[Provider] Rancher (#9173)

* Vendor Rancher Go library.

* Implement Rancher Provider.

Starting implementation taken from
https://github.com/platanus/terraform-provider-rancher

Commits from jidonoso@gmail.com and raphael.pinson@camptocamp.com
This commit is contained in:
John Engelman 2016-12-05 09:29:41 -06:00 committed by Paul Stack
parent 042695fe56
commit 243ecf3b4f
241 changed files with 53807 additions and 0 deletions

View File

@ -0,0 +1,15 @@
package main
import (
"github.com/hashicorp/terraform/builtin/providers/rancher"
"github.com/hashicorp/terraform/plugin"
"github.com/hashicorp/terraform/terraform"
)
func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: func() terraform.ResourceProvider {
return rancher.Provider()
},
})
}

View File

@ -0,0 +1,76 @@
package rancher
import (
"log"
rancherClient "github.com/rancher/go-rancher/client"
"github.com/raphink/go-rancher/catalog"
)
type Config struct {
*rancherClient.RancherClient
APIURL string
AccessKey string
SecretKey string
}
// Create creates a generic Rancher client
func (c *Config) CreateClient() error {
client, err := rancherClient.NewRancherClient(&rancherClient.ClientOpts{
Url: c.APIURL,
AccessKey: c.AccessKey,
SecretKey: c.SecretKey,
})
if err != nil {
return err
}
log.Printf("[INFO] Rancher Client configured for url: %s", c.APIURL)
c.RancherClient = client
return nil
}
func (c *Config) EnvironmentClient(env string) (*rancherClient.RancherClient, error) {
url := c.APIURL + "/projects/" + env + "/schemas"
client, err := rancherClient.NewRancherClient(&rancherClient.ClientOpts{
Url: url,
AccessKey: c.AccessKey,
SecretKey: c.SecretKey,
})
if err != nil {
return nil, err
}
log.Printf("[INFO] Rancher Client configured for url: %s", url)
return client, nil
}
func (c *Config) RegistryClient(id string) (*rancherClient.RancherClient, error) {
reg, err := c.Registry.ById(id)
if err != nil {
return nil, err
}
return c.EnvironmentClient(reg.AccountId)
}
func (c *Config) CatalogClient() (*catalog.RancherClient, error) {
url := c.APIURL + "-catalog/schemas"
client, err := catalog.NewRancherClient(&catalog.ClientOpts{
Url: url,
AccessKey: c.AccessKey,
SecretKey: c.SecretKey,
})
if err != nil {
return nil, err
}
log.Printf("[INFO] Rancher Catalog Client configured for url: %s", url)
return client, nil
}

View File

@ -0,0 +1,28 @@
package rancher
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccRancherEnvironment_importBasic(t *testing.T) {
resourceName := "rancher_environment.foo"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherEnvironmentDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherEnvironmentConfig,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,28 @@
package rancher
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccRancherRegistrationToken_importBasic(t *testing.T) {
resourceName := "rancher_registration_token.foo"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherRegistrationTokenDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherRegistrationTokenConfig,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,30 @@
package rancher
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccRancherRegistryCredential_importBasic(t *testing.T) {
resourceName := "rancher_registry_credential.foo"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherRegistryCredentialDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherRegistryCredentialConfig,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"secret_value"},
},
},
})
}

View File

@ -0,0 +1,28 @@
package rancher
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccRancherRegistry_importBasic(t *testing.T) {
resourceName := "rancher_registry.foo"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherRegistryDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherRegistryConfig,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,28 @@
package rancher
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccRancherStack_importBasic(t *testing.T) {
resourceName := "rancher_stack.foo"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherStackDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherStackConfig,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,66 @@
package rancher
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
// Provider returns a terraform.ResourceProvider.
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"api_url": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("RANCHER_URL", nil),
Description: descriptions["api_url"],
},
"access_key": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("RANCHER_ACCESS_KEY", ""),
Description: descriptions["access_key"],
},
"secret_key": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("RANCHER_SECRET_KEY", ""),
Description: descriptions["secret_key"],
},
},
ResourcesMap: map[string]*schema.Resource{
"rancher_environment": resourceRancherEnvironment(),
"rancher_registration_token": resourceRancherRegistrationToken(),
"rancher_registry": resourceRancherRegistry(),
"rancher_registry_credential": resourceRancherRegistryCredential(),
"rancher_stack": resourceRancherStack(),
},
ConfigureFunc: providerConfigure,
}
}
var descriptions map[string]string
func init() {
descriptions = map[string]string{
"access_key": "API Key used to authenticate with the rancher server",
"secret_key": "API secret used to authenticate with the rancher server",
"api_url": "The URL to the rancher API",
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := &Config{
APIURL: d.Get("api_url").(string) + "/v1",
AccessKey: d.Get("access_key").(string),
SecretKey: d.Get("secret_key").(string),
}
err := config.CreateClient()
return config, err
}

View File

@ -0,0 +1,35 @@
package rancher
import (
"os"
"testing"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
var testAccProviders map[string]terraform.ResourceProvider
var testAccProvider *schema.Provider
func init() {
testAccProvider = Provider().(*schema.Provider)
testAccProviders = map[string]terraform.ResourceProvider{
"rancher": testAccProvider,
}
}
func TestProvider(t *testing.T) {
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
t.Fatalf("err: %s", err)
}
}
func TestProvider_impl(t *testing.T) {
var _ terraform.ResourceProvider = Provider()
}
func testAccPreCheck(t *testing.T) {
if v := os.Getenv("RANCHER_URL"); v == "" {
t.Fatal("RANCHER_URL must be set for acceptance tests")
}
}

View File

@ -0,0 +1,194 @@
package rancher
import (
"fmt"
"log"
"strings"
"time"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
rancherClient "github.com/rancher/go-rancher/client"
)
func resourceRancherEnvironment() *schema.Resource {
return &schema.Resource{
Create: resourceRancherEnvironmentCreate,
Read: resourceRancherEnvironmentRead,
Update: resourceRancherEnvironmentUpdate,
Delete: resourceRancherEnvironmentDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"orchestration": &schema.Schema{
Type: schema.TypeString,
Default: "cattle",
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"cattle", "kubernetes", "mesos", "swarm"}, true),
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
},
}
}
func resourceRancherEnvironmentCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Creating Environment: %s", d.Id())
client := meta.(*Config)
name := d.Get("name").(string)
description := d.Get("description").(string)
orchestration := d.Get("orchestration").(string)
data := map[string]interface{}{
"name": &name,
"description": &description,
}
setOrchestrationFields(orchestration, data)
var newEnv rancherClient.Project
if err := client.Create("project", data, &newEnv); err != nil {
return err
}
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "removed", "removing"},
Target: []string{"active"},
Refresh: EnvironmentStateRefreshFunc(client, newEnv.Id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for environment (%s) to be created: %s", newEnv.Id, waitErr)
}
d.SetId(newEnv.Id)
log.Printf("[INFO] Environment ID: %s", d.Id())
return resourceRancherEnvironmentRead(d, meta)
}
func resourceRancherEnvironmentRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing Environment: %s", d.Id())
client := meta.(*Config)
env, err := client.Project.ById(d.Id())
if err != nil {
return err
}
log.Printf("[INFO] Environment Name: %s", env.Name)
d.Set("description", env.Description)
d.Set("name", env.Name)
d.Set("orchestration", GetActiveOrchestration(env))
return nil
}
func resourceRancherEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Config)
name := d.Get("name").(string)
description := d.Get("description").(string)
orchestration := d.Get("orchestration").(string)
data := map[string]interface{}{
"name": &name,
"description": &description,
}
setOrchestrationFields(orchestration, data)
var newEnv rancherClient.Project
env, err := client.Project.ById(d.Id())
if err != nil {
return err
}
if err := client.Update("project", &env.Resource, data, &newEnv); err != nil {
return err
}
return resourceRancherEnvironmentRead(d, meta)
}
func resourceRancherEnvironmentDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Deleting Environment: %s", d.Id())
id := d.Id()
client := meta.(*Config)
env, err := client.Project.ById(id)
if err != nil {
return err
}
if err := client.Project.Delete(env); err != nil {
return fmt.Errorf("Error deleting Environment: %s", err)
}
log.Printf("[DEBUG] Waiting for environment (%s) to be removed", id)
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "removed", "removing"},
Target: []string{"removed"},
Refresh: EnvironmentStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for environment (%s) to be removed: %s", id, waitErr)
}
d.SetId("")
return nil
}
func setOrchestrationFields(orchestration string, data map[string]interface{}) {
orch := strings.ToLower(orchestration)
data["swarm"] = false
data["kubernetes"] = false
data["mesos"] = false
if orch == "k8s" {
orch = "kubernetes"
}
data[orch] = true
}
// EnvironmentStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
// a Rancher Environment.
func EnvironmentStateRefreshFunc(client *Config, environmentID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
env, err := client.Project.ById(environmentID)
if err != nil {
return nil, "", err
}
return env, env.State, nil
}
}

View File

@ -0,0 +1,107 @@
package rancher
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
rancherClient "github.com/rancher/go-rancher/client"
)
func TestAccRancherEnvironment(t *testing.T) {
var environment rancherClient.Project
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherEnvironmentDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherEnvironmentConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherEnvironmentExists("rancher_environment.foo", &environment),
resource.TestCheckResourceAttr("rancher_environment.foo", "name", "foo"),
resource.TestCheckResourceAttr("rancher_environment.foo", "description", "Terraform acc test group"),
resource.TestCheckResourceAttr("rancher_environment.foo", "orchestration", "cattle"),
),
},
resource.TestStep{
Config: testAccRancherEnvironmentUpdateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherEnvironmentExists("rancher_environment.foo", &environment),
resource.TestCheckResourceAttr("rancher_environment.foo", "name", "foo2"),
resource.TestCheckResourceAttr("rancher_environment.foo", "description", "Terraform acc test group - updated"),
resource.TestCheckResourceAttr("rancher_environment.foo", "orchestration", "swarm"),
),
},
},
})
}
func testAccCheckRancherEnvironmentExists(n string, env *rancherClient.Project) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No App Name is set")
}
client := testAccProvider.Meta().(*Config)
foundEnv, err := client.Project.ById(rs.Primary.ID)
if err != nil {
return err
}
if foundEnv.Resource.Id != rs.Primary.ID {
return fmt.Errorf("Environment not found")
}
*env = *foundEnv
return nil
}
}
func testAccCheckRancherEnvironmentDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*Config)
for _, rs := range s.RootModule().Resources {
if rs.Type != "rancher_environment" {
continue
}
env, err := client.Project.ById(rs.Primary.ID)
if err == nil {
if env != nil &&
env.Resource.Id == rs.Primary.ID &&
env.State != "removed" {
return fmt.Errorf("Environment still exists")
}
}
return nil
}
return nil
}
const testAccRancherEnvironmentConfig = `
resource "rancher_environment" "foo" {
name = "foo"
description = "Terraform acc test group"
orchestration = "cattle"
}
`
const testAccRancherEnvironmentUpdateConfig = `
resource "rancher_environment" "foo" {
name = "foo2"
description = "Terraform acc test group - updated"
orchestration = "swarm"
}
`

View File

@ -0,0 +1,198 @@
package rancher
import (
"fmt"
"log"
"time"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
rancherClient "github.com/rancher/go-rancher/client"
)
func resourceRancherRegistrationToken() *schema.Resource {
return &schema.Resource{
Create: resourceRancherRegistrationTokenCreate,
Read: resourceRancherRegistrationTokenRead,
Delete: resourceRancherRegistrationTokenDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"environment_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"token": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"registration_url": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"command": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
}
}
func resourceRancherRegistrationTokenCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Creating RegistrationToken: %s", d.Id())
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
name := d.Get("name").(string)
description := d.Get("description").(string)
data := map[string]interface{}{
"name": &name,
"description": &description,
}
var newRegT rancherClient.RegistrationToken
if err := client.Create("registrationToken", data, &newRegT); err != nil {
return err
}
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "removed", "removing"},
Target: []string{"active"},
Refresh: RegistrationTokenStateRefreshFunc(client, newRegT.Id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registration token (%s) to be created: %s", newRegT.Id, waitErr)
}
d.SetId(newRegT.Id)
log.Printf("[INFO] RegistrationToken ID: %s", d.Id())
return resourceRancherRegistrationTokenRead(d, meta)
}
func resourceRancherRegistrationTokenRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing RegistrationToken: %s", d.Id())
client := meta.(*Config)
regT, err := client.RegistrationToken.ById(d.Id())
if err != nil {
return err
}
log.Printf("[INFO] RegistrationToken Name: %s", regT.Name)
d.Set("description", regT.Description)
d.Set("name", regT.Name)
d.Set("token", regT.Token)
d.Set("registration_url", regT.RegistrationUrl)
d.Set("environment_id", regT.AccountId)
d.Set("command", regT.Command)
return nil
}
func resourceRancherRegistrationTokenDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Deleting RegistrationToken: %s", d.Id())
id := d.Id()
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
regT, err := client.RegistrationToken.ById(id)
if err != nil {
return err
}
// Step 1: Deactivate
if _, e := client.RegistrationToken.ActionDeactivate(regT); e != nil {
return fmt.Errorf("Error deactivating RegistrationToken: %s", err)
}
log.Printf("[DEBUG] Waiting for registration token (%s) to be deactivated", id)
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "inactive", "deactivating"},
Target: []string{"inactive"},
Refresh: RegistrationTokenStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registration token (%s) to be deactivated: %s", id, waitErr)
}
// Update resource to reflect its state
regT, err = client.RegistrationToken.ById(id)
if err != nil {
return fmt.Errorf("Failed to refresh state of deactivated registration token (%s): %s", id, err)
}
// Step 2: Remove
if _, err := client.RegistrationToken.ActionRemove(regT); err != nil {
return fmt.Errorf("Error removing RegistrationToken: %s", err)
}
log.Printf("[DEBUG] Waiting for registration token (%s) to be removed", id)
stateConf = &resource.StateChangeConf{
Pending: []string{"inactive", "removed", "removing"},
Target: []string{"removed"},
Refresh: RegistrationTokenStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr = stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registration token (%s) to be removed: %s", id, waitErr)
}
d.SetId("")
return nil
}
// RegistrationTokenStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
// a Rancher RegistrationToken.
func RegistrationTokenStateRefreshFunc(client *rancherClient.RancherClient, regTID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
regT, err := client.RegistrationToken.ById(regTID)
if err != nil {
return nil, "", err
}
return regT, regT.State, nil
}
}

View File

@ -0,0 +1,123 @@
package rancher
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
rancherClient "github.com/rancher/go-rancher/client"
)
func TestAccRancherRegistrationToken(t *testing.T) {
var registrationToken rancherClient.RegistrationToken
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherRegistrationTokenDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherRegistrationTokenConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherRegistrationTokenExists("rancher_registration_token.foo", &registrationToken),
resource.TestCheckResourceAttr(
"rancher_registration_token.foo", "name", "foo"),
resource.TestCheckResourceAttr(
"rancher_registration_token.foo", "description", "Terraform acc test group"),
resource.TestCheckResourceAttrSet("rancher_registration_token.foo", "command"),
resource.TestCheckResourceAttrSet("rancher_registration_token.foo", "registration_url"),
resource.TestCheckResourceAttrSet("rancher_registration_token.foo", "token"),
),
},
resource.TestStep{
Config: testAccRancherRegistrationTokenUpdateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherRegistrationTokenExists("rancher_registration_token.foo", &registrationToken),
resource.TestCheckResourceAttr(
"rancher_registration_token.foo", "name", "foo-u"),
resource.TestCheckResourceAttr(
"rancher_registration_token.foo", "description", "Terraform acc test group-u"),
resource.TestCheckResourceAttrSet("rancher_registration_token.foo", "command"),
resource.TestCheckResourceAttrSet("rancher_registration_token.foo", "registration_url"),
resource.TestCheckResourceAttrSet("rancher_registration_token.foo", "token"),
),
},
},
})
}
func testAccCheckRancherRegistrationTokenExists(n string, regT *rancherClient.RegistrationToken) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No App Name is set")
}
client := testAccProvider.Meta().(*Config)
foundRegT, err := client.RegistrationToken.ById(rs.Primary.ID)
if err != nil {
return err
}
if foundRegT.Resource.Id != rs.Primary.ID {
return fmt.Errorf("RegistrationToken not found")
}
*regT = *foundRegT
return nil
}
}
func testAccCheckRancherRegistrationTokenDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*Config)
for _, rs := range s.RootModule().Resources {
if rs.Type != "rancher_registration_token" {
continue
}
regT, err := client.RegistrationToken.ById(rs.Primary.ID)
if err == nil {
if regT != nil &&
regT.Resource.Id == rs.Primary.ID &&
regT.State != "removed" {
return fmt.Errorf("RegistrationToken still exists")
}
}
return nil
}
return nil
}
const testAccRancherRegistrationTokenConfig = `
resource "rancher_environment" "foo" {
name = "foo"
}
resource "rancher_registration_token" "foo" {
name = "foo"
description = "Terraform acc test group"
environment_id = "${rancher_environment.foo.id}"
}
`
const testAccRancherRegistrationTokenUpdateConfig = `
resource "rancher_environment" "foo" {
name = "foo"
}
resource "rancher_registration_token" "foo" {
name = "foo-u"
description = "Terraform acc test group-u"
environment_id = "${rancher_environment.foo.id}"
}
`

View File

@ -0,0 +1,210 @@
package rancher
import (
"fmt"
"log"
"time"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
rancherClient "github.com/rancher/go-rancher/client"
)
func resourceRancherRegistry() *schema.Resource {
return &schema.Resource{
Create: resourceRancherRegistryCreate,
Read: resourceRancherRegistryRead,
Update: resourceRancherRegistryUpdate,
Delete: resourceRancherRegistryDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"server_address": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"environment_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
},
}
}
func resourceRancherRegistryCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Creating Registry: %s", d.Id())
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
name := d.Get("name").(string)
description := d.Get("description").(string)
serverAddress := d.Get("server_address").(string)
registry := rancherClient.Registry{
Name: name,
Description: description,
ServerAddress: serverAddress,
}
newRegistry, err := client.Registry.Create(&registry)
if err != nil {
return err
}
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "removed", "removing"},
Target: []string{"active"},
Refresh: RegistryStateRefreshFunc(client, newRegistry.Id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registry (%s) to be created: %s", newRegistry.Id, waitErr)
}
d.SetId(newRegistry.Id)
log.Printf("[INFO] Registry ID: %s", d.Id())
return resourceRancherRegistryRead(d, meta)
}
func resourceRancherRegistryRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing Registry: %s", d.Id())
client := meta.(*Config)
registry, err := client.Registry.ById(d.Id())
if err != nil {
return err
}
log.Printf("[INFO] Registry Name: %s", registry.Name)
d.Set("description", registry.Description)
d.Set("name", registry.Name)
d.Set("server_address", registry.ServerAddress)
d.Set("environment_id", registry.AccountId)
return nil
}
func resourceRancherRegistryUpdate(d *schema.ResourceData, meta interface{}) error {
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
registry, err := client.Registry.ById(d.Id())
if err != nil {
return err
}
name := d.Get("name").(string)
description := d.Get("description").(string)
registry.Name = name
registry.Description = description
client.Registry.Update(registry, &registry)
return resourceRancherRegistryRead(d, meta)
}
func resourceRancherRegistryDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Deleting Registry: %s", d.Id())
id := d.Id()
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
reg, err := client.Registry.ById(id)
if err != nil {
return err
}
// Step 1: Deactivate
if _, e := client.Registry.ActionDeactivate(reg); e != nil {
return fmt.Errorf("Error deactivating Registry: %s", err)
}
log.Printf("[DEBUG] Waiting for registry (%s) to be deactivated", id)
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "inactive", "deactivating"},
Target: []string{"inactive"},
Refresh: RegistryStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registry (%s) to be deactivated: %s", id, waitErr)
}
// Update resource to reflect its state
reg, err = client.Registry.ById(id)
if err != nil {
return fmt.Errorf("Failed to refresh state of deactivated registry (%s): %s", id, err)
}
// Step 2: Remove
if _, err := client.Registry.ActionRemove(reg); err != nil {
return fmt.Errorf("Error removing Registry: %s", err)
}
log.Printf("[DEBUG] Waiting for registry (%s) to be removed", id)
stateConf = &resource.StateChangeConf{
Pending: []string{"inactive", "removed", "removing"},
Target: []string{"removed"},
Refresh: RegistryStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr = stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registry (%s) to be removed: %s", id, waitErr)
}
d.SetId("")
return nil
}
// RegistryStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
// a Rancher Environment.
func RegistryStateRefreshFunc(client *rancherClient.RancherClient, registryID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
env, err := client.Registry.ById(registryID)
if err != nil {
return nil, "", err
}
return env, env.State, nil
}
}

View File

@ -0,0 +1,232 @@
package rancher
import (
"fmt"
"log"
"time"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
rancherClient "github.com/rancher/go-rancher/client"
)
func resourceRancherRegistryCredential() *schema.Resource {
return &schema.Resource{
Create: resourceRancherRegistryCredentialCreate,
Read: resourceRancherRegistryCredentialRead,
Update: resourceRancherRegistryCredentialUpdate,
Delete: resourceRancherRegistryCredentialDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"registry_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"email": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"public_value": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"secret_value": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
},
}
}
func resourceRancherRegistryCredentialCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Creating RegistryCredential: %s", d.Id())
client, err := meta.(*Config).RegistryClient(d.Get("registry_id").(string))
if err != nil {
return err
}
name := d.Get("name").(string)
description := d.Get("description").(string)
email := d.Get("email").(string)
publicValue := d.Get("public_value").(string)
secretValue := d.Get("secret_value").(string)
registryID := d.Get("registry_id").(string)
registryCred := rancherClient.RegistryCredential{
Name: name,
Description: description,
Email: email,
PublicValue: publicValue,
SecretValue: secretValue,
RegistryId: registryID,
}
newRegistryCredential, err := client.RegistryCredential.Create(&registryCred)
if err != nil {
return err
}
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "removed", "removing"},
Target: []string{"active"},
Refresh: RegistryCredentialStateRefreshFunc(client, newRegistryCredential.Id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registry credential (%s) to be created: %s", newRegistryCredential.Id, waitErr)
}
d.SetId(newRegistryCredential.Id)
log.Printf("[INFO] RegistryCredential ID: %s", d.Id())
return resourceRancherRegistryCredentialRead(d, meta)
}
func resourceRancherRegistryCredentialRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing RegistryCredential: %s", d.Id())
client := meta.(*Config)
registryCred, err := client.RegistryCredential.ById(d.Id())
if err != nil {
return err
}
log.Printf("[INFO] RegistryCredential Name: %s", registryCred.Name)
d.Set("description", registryCred.Description)
d.Set("name", registryCred.Name)
d.Set("email", registryCred.Email)
d.Set("public_value", registryCred.PublicValue)
d.Set("registry_id", registryCred.RegistryId)
return nil
}
func resourceRancherRegistryCredentialUpdate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Updating RegistryCredential: %s", d.Id())
client, err := meta.(*Config).RegistryClient(d.Get("registry_id").(string))
if err != nil {
return err
}
registryCred, err := client.RegistryCredential.ById(d.Id())
if err != nil {
return err
}
name := d.Get("name").(string)
description := d.Get("description").(string)
email := d.Get("email").(string)
publicValue := d.Get("public_value").(string)
secretValue := d.Get("secret_value").(string)
registryCred.Name = name
registryCred.Description = description
registryCred.Email = email
registryCred.PublicValue = publicValue
registryCred.SecretValue = secretValue
client.RegistryCredential.Update(registryCred, &registryCred)
return resourceRancherRegistryCredentialRead(d, meta)
}
func resourceRancherRegistryCredentialDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Deleting RegistryCredential: %s", d.Id())
id := d.Id()
client, err := meta.(*Config).RegistryClient(d.Get("registry_id").(string))
if err != nil {
return err
}
reg, err := client.RegistryCredential.ById(id)
if err != nil {
return err
}
// Step 1: Deactivate
if _, e := client.RegistryCredential.ActionDeactivate(reg); e != nil {
return fmt.Errorf("Error deactivating RegistryCredential: %s", err)
}
log.Printf("[DEBUG] Waiting for registry credential (%s) to be deactivated", id)
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "inactive", "deactivating"},
Target: []string{"inactive"},
Refresh: RegistryCredentialStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registry credential (%s) to be deactivated: %s", id, waitErr)
}
// Update resource to reflect its state
reg, err = client.RegistryCredential.ById(id)
if err != nil {
return fmt.Errorf("Failed to refresh state of deactivated registry credential (%s): %s", id, err)
}
// Step 2: Remove
if _, err := client.RegistryCredential.ActionRemove(reg); err != nil {
return fmt.Errorf("Error removing RegistryCredential: %s", err)
}
log.Printf("[DEBUG] Waiting for registry (%s) to be removed", id)
stateConf = &resource.StateChangeConf{
Pending: []string{"inactive", "removed", "removing"},
Target: []string{"removed"},
Refresh: RegistryCredentialStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr = stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for registry (%s) to be removed: %s", id, waitErr)
}
d.SetId("")
return nil
}
// RegistryCredentialStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
// a Rancher Environment.
func RegistryCredentialStateRefreshFunc(client *rancherClient.RancherClient, registryCredID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
regC, err := client.RegistryCredential.ById(registryCredID)
if err != nil {
return nil, "", err
}
return regC, regC.State, nil
}
}

View File

@ -0,0 +1,135 @@
package rancher
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
rancherClient "github.com/rancher/go-rancher/client"
)
func TestAccRancherRegistryCredential(t *testing.T) {
var registry rancherClient.RegistryCredential
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherRegistryCredentialDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherRegistryCredentialConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherRegistryCredentialExists("rancher_registry_credential.foo", &registry),
resource.TestCheckResourceAttr("rancher_registry_credential.foo", "name", "foo"),
resource.TestCheckResourceAttr("rancher_registry_credential.foo", "description", "registry credential test"),
resource.TestCheckResourceAttr("rancher_registry_credential.foo", "public_value", "user"),
),
},
resource.TestStep{
Config: testAccRancherRegistryCredentialUpdateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherRegistryCredentialExists("rancher_registry_credential.foo", &registry),
resource.TestCheckResourceAttr("rancher_registry_credential.foo", "name", "foo2"),
resource.TestCheckResourceAttr("rancher_registry_credential.foo", "description", "registry credential test - updated"),
resource.TestCheckResourceAttr("rancher_registry_credential.foo", "public_value", "user2"),
),
},
},
})
}
func testAccCheckRancherRegistryCredentialExists(n string, reg *rancherClient.RegistryCredential) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No App Name is set")
}
client := testAccProvider.Meta().(*Config)
foundReg, err := client.RegistryCredential.ById(rs.Primary.ID)
if err != nil {
return err
}
if foundReg.Resource.Id != rs.Primary.ID {
return fmt.Errorf("Environment not found")
}
*reg = *foundReg
return nil
}
}
func testAccCheckRancherRegistryCredentialDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*Config)
for _, rs := range s.RootModule().Resources {
if rs.Type != "rancher_registry_credential" {
continue
}
reg, err := client.RegistryCredential.ById(rs.Primary.ID)
if err == nil {
if reg != nil &&
reg.Resource.Id == rs.Primary.ID &&
reg.State != "removed" {
return fmt.Errorf("RegistryCredential still exists")
}
}
return nil
}
return nil
}
const testAccRancherRegistryCredentialConfig = `
resource "rancher_environment" "foo" {
name = "foo"
}
resource "rancher_registry" "foo" {
name = "foo"
description = "registry test"
server_address = "http://bar.com:8080"
environment_id = "${rancher_environment.foo.id}"
}
resource "rancher_registry_credential" "foo" {
name = "foo"
description = "registry credential test"
registry_id = "${rancher_registry.foo.id}"
email = "registry@credential.com"
public_value = "user"
secret_value = "pass"
}
`
const testAccRancherRegistryCredentialUpdateConfig = `
resource "rancher_environment" "foo" {
name = "foo"
}
resource "rancher_registry" "foo" {
name = "foo"
description = "registry test"
server_address = "http://bar.com:8080"
environment_id = "${rancher_environment.foo.id}"
}
resource "rancher_registry_credential" "foo" {
name = "foo2"
description = "registry credential test - updated"
registry_id = "${rancher_registry.foo.id}"
email = "registry@credential.com"
public_value = "user2"
secret_value = "pass"
}
`

View File

@ -0,0 +1,147 @@
package rancher
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
rancherClient "github.com/rancher/go-rancher/client"
)
func TestAccRancherRegistry(t *testing.T) {
var registry rancherClient.Registry
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherRegistryDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherRegistryConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherRegistryExists("rancher_registry.foo", &registry),
resource.TestCheckResourceAttr("rancher_registry.foo", "name", "foo"),
resource.TestCheckResourceAttr("rancher_registry.foo", "description", "registry test"),
resource.TestCheckResourceAttr("rancher_registry.foo", "server_address", "http://foo.com:8080"),
),
},
resource.TestStep{
Config: testAccRancherRegistryUpdateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherRegistryExists("rancher_registry.foo", &registry),
resource.TestCheckResourceAttr("rancher_registry.foo", "name", "foo2"),
resource.TestCheckResourceAttr("rancher_registry.foo", "description", "registry test - updated"),
resource.TestCheckResourceAttr("rancher_registry.foo", "server_address", "http://foo.updated.com:8080"),
),
},
resource.TestStep{
Config: testAccRancherRegistryRecreateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherRegistryExists("rancher_registry.foo", &registry),
resource.TestCheckResourceAttr("rancher_registry.foo", "name", "foo"),
resource.TestCheckResourceAttr("rancher_registry.foo", "description", "registry test"),
resource.TestCheckResourceAttr("rancher_registry.foo", "server_address", "http://foo.com:8080"),
),
},
},
})
}
func testAccCheckRancherRegistryExists(n string, reg *rancherClient.Registry) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No App Name is set")
}
client := testAccProvider.Meta().(*Config)
foundReg, err := client.Registry.ById(rs.Primary.ID)
if err != nil {
return err
}
if foundReg.Resource.Id != rs.Primary.ID {
return fmt.Errorf("Environment not found")
}
*reg = *foundReg
return nil
}
}
func testAccCheckRancherRegistryDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*Config)
for _, rs := range s.RootModule().Resources {
if rs.Type != "rancher_registry" {
continue
}
reg, err := client.Registry.ById(rs.Primary.ID)
if err == nil {
if reg != nil &&
reg.Resource.Id == rs.Primary.ID &&
reg.State != "removed" {
return fmt.Errorf("Registry still exists")
}
}
return nil
}
return nil
}
const testAccRancherRegistryConfig = `
resource "rancher_environment" "foo_registry" {
name = "registry test"
description = "environment to test registries"
}
resource "rancher_registry" "foo" {
name = "foo"
description = "registry test"
server_address = "http://foo.com:8080"
environment_id = "${rancher_environment.foo_registry.id}"
}
`
const testAccRancherRegistryUpdateConfig = `
resource "rancher_environment" "foo_registry" {
name = "registry test"
description = "environment to test registries"
}
resource "rancher_registry" "foo" {
name = "foo2"
description = "registry test - updated"
server_address = "http://foo.updated.com:8080"
environment_id = "${rancher_environment.foo_registry.id}"
}
`
const testAccRancherRegistryRecreateConfig = `
resource "rancher_environment" "foo_registry" {
name = "registry test"
description = "environment to test registries"
}
resource "rancher_environment" "foo_registry2" {
name = "alternative registry test"
description = "other environment to test registries"
}
resource "rancher_registry" "foo" {
name = "foo"
description = "registry test"
server_address = "http://foo.com:8080"
environment_id = "${rancher_environment.foo_registry2.id}"
}
`

View File

@ -0,0 +1,384 @@
package rancher
import (
"fmt"
"log"
"strings"
"time"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
rancherClient "github.com/rancher/go-rancher/client"
)
func resourceRancherStack() *schema.Resource {
return &schema.Resource{
Create: resourceRancherStackCreate,
Read: resourceRancherStackRead,
Update: resourceRancherStackUpdate,
Delete: resourceRancherStackDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"environment_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"docker_compose": {
Type: schema.TypeString,
Optional: true,
},
"rancher_compose": {
Type: schema.TypeString,
Optional: true,
},
"environment": {
Type: schema.TypeMap,
Optional: true,
},
"catalog_id": {
Type: schema.TypeString,
Optional: true,
},
"scope": {
Type: schema.TypeString,
Default: "user",
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"user", "system"}, true),
},
"start_on_create": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"finish_upgrade": {
Type: schema.TypeBool,
Optional: true,
},
"rendered_docker_compose": {
Type: schema.TypeString,
Computed: true,
},
"rendered_rancher_compose": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
func resourceRancherStackCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Creating Stack: %s", d.Id())
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
data, err := makeStackData(d, meta)
if err != nil {
return err
}
var newStack rancherClient.Environment
if err := client.Create("environment", data, &newStack); err != nil {
return err
}
stateConf := &resource.StateChangeConf{
Pending: []string{"activating", "active", "removed", "removing"},
Target: []string{"active"},
Refresh: StackStateRefreshFunc(client, newStack.Id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for stack (%s) to be created: %s", newStack.Id, waitErr)
}
d.SetId(newStack.Id)
log.Printf("[INFO] Stack ID: %s", d.Id())
return resourceRancherStackRead(d, meta)
}
func resourceRancherStackRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing Stack: %s", d.Id())
client := meta.(*Config)
stack, err := client.Environment.ById(d.Id())
if err != nil {
return err
}
config, err := client.Environment.ActionExportconfig(stack, &rancherClient.ComposeConfigInput{})
if err != nil {
return err
}
log.Printf("[INFO] Stack Name: %s", stack.Name)
d.Set("description", stack.Description)
d.Set("name", stack.Name)
d.Set("rendered_docker_compose", strings.Replace(config.DockerComposeConfig, "\r", "", -1))
d.Set("rendered_rancher_compose", strings.Replace(config.RancherComposeConfig, "\r", "", -1))
d.Set("environment_id", stack.AccountId)
d.Set("environment", stack.Environment)
if stack.ExternalId == "" {
d.Set("scope", "user")
d.Set("catalog_id", "")
} else {
trimmedID := strings.TrimPrefix(stack.ExternalId, "system-")
if trimmedID == stack.ExternalId {
d.Set("scope", "user")
} else {
d.Set("scope", "system")
}
d.Set("catalog_id", strings.TrimPrefix(trimmedID, "catalog://"))
}
d.Set("start_on_create", stack.StartOnCreate)
return nil
}
func resourceRancherStackUpdate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Updating Stack: %s", d.Id())
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
d.Partial(true)
data, err := makeStackData(d, meta)
if err != nil {
return err
}
stack, err := client.Environment.ById(d.Id())
if err != nil {
return err
}
var newStack rancherClient.Environment
if err := client.Update("environment", &stack.Resource, data, &newStack); err != nil {
return err
}
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "active-updating"},
Target: []string{"active"},
Refresh: StackStateRefreshFunc(client, newStack.Id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
s, waitErr := stateConf.WaitForState()
stack = s.(*rancherClient.Environment)
if waitErr != nil {
return fmt.Errorf(
"Error waiting for stack (%s) to be updated: %s", stack.Id, waitErr)
}
d.SetPartial("name")
d.SetPartial("description")
d.SetPartial("scope")
if d.HasChange("docker_compose") ||
d.HasChange("rancher_compose") ||
d.HasChange("environment") ||
d.HasChange("catalog_id") {
envMap := make(map[string]interface{})
for key, value := range *data["environment"].(*map[string]string) {
envValue := value
envMap[key] = &envValue
}
stack, err = client.Environment.ActionUpgrade(stack, &rancherClient.EnvironmentUpgrade{
DockerCompose: *data["dockerCompose"].(*string),
RancherCompose: *data["rancherCompose"].(*string),
Environment: envMap,
ExternalId: *data["externalId"].(*string),
})
if err != nil {
return err
}
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "upgrading", "upgraded"},
Target: []string{"upgraded"},
Refresh: StackStateRefreshFunc(client, stack.Id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
s, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for stack (%s) to be upgraded: %s", stack.Id, waitErr)
}
stack = s.(*rancherClient.Environment)
if d.Get("finish_upgrade").(bool) {
stack, err = client.Environment.ActionFinishupgrade(stack)
if err != nil {
return err
}
stateConf = &resource.StateChangeConf{
Pending: []string{"active", "upgraded"},
Target: []string{"active"},
Refresh: StackStateRefreshFunc(client, stack.Id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr = stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for stack (%s) to be upgraded: %s", stack.Id, waitErr)
}
}
d.SetPartial("rendered_docker_compose")
d.SetPartial("rendered_rancher_compose")
d.SetPartial("docker_compose")
d.SetPartial("rancher_compose")
d.SetPartial("environment")
d.SetPartial("catalog_id")
}
d.Partial(false)
return resourceRancherStackRead(d, meta)
}
func resourceRancherStackDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Deleting Stack: %s", d.Id())
id := d.Id()
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
stack, err := client.Environment.ById(id)
if err != nil {
return err
}
if err := client.Environment.Delete(stack); err != nil {
return fmt.Errorf("Error deleting Stack: %s", err)
}
log.Printf("[DEBUG] Waiting for stack (%s) to be removed", id)
stateConf := &resource.StateChangeConf{
Pending: []string{"active", "removed", "removing"},
Target: []string{"removed"},
Refresh: StackStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
_, waitErr := stateConf.WaitForState()
if waitErr != nil {
return fmt.Errorf(
"Error waiting for stack (%s) to be removed: %s", id, waitErr)
}
d.SetId("")
return nil
}
// StackStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
// a Rancher Stack.
func StackStateRefreshFunc(client *rancherClient.RancherClient, stackID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
stack, err := client.Environment.ById(stackID)
if err != nil {
return nil, "", err
}
return stack, stack.State, nil
}
}
func environmentFromMap(m map[string]interface{}) map[string]string {
result := make(map[string]string)
for k, v := range m {
result[k] = v.(string)
}
return result
}
func makeStackData(d *schema.ResourceData, meta interface{}) (data map[string]interface{}, err error) {
name := d.Get("name").(string)
description := d.Get("description").(string)
var externalID string
var dockerCompose string
var rancherCompose string
var environment map[string]string
if c, ok := d.GetOk("catalog_id"); ok {
if scope, ok := d.GetOk("scope"); ok && scope.(string) == "system" {
externalID = "system-"
}
catalogID := c.(string)
externalID += "catalog://" + catalogID
catalogClient, err := meta.(*Config).CatalogClient()
if err != nil {
return data, err
}
template, err := catalogClient.Template.ById(catalogID)
if err != nil {
return data, fmt.Errorf("Failed to get catalog template: %s", err)
}
dockerCompose = template.Files["docker-compose.yml"].(string)
rancherCompose = template.Files["rancher-compose.yml"].(string)
}
if c, ok := d.GetOk("docker_compose"); ok {
dockerCompose = c.(string)
}
if c, ok := d.GetOk("rancher_compose"); ok {
rancherCompose = c.(string)
}
environment = environmentFromMap(d.Get("environment").(map[string]interface{}))
startOnCreate := d.Get("start_on_create")
data = map[string]interface{}{
"name": &name,
"description": &description,
"dockerCompose": &dockerCompose,
"rancherCompose": &rancherCompose,
"environment": &environment,
"externalId": &externalID,
"startOnCreate": &startOnCreate,
}
return data, nil
}

View File

@ -0,0 +1,311 @@
package rancher
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
rancherClient "github.com/rancher/go-rancher/client"
)
func TestAccRancherStack_basic(t *testing.T) {
var stack rancherClient.Environment
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherStackDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherStackConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherStackExists("rancher_stack.foo", &stack),
resource.TestCheckResourceAttr("rancher_stack.foo", "name", "foo"),
resource.TestCheckResourceAttr("rancher_stack.foo", "description", "Terraform acc test group"),
resource.TestCheckResourceAttr("rancher_stack.foo", "catalog_id", ""),
resource.TestCheckResourceAttr("rancher_stack.foo", "docker_compose", ""),
resource.TestCheckResourceAttr("rancher_stack.foo", "rancher_compose", ""),
testAccCheckRancherStackAttributes(&stack, emptyEnvironment, false),
),
},
resource.TestStep{
Config: testAccRancherStackUpdateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherStackExists("rancher_stack.foo", &stack),
resource.TestCheckResourceAttr("rancher_stack.foo", "name", "foo2"),
resource.TestCheckResourceAttr("rancher_stack.foo", "description", "Terraform acc test group - updated"),
resource.TestCheckResourceAttr("rancher_stack.foo", "catalog_id", ""),
resource.TestCheckResourceAttr("rancher_stack.foo", "docker_compose", ""),
resource.TestCheckResourceAttr("rancher_stack.foo", "rancher_compose", ""),
testAccCheckRancherStackAttributes(&stack, emptyEnvironment, false),
),
},
},
})
}
func TestAccRancherStack_compose(t *testing.T) {
var stack rancherClient.Environment
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherStackDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherStackComposeConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherStackExists("rancher_stack.compose", &stack),
resource.TestCheckResourceAttr("rancher_stack.compose", "name", "compose"),
resource.TestCheckResourceAttr("rancher_stack.compose", "description", "Terraform acc test group - compose"),
resource.TestCheckResourceAttr("rancher_stack.compose", "catalog_id", ""),
resource.TestCheckResourceAttr("rancher_stack.compose", "docker_compose", "web: { image: nginx }"),
resource.TestCheckResourceAttr("rancher_stack.compose", "rancher_compose", "web: { scale: 1 }"),
testAccCheckRancherStackAttributes(&stack, emptyEnvironment, false),
),
},
},
})
}
//The following tests are run against the Default environment because
//upgrading a stack automatically starts the services which never
//completes if there is no host available
func TestAccRancherStack_catalog(t *testing.T) {
var stack rancherClient.Environment
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRancherStackDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRancherStackSystemCatalogConfigInitial,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherStackExists("rancher_stack.catalog", &stack),
resource.TestCheckResourceAttr("rancher_stack.catalog", "name", "catalogInitial"),
resource.TestCheckResourceAttr("rancher_stack.catalog", "description", "Terraform acc test group - catalogInitial"),
resource.TestCheckResourceAttr("rancher_stack.catalog", "catalog_id", "community:janitor:0"),
resource.TestCheckResourceAttr("rancher_stack.catalog", "scope", "system"),
resource.TestCheckResourceAttr("rancher_stack.catalog", "docker_compose", ""),
resource.TestCheckResourceAttr("rancher_stack.catalog", "rancher_compose", ""),
resource.TestCheckResourceAttr("rancher_stack.catalog", "rendered_docker_compose", catalogDockerComposeInitial),
resource.TestCheckResourceAttr("rancher_stack.catalog", "rendered_rancher_compose", catalogRancherComposeInitial),
testAccCheckRancherStackAttributes(&stack, catalogEnvironment, true),
),
},
resource.TestStep{
Config: testAccRancherStackSystemCatalogConfigUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancherStackExists("rancher_stack.catalog", &stack),
resource.TestCheckResourceAttr("rancher_stack.catalog", "name", "catalogUpdate"),
resource.TestCheckResourceAttr("rancher_stack.catalog", "description", "Terraform acc test group - catalogUpdate"),
resource.TestCheckResourceAttr("rancher_stack.catalog", "catalog_id", "community:janitor:1"),
resource.TestCheckResourceAttr("rancher_stack.catalog", "scope", "user"),
resource.TestCheckResourceAttr("rancher_stack.catalog", "docker_compose", ""),
resource.TestCheckResourceAttr("rancher_stack.catalog", "rancher_compose", ""),
resource.TestCheckResourceAttr("rancher_stack.catalog", "rendered_docker_compose", catalogDockerComposeUpdate),
resource.TestCheckResourceAttr("rancher_stack.catalog", "rendered_rancher_compose", catalogRancherComposeUpdate),
testAccCheckRancherStackAttributes(&stack, catalogEnvironmentUpgrade, true),
),
},
},
})
}
func testAccCheckRancherStackExists(n string, stack *rancherClient.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No App Name is set")
}
client := testAccProvider.Meta().(*Config)
foundStack, err := client.Environment.ById(rs.Primary.ID)
if err != nil {
return err
}
if foundStack.Resource.Id != rs.Primary.ID {
return fmt.Errorf("Stack not found")
}
*stack = *foundStack
return nil
}
}
func testAccCheckRancherStackAttributes(stack *rancherClient.Environment, environment map[string]string, startOnCreate bool) resource.TestCheckFunc {
return func(s *terraform.State) error {
if len(stack.Environment) != len(environment) {
return fmt.Errorf("Bad environment size: %v should be: %v", len(stack.Environment), environment)
}
for k, v := range stack.Environment {
if environment[k] != v {
return fmt.Errorf("Bad environment value for %s: %s should be: %s", k, environment[k], v)
}
}
if stack.StartOnCreate != startOnCreate {
return fmt.Errorf("Bad startOnCreate: %t should be: %t", stack.StartOnCreate, startOnCreate)
}
return nil
}
}
func testAccCheckRancherStackDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*Config)
for _, rs := range s.RootModule().Resources {
if rs.Type != "rancher_stack" {
continue
}
stack, err := client.Environment.ById(rs.Primary.ID)
if err == nil {
if stack != nil &&
stack.Resource.Id == rs.Primary.ID &&
stack.State != "removed" {
return fmt.Errorf("Stack still exists")
}
}
return nil
}
return nil
}
const testAccRancherStackConfig = `
resource "rancher_environment" "foo" {
name = "foo"
}
resource "rancher_stack" "foo" {
name = "foo"
description = "Terraform acc test group"
environment_id = "${rancher_environment.foo.id}"
}
`
const testAccRancherStackUpdateConfig = `
resource "rancher_environment" "foo" {
name = "foo"
}
resource "rancher_stack" "foo" {
name = "foo2"
description = "Terraform acc test group - updated"
environment_id = "${rancher_environment.foo.id}"
}
`
const testAccRancherStackComposeConfig = `
resource "rancher_environment" "foo" {
name = "foo"
}
resource "rancher_stack" "compose" {
name = "compose"
description = "Terraform acc test group - compose"
environment_id = "${rancher_environment.foo.id}"
docker_compose = "web: { image: nginx }"
rancher_compose = "web: { scale: 1 }"
}
`
const testAccRancherStackSystemCatalogConfigInitial = `
resource "rancher_stack" "catalog" {
name = "catalogInitial"
description = "Terraform acc test group - catalogInitial"
environment_id = "1a5"
catalog_id = "community:janitor:0"
scope = "system"
start_on_create = true
environment {
EXCLUDE_LABEL = "cleanup=false"
FREQUENCY = "60"
KEEP = "rancher/agent:*"
}
}
`
const testAccRancherStackSystemCatalogConfigUpdate = `
resource "rancher_stack" "catalog" {
name = "catalogUpdate"
description = "Terraform acc test group - catalogUpdate"
environment_id = "1a5"
catalog_id = "community:janitor:1"
scope = "user"
environment {
EXCLUDE_LABEL = "cleanup=false"
FREQUENCY = "60"
KEEP = "rancher/agent:*"
KEEPC = "*:*"
}
}
`
var catalogDockerComposeInitial = `cleanup:
environment:
CLEAN_PERIOD: '60'
DELAY_TIME: '900'
KEEP_IMAGES: rancher/agent:*
labels:
io.rancher.scheduler.global: 'true'
io.rancher.scheduler.affinity:host_label_ne: cleanup=false
tty: true
image: meltwater/docker-cleanup:1.4.0
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker:/var/lib/docker
stdin_open: true
`
const catalogRancherComposeInitial = `{}
`
const catalogDockerComposeUpdate = `cleanup:
environment:
CLEAN_PERIOD: '60'
DELAY_TIME: '900'
KEEP_CONTAINERS: '*:*'
KEEP_IMAGES: rancher/agent:*
labels:
io.rancher.scheduler.global: 'true'
io.rancher.scheduler.affinity:host_label_ne: cleanup=false
image: sshipway/docker-cleanup:1.5.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker:/var/lib/docker
net: none
`
const catalogRancherComposeUpdate = `{}
`
var emptyEnvironment = map[string]string{}
var catalogEnvironment = map[string]string{
"EXCLUDE_LABEL": "cleanup=false",
"FREQUENCY": "60",
"KEEP": "rancher/agent:*",
}
var catalogEnvironmentUpgrade = map[string]string{
"EXCLUDE_LABEL": "cleanup=false",
"FREQUENCY": "60",
"KEEP": "rancher/agent:*",
"KEEPC": "*:*",
}

View File

@ -0,0 +1,19 @@
package rancher
import "github.com/rancher/go-rancher/client"
// GetActiveOrchestration get the name of the active orchestration for a environment
func GetActiveOrchestration(project *client.Project) string {
orch := "cattle"
switch {
case project.Swarm:
orch = "swarm"
case project.Mesos:
orch = "mesos"
case project.Kubernetes:
orch = "kubernetes"
}
return orch
}

View File

@ -42,6 +42,7 @@ import (
postgresqlprovider "github.com/hashicorp/terraform/builtin/providers/postgresql"
powerdnsprovider "github.com/hashicorp/terraform/builtin/providers/powerdns"
rabbitmqprovider "github.com/hashicorp/terraform/builtin/providers/rabbitmq"
rancherprovider "github.com/hashicorp/terraform/builtin/providers/rancher"
randomprovider "github.com/hashicorp/terraform/builtin/providers/random"
rundeckprovider "github.com/hashicorp/terraform/builtin/providers/rundeck"
scalewayprovider "github.com/hashicorp/terraform/builtin/providers/scaleway"
@ -102,6 +103,7 @@ var InternalProviders = map[string]plugin.ProviderFunc{
"postgresql": postgresqlprovider.Provider,
"powerdns": powerdnsprovider.Provider,
"rabbitmq": rabbitmqprovider.Provider,
"rancher": rancherprovider.Provider,
"random": randomprovider.Provider,
"rundeck": rundeckprovider.Provider,
"scaleway": scalewayprovider.Provider,

8
vendor/github.com/gorilla/websocket/AUTHORS generated vendored Normal file
View File

@ -0,0 +1,8 @@
# This is the official list of Gorilla WebSocket authors for copyright
# purposes.
#
# Please keep the list sorted.
Gary Burd <gary@beagledreams.com>
Joachim Bauch <mail@joachim-bauch.de>

22
vendor/github.com/gorilla/websocket/LICENSE generated vendored Normal file
View File

@ -0,0 +1,22 @@
Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

61
vendor/github.com/gorilla/websocket/README.md generated vendored Normal file
View File

@ -0,0 +1,61 @@
# Gorilla WebSocket
Gorilla WebSocket is a [Go](http://golang.org/) implementation of the
[WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol.
### Documentation
* [API Reference](http://godoc.org/github.com/gorilla/websocket)
* [Chat example](https://github.com/gorilla/websocket/tree/master/examples/chat)
* [Command example](https://github.com/gorilla/websocket/tree/master/examples/command)
* [Client and server example](https://github.com/gorilla/websocket/tree/master/examples/echo)
* [File watch example](https://github.com/gorilla/websocket/tree/master/examples/filewatch)
### Status
The Gorilla WebSocket package provides a complete and tested implementation of
the [WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol. The
package API is stable.
### Installation
go get github.com/gorilla/websocket
### Protocol Compliance
The Gorilla WebSocket package passes the server tests in the [Autobahn Test
Suite](http://autobahn.ws/testsuite) using the application in the [examples/autobahn
subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn).
### Gorilla WebSocket compared with other packages
<table>
<tr>
<th></th>
<th><a href="http://godoc.org/github.com/gorilla/websocket">github.com/gorilla</a></th>
<th><a href="http://godoc.org/golang.org/x/net/websocket">golang.org/x/net</a></th>
</tr>
<tr>
<tr><td colspan="3"><a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a> Features</td></tr>
<tr><td>Passes <a href="http://autobahn.ws/testsuite/">Autobahn Test Suite</a></td><td><a href="https://github.com/gorilla/websocket/tree/master/examples/autobahn">Yes</a></td><td>No</td></tr>
<tr><td>Receive <a href="https://tools.ietf.org/html/rfc6455#section-5.4">fragmented</a> message<td>Yes</td><td><a href="https://code.google.com/p/go/issues/detail?id=7632">No</a>, see note 1</td></tr>
<tr><td>Send <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close</a> message</td><td><a href="http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages">Yes</a></td><td><a href="https://code.google.com/p/go/issues/detail?id=4588">No</a></td></tr>
<tr><td>Send <a href="https://tools.ietf.org/html/rfc6455#section-5.5.2">pings</a> and receive <a href="https://tools.ietf.org/html/rfc6455#section-5.5.3">pongs</a></td><td><a href="http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages">Yes</a></td><td>No</td></tr>
<tr><td>Get the <a href="https://tools.ietf.org/html/rfc6455#section-5.6">type</a> of a received data message</td><td>Yes</td><td>Yes, see note 2</td></tr>
<tr><td colspan="3">Other Features</tr></td>
<tr><td>Limit size of received message</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.SetReadLimit">Yes</a></td><td><a href="https://code.google.com/p/go/issues/detail?id=5082">No</a></td></tr>
<tr><td>Read message using io.Reader</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextReader">Yes</a></td><td>No, see note 3</td></tr>
<tr><td>Write message using io.WriteCloser</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextWriter">Yes</a></td><td>No, see note 3</td></tr>
</table>
Notes:
1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html).
2. The application can get the type of a received data message by implementing
a [Codec marshal](http://godoc.org/golang.org/x/net/websocket#Codec.Marshal)
function.
3. The go.net io.Reader and io.Writer operate across WebSocket frame boundaries.
Read returns when the input buffer is full or a frame boundary is
encountered. Each call to Write sends a single frame message. The Gorilla
io.Reader and io.WriteCloser operate on a single WebSocket message.

375
vendor/github.com/gorilla/websocket/client.go generated vendored Normal file
View File

@ -0,0 +1,375 @@
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"bufio"
"bytes"
"crypto/tls"
"encoding/base64"
"errors"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
"strings"
"time"
)
// ErrBadHandshake is returned when the server response to opening handshake is
// invalid.
var ErrBadHandshake = errors.New("websocket: bad handshake")
// NewClient creates a new client connection using the given net connection.
// The URL u specifies the host and request URI. Use requestHeader to specify
// the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies
// (Cookie). Use the response.Header to get the selected subprotocol
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
//
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
// non-nil *http.Response so that callers can handle redirects, authentication,
// etc.
//
// Deprecated: Use Dialer instead.
func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int) (c *Conn, response *http.Response, err error) {
d := Dialer{
ReadBufferSize: readBufSize,
WriteBufferSize: writeBufSize,
NetDial: func(net, addr string) (net.Conn, error) {
return netConn, nil
},
}
return d.Dial(u.String(), requestHeader)
}
// A Dialer contains options for connecting to WebSocket server.
type Dialer struct {
// NetDial specifies the dial function for creating TCP connections. If
// NetDial is nil, net.Dial is used.
NetDial func(network, addr string) (net.Conn, error)
// Proxy specifies a function to return a proxy for a given
// Request. If the function returns a non-nil error, the
// request is aborted with the provided error.
// If Proxy is nil or returns a nil *URL, no proxy is used.
Proxy func(*http.Request) (*url.URL, error)
// TLSClientConfig specifies the TLS configuration to use with tls.Client.
// If nil, the default configuration is used.
TLSClientConfig *tls.Config
// HandshakeTimeout specifies the duration for the handshake to complete.
HandshakeTimeout time.Duration
// Input and output buffer sizes. If the buffer size is zero, then a
// default value of 4096 is used.
ReadBufferSize, WriteBufferSize int
// Subprotocols specifies the client's requested subprotocols.
Subprotocols []string
}
var errMalformedURL = errors.New("malformed ws or wss URL")
// parseURL parses the URL.
//
// This function is a replacement for the standard library url.Parse function.
// In Go 1.4 and earlier, url.Parse loses information from the path.
func parseURL(s string) (*url.URL, error) {
// From the RFC:
//
// ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ]
// wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ]
var u url.URL
switch {
case strings.HasPrefix(s, "ws://"):
u.Scheme = "ws"
s = s[len("ws://"):]
case strings.HasPrefix(s, "wss://"):
u.Scheme = "wss"
s = s[len("wss://"):]
default:
return nil, errMalformedURL
}
if i := strings.Index(s, "?"); i >= 0 {
u.RawQuery = s[i+1:]
s = s[:i]
}
if i := strings.Index(s, "/"); i >= 0 {
u.Opaque = s[i:]
s = s[:i]
} else {
u.Opaque = "/"
}
u.Host = s
if strings.Contains(u.Host, "@") {
// Don't bother parsing user information because user information is
// not allowed in websocket URIs.
return nil, errMalformedURL
}
return &u, nil
}
func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
hostPort = u.Host
hostNoPort = u.Host
if i := strings.LastIndex(u.Host, ":"); i > strings.LastIndex(u.Host, "]") {
hostNoPort = hostNoPort[:i]
} else {
switch u.Scheme {
case "wss":
hostPort += ":443"
case "https":
hostPort += ":443"
default:
hostPort += ":80"
}
}
return hostPort, hostNoPort
}
// DefaultDialer is a dialer with all fields set to the default zero values.
var DefaultDialer = &Dialer{
Proxy: http.ProxyFromEnvironment,
}
// Dial creates a new client connection. Use requestHeader to specify the
// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie).
// Use the response.Header to get the selected subprotocol
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
//
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
// non-nil *http.Response so that callers can handle redirects, authentication,
// etcetera. The response body may not contain the entire response and does not
// need to be closed by the application.
func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
if d == nil {
d = &Dialer{
Proxy: http.ProxyFromEnvironment,
}
}
challengeKey, err := generateChallengeKey()
if err != nil {
return nil, nil, err
}
u, err := parseURL(urlStr)
if err != nil {
return nil, nil, err
}
switch u.Scheme {
case "ws":
u.Scheme = "http"
case "wss":
u.Scheme = "https"
default:
return nil, nil, errMalformedURL
}
if u.User != nil {
// User name and password are not allowed in websocket URIs.
return nil, nil, errMalformedURL
}
req := &http.Request{
Method: "GET",
URL: u,
Proto: "HTTP/1.1",
ProtoMajor: 1,
ProtoMinor: 1,
Header: make(http.Header),
Host: u.Host,
}
// Set the request headers using the capitalization for names and values in
// RFC examples. Although the capitalization shouldn't matter, there are
// servers that depend on it. The Header.Set method is not used because the
// method canonicalizes the header names.
req.Header["Upgrade"] = []string{"websocket"}
req.Header["Connection"] = []string{"Upgrade"}
req.Header["Sec-WebSocket-Key"] = []string{challengeKey}
req.Header["Sec-WebSocket-Version"] = []string{"13"}
if len(d.Subprotocols) > 0 {
req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(d.Subprotocols, ", ")}
}
for k, vs := range requestHeader {
switch {
case k == "Host":
if len(vs) > 0 {
req.Host = vs[0]
}
case k == "Upgrade" ||
k == "Connection" ||
k == "Sec-Websocket-Key" ||
k == "Sec-Websocket-Version" ||
(k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0):
return nil, nil, errors.New("websocket: duplicate header not allowed: " + k)
default:
req.Header[k] = vs
}
}
hostPort, hostNoPort := hostPortNoPort(u)
var proxyURL *url.URL
// Check wether the proxy method has been configured
if d.Proxy != nil {
proxyURL, err = d.Proxy(req)
}
if err != nil {
return nil, nil, err
}
var targetHostPort string
if proxyURL != nil {
targetHostPort, _ = hostPortNoPort(proxyURL)
} else {
targetHostPort = hostPort
}
var deadline time.Time
if d.HandshakeTimeout != 0 {
deadline = time.Now().Add(d.HandshakeTimeout)
}
netDial := d.NetDial
if netDial == nil {
netDialer := &net.Dialer{Deadline: deadline}
netDial = netDialer.Dial
}
netConn, err := netDial("tcp", targetHostPort)
if err != nil {
return nil, nil, err
}
defer func() {
if netConn != nil {
netConn.Close()
}
}()
if err := netConn.SetDeadline(deadline); err != nil {
return nil, nil, err
}
if proxyURL != nil {
connectHeader := make(http.Header)
if user := proxyURL.User; user != nil {
proxyUser := user.Username()
if proxyPassword, passwordSet := user.Password(); passwordSet {
credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword))
connectHeader.Set("Proxy-Authorization", "Basic "+credential)
}
}
connectReq := &http.Request{
Method: "CONNECT",
URL: &url.URL{Opaque: hostPort},
Host: hostPort,
Header: connectHeader,
}
connectReq.Write(netConn)
// Read response.
// Okay to use and discard buffered reader here, because
// TLS server will not speak until spoken to.
br := bufio.NewReader(netConn)
resp, err := http.ReadResponse(br, connectReq)
if err != nil {
return nil, nil, err
}
if resp.StatusCode != 200 {
f := strings.SplitN(resp.Status, " ", 2)
return nil, nil, errors.New(f[1])
}
}
if u.Scheme == "https" {
cfg := cloneTLSConfig(d.TLSClientConfig)
if cfg.ServerName == "" {
cfg.ServerName = hostNoPort
}
tlsConn := tls.Client(netConn, cfg)
netConn = tlsConn
if err := tlsConn.Handshake(); err != nil {
return nil, nil, err
}
if !cfg.InsecureSkipVerify {
if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil {
return nil, nil, err
}
}
}
conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize)
if err := req.Write(netConn); err != nil {
return nil, nil, err
}
resp, err := http.ReadResponse(conn.br, req)
if err != nil {
return nil, nil, err
}
if resp.StatusCode != 101 ||
!strings.EqualFold(resp.Header.Get("Upgrade"), "websocket") ||
!strings.EqualFold(resp.Header.Get("Connection"), "upgrade") ||
resp.Header.Get("Sec-Websocket-Accept") != computeAcceptKey(challengeKey) {
// Before closing the network connection on return from this
// function, slurp up some of the response to aid application
// debugging.
buf := make([]byte, 1024)
n, _ := io.ReadFull(resp.Body, buf)
resp.Body = ioutil.NopCloser(bytes.NewReader(buf[:n]))
return nil, resp, ErrBadHandshake
}
resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{}))
conn.subprotocol = resp.Header.Get("Sec-Websocket-Protocol")
netConn.SetDeadline(time.Time{})
netConn = nil // to avoid close in defer.
return conn, resp, nil
}
// cloneTLSConfig clones all public fields except the fields
// SessionTicketsDisabled and SessionTicketKey. This avoids copying the
// sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a
// config in active use.
func cloneTLSConfig(cfg *tls.Config) *tls.Config {
if cfg == nil {
return &tls.Config{}
}
return &tls.Config{
Rand: cfg.Rand,
Time: cfg.Time,
Certificates: cfg.Certificates,
NameToCertificate: cfg.NameToCertificate,
GetCertificate: cfg.GetCertificate,
RootCAs: cfg.RootCAs,
NextProtos: cfg.NextProtos,
ServerName: cfg.ServerName,
ClientAuth: cfg.ClientAuth,
ClientCAs: cfg.ClientCAs,
InsecureSkipVerify: cfg.InsecureSkipVerify,
CipherSuites: cfg.CipherSuites,
PreferServerCipherSuites: cfg.PreferServerCipherSuites,
ClientSessionCache: cfg.ClientSessionCache,
MinVersion: cfg.MinVersion,
MaxVersion: cfg.MaxVersion,
CurvePreferences: cfg.CurvePreferences,
}
}

85
vendor/github.com/gorilla/websocket/compression.go generated vendored Normal file
View File

@ -0,0 +1,85 @@
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"compress/flate"
"errors"
"io"
"strings"
)
func decompressNoContextTakeover(r io.Reader) io.Reader {
const tail =
// Add four bytes as specified in RFC
"\x00\x00\xff\xff" +
// Add final block to squelch unexpected EOF error from flate reader.
"\x01\x00\x00\xff\xff"
return flate.NewReader(io.MultiReader(r, strings.NewReader(tail)))
}
func compressNoContextTakeover(w io.WriteCloser) (io.WriteCloser, error) {
tw := &truncWriter{w: w}
fw, err := flate.NewWriter(tw, 3)
return &flateWrapper{fw: fw, tw: tw}, err
}
// truncWriter is an io.Writer that writes all but the last four bytes of the
// stream to another io.Writer.
type truncWriter struct {
w io.WriteCloser
n int
p [4]byte
}
func (w *truncWriter) Write(p []byte) (int, error) {
n := 0
// fill buffer first for simplicity.
if w.n < len(w.p) {
n = copy(w.p[w.n:], p)
p = p[n:]
w.n += n
if len(p) == 0 {
return n, nil
}
}
m := len(p)
if m > len(w.p) {
m = len(w.p)
}
if nn, err := w.w.Write(w.p[:m]); err != nil {
return n + nn, err
}
copy(w.p[:], w.p[m:])
copy(w.p[len(w.p)-m:], p[len(p)-m:])
nn, err := w.w.Write(p[:len(p)-m])
return n + nn, err
}
type flateWrapper struct {
fw *flate.Writer
tw *truncWriter
}
func (w *flateWrapper) Write(p []byte) (int, error) {
return w.fw.Write(p)
}
func (w *flateWrapper) Close() error {
err1 := w.fw.Flush()
if w.tw.p != [4]byte{0, 0, 0xff, 0xff} {
return errors.New("websocket: internal error, unexpected bytes at end of flate stream")
}
err2 := w.tw.w.Close()
if err1 != nil {
return err1
}
return err2
}

994
vendor/github.com/gorilla/websocket/conn.go generated vendored Normal file
View File

@ -0,0 +1,994 @@
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"bufio"
"encoding/binary"
"errors"
"io"
"io/ioutil"
"math/rand"
"net"
"strconv"
"time"
"unicode/utf8"
)
const (
// Frame header byte 0 bits from Section 5.2 of RFC 6455
finalBit = 1 << 7
rsv1Bit = 1 << 6
rsv2Bit = 1 << 5
rsv3Bit = 1 << 4
// Frame header byte 1 bits from Section 5.2 of RFC 6455
maskBit = 1 << 7
maxFrameHeaderSize = 2 + 8 + 4 // Fixed header + length + mask
maxControlFramePayloadSize = 125
writeWait = time.Second
defaultReadBufferSize = 4096
defaultWriteBufferSize = 4096
continuationFrame = 0
noFrame = -1
)
// Close codes defined in RFC 6455, section 11.7.
const (
CloseNormalClosure = 1000
CloseGoingAway = 1001
CloseProtocolError = 1002
CloseUnsupportedData = 1003
CloseNoStatusReceived = 1005
CloseAbnormalClosure = 1006
CloseInvalidFramePayloadData = 1007
ClosePolicyViolation = 1008
CloseMessageTooBig = 1009
CloseMandatoryExtension = 1010
CloseInternalServerErr = 1011
CloseServiceRestart = 1012
CloseTryAgainLater = 1013
CloseTLSHandshake = 1015
)
// The message types are defined in RFC 6455, section 11.8.
const (
// TextMessage denotes a text data message. The text message payload is
// interpreted as UTF-8 encoded text data.
TextMessage = 1
// BinaryMessage denotes a binary data message.
BinaryMessage = 2
// CloseMessage denotes a close control message. The optional message
// payload contains a numeric code and text. Use the FormatCloseMessage
// function to format a close message payload.
CloseMessage = 8
// PingMessage denotes a ping control message. The optional message payload
// is UTF-8 encoded text.
PingMessage = 9
// PongMessage denotes a ping control message. The optional message payload
// is UTF-8 encoded text.
PongMessage = 10
)
// ErrCloseSent is returned when the application writes a message to the
// connection after sending a close message.
var ErrCloseSent = errors.New("websocket: close sent")
// ErrReadLimit is returned when reading a message that is larger than the
// read limit set for the connection.
var ErrReadLimit = errors.New("websocket: read limit exceeded")
// netError satisfies the net Error interface.
type netError struct {
msg string
temporary bool
timeout bool
}
func (e *netError) Error() string { return e.msg }
func (e *netError) Temporary() bool { return e.temporary }
func (e *netError) Timeout() bool { return e.timeout }
// CloseError represents close frame.
type CloseError struct {
// Code is defined in RFC 6455, section 11.7.
Code int
// Text is the optional text payload.
Text string
}
func (e *CloseError) Error() string {
s := []byte("websocket: close ")
s = strconv.AppendInt(s, int64(e.Code), 10)
switch e.Code {
case CloseNormalClosure:
s = append(s, " (normal)"...)
case CloseGoingAway:
s = append(s, " (going away)"...)
case CloseProtocolError:
s = append(s, " (protocol error)"...)
case CloseUnsupportedData:
s = append(s, " (unsupported data)"...)
case CloseNoStatusReceived:
s = append(s, " (no status)"...)
case CloseAbnormalClosure:
s = append(s, " (abnormal closure)"...)
case CloseInvalidFramePayloadData:
s = append(s, " (invalid payload data)"...)
case ClosePolicyViolation:
s = append(s, " (policy violation)"...)
case CloseMessageTooBig:
s = append(s, " (message too big)"...)
case CloseMandatoryExtension:
s = append(s, " (mandatory extension missing)"...)
case CloseInternalServerErr:
s = append(s, " (internal server error)"...)
case CloseTLSHandshake:
s = append(s, " (TLS handshake error)"...)
}
if e.Text != "" {
s = append(s, ": "...)
s = append(s, e.Text...)
}
return string(s)
}
// IsCloseError returns boolean indicating whether the error is a *CloseError
// with one of the specified codes.
func IsCloseError(err error, codes ...int) bool {
if e, ok := err.(*CloseError); ok {
for _, code := range codes {
if e.Code == code {
return true
}
}
}
return false
}
// IsUnexpectedCloseError returns boolean indicating whether the error is a
// *CloseError with a code not in the list of expected codes.
func IsUnexpectedCloseError(err error, expectedCodes ...int) bool {
if e, ok := err.(*CloseError); ok {
for _, code := range expectedCodes {
if e.Code == code {
return false
}
}
return true
}
return false
}
var (
errWriteTimeout = &netError{msg: "websocket: write timeout", timeout: true, temporary: true}
errUnexpectedEOF = &CloseError{Code: CloseAbnormalClosure, Text: io.ErrUnexpectedEOF.Error()}
errBadWriteOpCode = errors.New("websocket: bad write message type")
errWriteClosed = errors.New("websocket: write closed")
errInvalidControlFrame = errors.New("websocket: invalid control frame")
)
func hideTempErr(err error) error {
if e, ok := err.(net.Error); ok && e.Temporary() {
err = &netError{msg: e.Error(), timeout: e.Timeout()}
}
return err
}
func isControl(frameType int) bool {
return frameType == CloseMessage || frameType == PingMessage || frameType == PongMessage
}
func isData(frameType int) bool {
return frameType == TextMessage || frameType == BinaryMessage
}
var validReceivedCloseCodes = map[int]bool{
// see http://www.iana.org/assignments/websocket/websocket.xhtml#close-code-number
CloseNormalClosure: true,
CloseGoingAway: true,
CloseProtocolError: true,
CloseUnsupportedData: true,
CloseNoStatusReceived: false,
CloseAbnormalClosure: false,
CloseInvalidFramePayloadData: true,
ClosePolicyViolation: true,
CloseMessageTooBig: true,
CloseMandatoryExtension: true,
CloseInternalServerErr: true,
CloseServiceRestart: true,
CloseTryAgainLater: true,
CloseTLSHandshake: false,
}
func isValidReceivedCloseCode(code int) bool {
return validReceivedCloseCodes[code] || (code >= 3000 && code <= 4999)
}
func maskBytes(key [4]byte, pos int, b []byte) int {
for i := range b {
b[i] ^= key[pos&3]
pos++
}
return pos & 3
}
func newMaskKey() [4]byte {
n := rand.Uint32()
return [4]byte{byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24)}
}
// Conn represents a WebSocket connection.
type Conn struct {
conn net.Conn
isServer bool
subprotocol string
// Write fields
mu chan bool // used as mutex to protect write to conn and closeSent
closeSent bool // whether close message was sent
writeErr error
writeBuf []byte // frame is constructed in this buffer.
writePos int // end of data in writeBuf.
writeFrameType int // type of the current frame.
writeDeadline time.Time
messageWriter *messageWriter // the current low-level message writer
writer io.WriteCloser // the current writer returned to the application
isWriting bool // for best-effort concurrent write detection
enableWriteCompression bool
writeCompress bool // whether next call to flushFrame should set RSV1
newCompressionWriter func(io.WriteCloser) (io.WriteCloser, error)
// Read fields
readErr error
br *bufio.Reader
readRemaining int64 // bytes remaining in current frame.
readFinal bool // true the current message has more frames.
readLength int64 // Message size.
readLimit int64 // Maximum message size.
readMaskPos int
readMaskKey [4]byte
handlePong func(string) error
handlePing func(string) error
readErrCount int
messageReader *messageReader // the current low-level reader
readDecompress bool // whether last read frame had RSV1 set
newDecompressionReader func(io.Reader) io.Reader
}
func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int) *Conn {
mu := make(chan bool, 1)
mu <- true
if readBufferSize == 0 {
readBufferSize = defaultReadBufferSize
}
if readBufferSize < maxControlFramePayloadSize {
readBufferSize = maxControlFramePayloadSize
}
if writeBufferSize == 0 {
writeBufferSize = defaultWriteBufferSize
}
c := &Conn{
isServer: isServer,
br: bufio.NewReaderSize(conn, readBufferSize),
conn: conn,
mu: mu,
readFinal: true,
writeBuf: make([]byte, writeBufferSize+maxFrameHeaderSize),
writeFrameType: noFrame,
writePos: maxFrameHeaderSize,
enableWriteCompression: true,
}
c.SetPingHandler(nil)
c.SetPongHandler(nil)
return c
}
// Subprotocol returns the negotiated protocol for the connection.
func (c *Conn) Subprotocol() string {
return c.subprotocol
}
// Close closes the underlying network connection without sending or waiting for a close frame.
func (c *Conn) Close() error {
return c.conn.Close()
}
// LocalAddr returns the local network address.
func (c *Conn) LocalAddr() net.Addr {
return c.conn.LocalAddr()
}
// RemoteAddr returns the remote network address.
func (c *Conn) RemoteAddr() net.Addr {
return c.conn.RemoteAddr()
}
// Write methods
func (c *Conn) write(frameType int, deadline time.Time, bufs ...[]byte) error {
<-c.mu
defer func() { c.mu <- true }()
if c.closeSent {
return ErrCloseSent
} else if frameType == CloseMessage {
c.closeSent = true
}
c.conn.SetWriteDeadline(deadline)
for _, buf := range bufs {
if len(buf) > 0 {
n, err := c.conn.Write(buf)
if n != len(buf) {
// Close on partial write.
c.conn.Close()
}
if err != nil {
return err
}
}
}
return nil
}
// WriteControl writes a control message with the given deadline. The allowed
// message types are CloseMessage, PingMessage and PongMessage.
func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) error {
if !isControl(messageType) {
return errBadWriteOpCode
}
if len(data) > maxControlFramePayloadSize {
return errInvalidControlFrame
}
b0 := byte(messageType) | finalBit
b1 := byte(len(data))
if !c.isServer {
b1 |= maskBit
}
buf := make([]byte, 0, maxFrameHeaderSize+maxControlFramePayloadSize)
buf = append(buf, b0, b1)
if c.isServer {
buf = append(buf, data...)
} else {
key := newMaskKey()
buf = append(buf, key[:]...)
buf = append(buf, data...)
maskBytes(key, 0, buf[6:])
}
d := time.Hour * 1000
if !deadline.IsZero() {
d = deadline.Sub(time.Now())
if d < 0 {
return errWriteTimeout
}
}
timer := time.NewTimer(d)
select {
case <-c.mu:
timer.Stop()
case <-timer.C:
return errWriteTimeout
}
defer func() { c.mu <- true }()
if c.closeSent {
return ErrCloseSent
} else if messageType == CloseMessage {
c.closeSent = true
}
c.conn.SetWriteDeadline(deadline)
n, err := c.conn.Write(buf)
if n != 0 && n != len(buf) {
c.conn.Close()
}
return hideTempErr(err)
}
// NextWriter returns a writer for the next message to send. The writer's Close
// method flushes the complete message to the network.
//
// There can be at most one open writer on a connection. NextWriter closes the
// previous writer if the application has not already done so.
func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error) {
if c.writeErr != nil {
return nil, c.writeErr
}
// Close previous writer if not already closed by the application. It's
// probably better to return an error in this situation, but we cannot
// change this without breaking existing applications.
if c.writer != nil {
err := c.writer.Close()
if err != nil {
return nil, err
}
}
if !isControl(messageType) && !isData(messageType) {
return nil, errBadWriteOpCode
}
c.writeFrameType = messageType
c.messageWriter = &messageWriter{c}
var w io.WriteCloser = c.messageWriter
if c.newCompressionWriter != nil && c.enableWriteCompression && isData(messageType) {
c.writeCompress = true
var err error
w, err = c.newCompressionWriter(w)
if err != nil {
c.writer.Close()
return nil, err
}
}
return w, nil
}
// flushFrame writes buffered data and extra as a frame to the network. The
// final argument indicates that this is the last frame in the message.
func (c *Conn) flushFrame(final bool, extra []byte) error {
length := c.writePos - maxFrameHeaderSize + len(extra)
// Check for invalid control frames.
if isControl(c.writeFrameType) &&
(!final || length > maxControlFramePayloadSize) {
c.messageWriter = nil
c.writer = nil
c.writeFrameType = noFrame
c.writePos = maxFrameHeaderSize
return errInvalidControlFrame
}
b0 := byte(c.writeFrameType)
if final {
b0 |= finalBit
}
if c.writeCompress {
b0 |= rsv1Bit
}
c.writeCompress = false
b1 := byte(0)
if !c.isServer {
b1 |= maskBit
}
// Assume that the frame starts at beginning of c.writeBuf.
framePos := 0
if c.isServer {
// Adjust up if mask not included in the header.
framePos = 4
}
switch {
case length >= 65536:
c.writeBuf[framePos] = b0
c.writeBuf[framePos+1] = b1 | 127
binary.BigEndian.PutUint64(c.writeBuf[framePos+2:], uint64(length))
case length > 125:
framePos += 6
c.writeBuf[framePos] = b0
c.writeBuf[framePos+1] = b1 | 126
binary.BigEndian.PutUint16(c.writeBuf[framePos+2:], uint16(length))
default:
framePos += 8
c.writeBuf[framePos] = b0
c.writeBuf[framePos+1] = b1 | byte(length)
}
if !c.isServer {
key := newMaskKey()
copy(c.writeBuf[maxFrameHeaderSize-4:], key[:])
maskBytes(key, 0, c.writeBuf[maxFrameHeaderSize:c.writePos])
if len(extra) > 0 {
c.writeErr = errors.New("websocket: internal error, extra used in client mode")
return c.writeErr
}
}
// Write the buffers to the connection with best-effort detection of
// concurrent writes. See the concurrency section in the package
// documentation for more info.
if c.isWriting {
panic("concurrent write to websocket connection")
}
c.isWriting = true
c.writeErr = c.write(c.writeFrameType, c.writeDeadline, c.writeBuf[framePos:c.writePos], extra)
if !c.isWriting {
panic("concurrent write to websocket connection")
}
c.isWriting = false
// Setup for next frame.
c.writePos = maxFrameHeaderSize
c.writeFrameType = continuationFrame
if final {
c.messageWriter = nil
c.writer = nil
c.writeFrameType = noFrame
}
return c.writeErr
}
type messageWriter struct{ c *Conn }
func (w *messageWriter) err() error {
c := w.c
if c.messageWriter != w {
return errWriteClosed
}
if c.writeErr != nil {
return c.writeErr
}
return nil
}
func (w *messageWriter) ncopy(max int) (int, error) {
n := len(w.c.writeBuf) - w.c.writePos
if n <= 0 {
if err := w.c.flushFrame(false, nil); err != nil {
return 0, err
}
n = len(w.c.writeBuf) - w.c.writePos
}
if n > max {
n = max
}
return n, nil
}
func (w *messageWriter) Write(p []byte) (int, error) {
if err := w.err(); err != nil {
return 0, err
}
if len(p) > 2*len(w.c.writeBuf) && w.c.isServer {
// Don't buffer large messages.
err := w.c.flushFrame(false, p)
if err != nil {
return 0, err
}
return len(p), nil
}
nn := len(p)
for len(p) > 0 {
n, err := w.ncopy(len(p))
if err != nil {
return 0, err
}
copy(w.c.writeBuf[w.c.writePos:], p[:n])
w.c.writePos += n
p = p[n:]
}
return nn, nil
}
func (w *messageWriter) WriteString(p string) (int, error) {
if err := w.err(); err != nil {
return 0, err
}
nn := len(p)
for len(p) > 0 {
n, err := w.ncopy(len(p))
if err != nil {
return 0, err
}
copy(w.c.writeBuf[w.c.writePos:], p[:n])
w.c.writePos += n
p = p[n:]
}
return nn, nil
}
func (w *messageWriter) ReadFrom(r io.Reader) (nn int64, err error) {
if err := w.err(); err != nil {
return 0, err
}
for {
if w.c.writePos == len(w.c.writeBuf) {
err = w.c.flushFrame(false, nil)
if err != nil {
break
}
}
var n int
n, err = r.Read(w.c.writeBuf[w.c.writePos:])
w.c.writePos += n
nn += int64(n)
if err != nil {
if err == io.EOF {
err = nil
}
break
}
}
return nn, err
}
func (w *messageWriter) Close() error {
if err := w.err(); err != nil {
return err
}
return w.c.flushFrame(true, nil)
}
// WriteMessage is a helper method for getting a writer using NextWriter,
// writing the message and closing the writer.
func (c *Conn) WriteMessage(messageType int, data []byte) error {
w, err := c.NextWriter(messageType)
if err != nil {
return err
}
if _, ok := w.(*messageWriter); ok && c.isServer {
// Optimize write as a single frame.
n := copy(c.writeBuf[c.writePos:], data)
c.writePos += n
data = data[n:]
err = c.flushFrame(true, data)
return err
}
if _, err = w.Write(data); err != nil {
return err
}
return w.Close()
}
// SetWriteDeadline sets the write deadline on the underlying network
// connection. After a write has timed out, the websocket state is corrupt and
// all future writes will return an error. A zero value for t means writes will
// not time out.
func (c *Conn) SetWriteDeadline(t time.Time) error {
c.writeDeadline = t
return nil
}
// Read methods
func (c *Conn) advanceFrame() (int, error) {
// 1. Skip remainder of previous frame.
if c.readRemaining > 0 {
if _, err := io.CopyN(ioutil.Discard, c.br, c.readRemaining); err != nil {
return noFrame, err
}
}
// 2. Read and parse first two bytes of frame header.
p, err := c.read(2)
if err != nil {
return noFrame, err
}
final := p[0]&finalBit != 0
frameType := int(p[0] & 0xf)
mask := p[1]&maskBit != 0
c.readRemaining = int64(p[1] & 0x7f)
c.readDecompress = false
if c.newDecompressionReader != nil && (p[0]&rsv1Bit) != 0 {
c.readDecompress = true
p[0] &^= rsv1Bit
}
if rsv := p[0] & (rsv1Bit | rsv2Bit | rsv3Bit); rsv != 0 {
return noFrame, c.handleProtocolError("unexpected reserved bits 0x" + strconv.FormatInt(int64(rsv), 16))
}
switch frameType {
case CloseMessage, PingMessage, PongMessage:
if c.readRemaining > maxControlFramePayloadSize {
return noFrame, c.handleProtocolError("control frame length > 125")
}
if !final {
return noFrame, c.handleProtocolError("control frame not final")
}
case TextMessage, BinaryMessage:
if !c.readFinal {
return noFrame, c.handleProtocolError("message start before final message frame")
}
c.readFinal = final
case continuationFrame:
if c.readFinal {
return noFrame, c.handleProtocolError("continuation after final message frame")
}
c.readFinal = final
default:
return noFrame, c.handleProtocolError("unknown opcode " + strconv.Itoa(frameType))
}
// 3. Read and parse frame length.
switch c.readRemaining {
case 126:
p, err := c.read(2)
if err != nil {
return noFrame, err
}
c.readRemaining = int64(binary.BigEndian.Uint16(p))
case 127:
p, err := c.read(8)
if err != nil {
return noFrame, err
}
c.readRemaining = int64(binary.BigEndian.Uint64(p))
}
// 4. Handle frame masking.
if mask != c.isServer {
return noFrame, c.handleProtocolError("incorrect mask flag")
}
if mask {
c.readMaskPos = 0
p, err := c.read(len(c.readMaskKey))
if err != nil {
return noFrame, err
}
copy(c.readMaskKey[:], p)
}
// 5. For text and binary messages, enforce read limit and return.
if frameType == continuationFrame || frameType == TextMessage || frameType == BinaryMessage {
c.readLength += c.readRemaining
if c.readLimit > 0 && c.readLength > c.readLimit {
c.WriteControl(CloseMessage, FormatCloseMessage(CloseMessageTooBig, ""), time.Now().Add(writeWait))
return noFrame, ErrReadLimit
}
return frameType, nil
}
// 6. Read control frame payload.
var payload []byte
if c.readRemaining > 0 {
payload, err = c.read(int(c.readRemaining))
c.readRemaining = 0
if err != nil {
return noFrame, err
}
if c.isServer {
maskBytes(c.readMaskKey, 0, payload)
}
}
// 7. Process control frame payload.
switch frameType {
case PongMessage:
if err := c.handlePong(string(payload)); err != nil {
return noFrame, err
}
case PingMessage:
if err := c.handlePing(string(payload)); err != nil {
return noFrame, err
}
case CloseMessage:
echoMessage := []byte{}
closeCode := CloseNoStatusReceived
closeText := ""
if len(payload) >= 2 {
echoMessage = payload[:2]
closeCode = int(binary.BigEndian.Uint16(payload))
if !isValidReceivedCloseCode(closeCode) {
return noFrame, c.handleProtocolError("invalid close code")
}
closeText = string(payload[2:])
if !utf8.ValidString(closeText) {
return noFrame, c.handleProtocolError("invalid utf8 payload in close frame")
}
}
c.WriteControl(CloseMessage, echoMessage, time.Now().Add(writeWait))
return noFrame, &CloseError{Code: closeCode, Text: closeText}
}
return frameType, nil
}
func (c *Conn) handleProtocolError(message string) error {
c.WriteControl(CloseMessage, FormatCloseMessage(CloseProtocolError, message), time.Now().Add(writeWait))
return errors.New("websocket: " + message)
}
// NextReader returns the next data message received from the peer. The
// returned messageType is either TextMessage or BinaryMessage.
//
// There can be at most one open reader on a connection. NextReader discards
// the previous message if the application has not already consumed it.
//
// Applications must break out of the application's read loop when this method
// returns a non-nil error value. Errors returned from this method are
// permanent. Once this method returns a non-nil error, all subsequent calls to
// this method return the same error.
func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
c.messageReader = nil
c.readLength = 0
for c.readErr == nil {
frameType, err := c.advanceFrame()
if err != nil {
c.readErr = hideTempErr(err)
break
}
if frameType == TextMessage || frameType == BinaryMessage {
c.messageReader = &messageReader{c}
var r io.Reader = c.messageReader
if c.readDecompress {
r = c.newDecompressionReader(r)
}
return frameType, r, nil
}
}
// Applications that do handle the error returned from this method spin in
// tight loop on connection failure. To help application developers detect
// this error, panic on repeated reads to the failed connection.
c.readErrCount++
if c.readErrCount >= 1000 {
panic("repeated read on failed websocket connection")
}
return noFrame, nil, c.readErr
}
type messageReader struct{ c *Conn }
func (r *messageReader) Read(b []byte) (int, error) {
c := r.c
if c.messageReader != r {
return 0, io.EOF
}
for c.readErr == nil {
if c.readRemaining > 0 {
if int64(len(b)) > c.readRemaining {
b = b[:c.readRemaining]
}
n, err := c.br.Read(b)
c.readErr = hideTempErr(err)
if c.isServer {
c.readMaskPos = maskBytes(c.readMaskKey, c.readMaskPos, b[:n])
}
c.readRemaining -= int64(n)
if c.readRemaining > 0 && c.readErr == io.EOF {
c.readErr = errUnexpectedEOF
}
return n, c.readErr
}
if c.readFinal {
c.messageReader = nil
return 0, io.EOF
}
frameType, err := c.advanceFrame()
switch {
case err != nil:
c.readErr = hideTempErr(err)
case frameType == TextMessage || frameType == BinaryMessage:
c.readErr = errors.New("websocket: internal error, unexpected text or binary in Reader")
}
}
err := c.readErr
if err == io.EOF && c.messageReader == r {
err = errUnexpectedEOF
}
return 0, err
}
// ReadMessage is a helper method for getting a reader using NextReader and
// reading from that reader to a buffer.
func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
var r io.Reader
messageType, r, err = c.NextReader()
if err != nil {
return messageType, nil, err
}
p, err = ioutil.ReadAll(r)
return messageType, p, err
}
// SetReadDeadline sets the read deadline on the underlying network connection.
// After a read has timed out, the websocket connection state is corrupt and
// all future reads will return an error. A zero value for t means reads will
// not time out.
func (c *Conn) SetReadDeadline(t time.Time) error {
return c.conn.SetReadDeadline(t)
}
// SetReadLimit sets the maximum size for a message read from the peer. If a
// message exceeds the limit, the connection sends a close frame to the peer
// and returns ErrReadLimit to the application.
func (c *Conn) SetReadLimit(limit int64) {
c.readLimit = limit
}
// PingHandler returns the current ping handler
func (c *Conn) PingHandler() func(appData string) error {
return c.handlePing
}
// SetPingHandler sets the handler for ping messages received from the peer.
// The appData argument to h is the PING frame application data. The default
// ping handler sends a pong to the peer.
func (c *Conn) SetPingHandler(h func(appData string) error) {
if h == nil {
h = func(message string) error {
err := c.WriteControl(PongMessage, []byte(message), time.Now().Add(writeWait))
if err == ErrCloseSent {
return nil
} else if e, ok := err.(net.Error); ok && e.Temporary() {
return nil
}
return err
}
}
c.handlePing = h
}
// PongHandler returns the current pong handler
func (c *Conn) PongHandler() func(appData string) error {
return c.handlePong
}
// SetPongHandler sets the handler for pong messages received from the peer.
// The appData argument to h is the PONG frame application data. The default
// pong handler does nothing.
func (c *Conn) SetPongHandler(h func(appData string) error) {
if h == nil {
h = func(string) error { return nil }
}
c.handlePong = h
}
// UnderlyingConn returns the internal net.Conn. This can be used to further
// modifications to connection specific flags.
func (c *Conn) UnderlyingConn() net.Conn {
return c.conn
}
// FormatCloseMessage formats closeCode and text as a WebSocket close message.
func FormatCloseMessage(closeCode int, text string) []byte {
buf := make([]byte, 2+len(text))
binary.BigEndian.PutUint16(buf, uint16(closeCode))
copy(buf[2:], text)
return buf
}

18
vendor/github.com/gorilla/websocket/conn_read.go generated vendored Normal file
View File

@ -0,0 +1,18 @@
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build go1.5
package websocket
import "io"
func (c *Conn) read(n int) ([]byte, error) {
p, err := c.br.Peek(n)
if err == io.EOF {
err = errUnexpectedEOF
}
c.br.Discard(len(p))
return p, err
}

View File

@ -0,0 +1,21 @@
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !go1.5
package websocket
import "io"
func (c *Conn) read(n int) ([]byte, error) {
p, err := c.br.Peek(n)
if err == io.EOF {
err = errUnexpectedEOF
}
if len(p) > 0 {
// advance over the bytes just read
io.ReadFull(c.br, p)
}
return p, err
}

152
vendor/github.com/gorilla/websocket/doc.go generated vendored Normal file
View File

@ -0,0 +1,152 @@
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package websocket implements the WebSocket protocol defined in RFC 6455.
//
// Overview
//
// The Conn type represents a WebSocket connection. A server application uses
// the Upgrade function from an Upgrader object with a HTTP request handler
// to get a pointer to a Conn:
//
// var upgrader = websocket.Upgrader{
// ReadBufferSize: 1024,
// WriteBufferSize: 1024,
// }
//
// func handler(w http.ResponseWriter, r *http.Request) {
// conn, err := upgrader.Upgrade(w, r, nil)
// if err != nil {
// log.Println(err)
// return
// }
// ... Use conn to send and receive messages.
// }
//
// 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:
//
// for {
// messageType, p, err := conn.ReadMessage()
// if err != nil {
// return
// }
// if err = conn.WriteMessage(messageType, p); err != nil {
// return err
// }
// }
//
// In above snippet of code, p is a []byte and messageType is an int with value
// websocket.BinaryMessage or websocket.TextMessage.
//
// An application can also send and receive messages using the io.WriteCloser
// and io.Reader interfaces. To send a message, call the connection NextWriter
// method to get an io.WriteCloser, write the message to the writer and close
// the writer when done. To receive a message, call the connection NextReader
// method to get an io.Reader and read until io.EOF is returned. This snippet
// shows how to echo messages using the NextWriter and NextReader methods:
//
// for {
// messageType, r, err := conn.NextReader()
// if err != nil {
// return
// }
// w, err := conn.NextWriter(messageType)
// if err != nil {
// return err
// }
// if _, err := io.Copy(w, r); err != nil {
// return err
// }
// if err := w.Close(); err != nil {
// return err
// }
// }
//
// Data Messages
//
// The WebSocket protocol distinguishes between text and binary data messages.
// Text messages are interpreted as UTF-8 encoded text. The interpretation of
// binary messages is left to the application.
//
// This package uses the TextMessage and BinaryMessage integer constants to
// identify the two data message types. The ReadMessage and NextReader methods
// return the type of the received message. The messageType argument to the
// WriteMessage and NextWriter methods specifies the type of a sent message.
//
// It is the application's responsibility to ensure that text messages are
// valid UTF-8 encoded text.
//
// Control Messages
//
// The WebSocket protocol defines three types of control messages: close, ping
// and pong. Call the connection WriteControl, WriteMessage or NextWriter
// methods to send a control message to the peer.
//
// Connections handle received close messages by sending a close message to the
// peer and returning a *CloseError from the the NextReader, ReadMessage or the
// message Read method.
//
// Connections handle received ping and pong messages by invoking callback
// functions set with SetPingHandler and SetPongHandler methods. The callback
// functions are called from the NextReader, ReadMessage and the message Read
// methods.
//
// The default ping handler sends a pong to the peer. The application's reading
// goroutine can block for a short time while the handler writes the pong data
// to the connection.
//
// The application must read the connection to process ping, pong and close
// messages sent from the peer. If the application is not otherwise interested
// in messages from the peer, then the application should start a goroutine to
// read and discard messages from the peer. A simple example is:
//
// func readLoop(c *websocket.Conn) {
// for {
// if _, _, err := c.NextReader(); err != nil {
// c.Close()
// break
// }
// }
// }
//
// Concurrency
//
// Connections support one concurrent reader and one concurrent writer.
//
// Applications are responsible for ensuring that no more than one goroutine
// calls the write methods (NextWriter, SetWriteDeadline, WriteMessage,
// WriteJSON) concurrently and that no more than one goroutine calls the read
// methods (NextReader, SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler,
// SetPingHandler) concurrently.
//
// The Close and WriteControl methods can be called concurrently with all other
// methods.
//
// Origin Considerations
//
// Web browsers allow Javascript applications to open a WebSocket connection to
// any host. It's up to the server to enforce an origin policy using the Origin
// request header sent by the browser.
//
// The Upgrader calls the function specified in the CheckOrigin field to check
// the origin. If the CheckOrigin function returns false, then the Upgrade
// method fails the WebSocket handshake with HTTP status 403.
//
// If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail
// the handshake if the Origin request header is present and not equal to the
// Host request header.
//
// An application can allow connections from any origin by specifying a
// function that always returns true:
//
// var upgrader = websocket.Upgrader{
// CheckOrigin: func(r *http.Request) bool { return true },
// }
//
// The deprecated Upgrade function does not enforce an origin policy. It's the
// application's responsibility to check the Origin header before calling
// Upgrade.
package websocket

55
vendor/github.com/gorilla/websocket/json.go generated vendored Normal file
View File

@ -0,0 +1,55 @@
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"encoding/json"
"io"
)
// WriteJSON is deprecated, use c.WriteJSON instead.
func WriteJSON(c *Conn, v interface{}) error {
return c.WriteJSON(v)
}
// WriteJSON writes the JSON encoding of v to the connection.
//
// See the documentation for encoding/json Marshal for details about the
// conversion of Go values to JSON.
func (c *Conn) WriteJSON(v interface{}) error {
w, err := c.NextWriter(TextMessage)
if err != nil {
return err
}
err1 := json.NewEncoder(w).Encode(v)
err2 := w.Close()
if err1 != nil {
return err1
}
return err2
}
// ReadJSON is deprecated, use c.ReadJSON instead.
func ReadJSON(c *Conn, v interface{}) error {
return c.ReadJSON(v)
}
// ReadJSON reads the next JSON-encoded message from the connection and stores
// it in the value pointed to by v.
//
// See the documentation for the encoding/json Unmarshal function for details
// about the conversion of JSON to a Go value.
func (c *Conn) ReadJSON(v interface{}) error {
_, r, err := c.NextReader()
if err != nil {
return err
}
err = json.NewDecoder(r).Decode(v)
if err == io.EOF {
// One value is expected in the message.
err = io.ErrUnexpectedEOF
}
return err
}

261
vendor/github.com/gorilla/websocket/server.go generated vendored Normal file
View File

@ -0,0 +1,261 @@
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"bufio"
"errors"
"net"
"net/http"
"net/url"
"strings"
"time"
)
// HandshakeError describes an error with the handshake from the peer.
type HandshakeError struct {
message string
}
func (e HandshakeError) Error() string { return e.message }
// Upgrader specifies parameters for upgrading an HTTP connection to a
// WebSocket connection.
type Upgrader struct {
// HandshakeTimeout specifies the duration for the handshake to complete.
HandshakeTimeout time.Duration
// ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
// size is zero, then a default value of 4096 is used. The I/O buffer sizes
// do not limit the size of the messages that can be sent or received.
ReadBufferSize, WriteBufferSize int
// Subprotocols specifies the server's supported protocols in order of
// preference. If this field is set, then the Upgrade method negotiates a
// subprotocol by selecting the first match in this list with a protocol
// requested by the client.
Subprotocols []string
// Error specifies the function for generating HTTP error responses. If Error
// is nil, then http.Error is used to generate the HTTP response.
Error func(w http.ResponseWriter, r *http.Request, status int, reason error)
// CheckOrigin returns true if the request Origin header is acceptable. If
// CheckOrigin is nil, the host in the Origin header must not be set or
// must match the host of the request.
CheckOrigin func(r *http.Request) bool
}
func (u *Upgrader) returnError(w http.ResponseWriter, r *http.Request, status int, reason string) (*Conn, error) {
err := HandshakeError{reason}
if u.Error != nil {
u.Error(w, r, status, err)
} else {
w.Header().Set("Sec-Websocket-Version", "13")
http.Error(w, http.StatusText(status), status)
}
return nil, err
}
// checkSameOrigin returns true if the origin is not set or is equal to the request host.
func checkSameOrigin(r *http.Request) bool {
origin := r.Header["Origin"]
if len(origin) == 0 {
return true
}
u, err := url.Parse(origin[0])
if err != nil {
return false
}
return u.Host == r.Host
}
func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string {
if u.Subprotocols != nil {
clientProtocols := Subprotocols(r)
for _, serverProtocol := range u.Subprotocols {
for _, clientProtocol := range clientProtocols {
if clientProtocol == serverProtocol {
return clientProtocol
}
}
}
} else if responseHeader != nil {
return responseHeader.Get("Sec-Websocket-Protocol")
}
return ""
}
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
//
// The responseHeader is included in the response to the client's upgrade
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
// application negotiated subprotocol (Sec-Websocket-Protocol).
//
// If the upgrade fails, then Upgrade replies to the client with an HTTP error
// response.
func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error) {
if r.Method != "GET" {
return u.returnError(w, r, http.StatusMethodNotAllowed, "websocket: method not GET")
}
if !tokenListContainsValue(r.Header, "Sec-Websocket-Version", "13") {
return u.returnError(w, r, http.StatusBadRequest, "websocket: version != 13")
}
if !tokenListContainsValue(r.Header, "Connection", "upgrade") {
return u.returnError(w, r, http.StatusBadRequest, "websocket: could not find connection header with token 'upgrade'")
}
if !tokenListContainsValue(r.Header, "Upgrade", "websocket") {
return u.returnError(w, r, http.StatusBadRequest, "websocket: could not find upgrade header with token 'websocket'")
}
checkOrigin := u.CheckOrigin
if checkOrigin == nil {
checkOrigin = checkSameOrigin
}
if !checkOrigin(r) {
return u.returnError(w, r, http.StatusForbidden, "websocket: origin not allowed")
}
challengeKey := r.Header.Get("Sec-Websocket-Key")
if challengeKey == "" {
return u.returnError(w, r, http.StatusBadRequest, "websocket: key missing or blank")
}
subprotocol := u.selectSubprotocol(r, responseHeader)
var (
netConn net.Conn
br *bufio.Reader
err error
)
h, ok := w.(http.Hijacker)
if !ok {
return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker")
}
var rw *bufio.ReadWriter
netConn, rw, err = h.Hijack()
if err != nil {
return u.returnError(w, r, http.StatusInternalServerError, err.Error())
}
br = rw.Reader
if br.Buffered() > 0 {
netConn.Close()
return nil, errors.New("websocket: client sent data before handshake is complete")
}
c := newConn(netConn, true, u.ReadBufferSize, u.WriteBufferSize)
c.subprotocol = subprotocol
p := c.writeBuf[:0]
p = append(p, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "...)
p = append(p, computeAcceptKey(challengeKey)...)
p = append(p, "\r\n"...)
if c.subprotocol != "" {
p = append(p, "Sec-Websocket-Protocol: "...)
p = append(p, c.subprotocol...)
p = append(p, "\r\n"...)
}
for k, vs := range responseHeader {
if k == "Sec-Websocket-Protocol" {
continue
}
for _, v := range vs {
p = append(p, k...)
p = append(p, ": "...)
for i := 0; i < len(v); i++ {
b := v[i]
if b <= 31 {
// prevent response splitting.
b = ' '
}
p = append(p, b)
}
p = append(p, "\r\n"...)
}
}
p = append(p, "\r\n"...)
// Clear deadlines set by HTTP server.
netConn.SetDeadline(time.Time{})
if u.HandshakeTimeout > 0 {
netConn.SetWriteDeadline(time.Now().Add(u.HandshakeTimeout))
}
if _, err = netConn.Write(p); err != nil {
netConn.Close()
return nil, err
}
if u.HandshakeTimeout > 0 {
netConn.SetWriteDeadline(time.Time{})
}
return c, nil
}
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
//
// This function is deprecated, use websocket.Upgrader instead.
//
// The application is responsible for checking the request origin before
// calling Upgrade. An example implementation of the same origin policy is:
//
// if req.Header.Get("Origin") != "http://"+req.Host {
// http.Error(w, "Origin not allowed", 403)
// return
// }
//
// If the endpoint supports subprotocols, then the application is responsible
// for negotiating the protocol used on the connection. Use the Subprotocols()
// function to get the subprotocols requested by the client. Use the
// Sec-Websocket-Protocol response header to specify the subprotocol selected
// by the application.
//
// The responseHeader is included in the response to the client's upgrade
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
// negotiated subprotocol (Sec-Websocket-Protocol).
//
// The connection buffers IO to the underlying network connection. The
// readBufSize and writeBufSize parameters specify the size of the buffers to
// use. Messages can be larger than the buffers.
//
// If the request is not a valid WebSocket handshake, then Upgrade returns an
// error of type HandshakeError. Applications should handle this error by
// replying to the client with an HTTP error response.
func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int) (*Conn, error) {
u := Upgrader{ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize}
u.Error = func(w http.ResponseWriter, r *http.Request, status int, reason error) {
// don't return errors to maintain backwards compatibility
}
u.CheckOrigin = func(r *http.Request) bool {
// allow all connections by default
return true
}
return u.Upgrade(w, r, responseHeader)
}
// Subprotocols returns the subprotocols requested by the client in the
// Sec-Websocket-Protocol header.
func Subprotocols(r *http.Request) []string {
h := strings.TrimSpace(r.Header.Get("Sec-Websocket-Protocol"))
if h == "" {
return nil
}
protocols := strings.Split(h, ",")
for i := range protocols {
protocols[i] = strings.TrimSpace(protocols[i])
}
return protocols
}
// IsWebSocketUpgrade returns true if the client requested upgrade to the
// WebSocket protocol.
func IsWebSocketUpgrade(r *http.Request) bool {
return tokenListContainsValue(r.Header, "Connection", "upgrade") &&
tokenListContainsValue(r.Header, "Upgrade", "websocket")
}

214
vendor/github.com/gorilla/websocket/util.go generated vendored Normal file
View File

@ -0,0 +1,214 @@
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"crypto/rand"
"crypto/sha1"
"encoding/base64"
"io"
"net/http"
"strings"
)
var keyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
func computeAcceptKey(challengeKey string) string {
h := sha1.New()
h.Write([]byte(challengeKey))
h.Write(keyGUID)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
func generateChallengeKey() (string, error) {
p := make([]byte, 16)
if _, err := io.ReadFull(rand.Reader, p); err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(p), nil
}
// Octet types from RFC 2616.
var octetTypes [256]byte
const (
isTokenOctet = 1 << iota
isSpaceOctet
)
func init() {
// From RFC 2616
//
// OCTET = <any 8-bit sequence of data>
// CHAR = <any US-ASCII character (octets 0 - 127)>
// CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
// CR = <US-ASCII CR, carriage return (13)>
// LF = <US-ASCII LF, linefeed (10)>
// SP = <US-ASCII SP, space (32)>
// HT = <US-ASCII HT, horizontal-tab (9)>
// <"> = <US-ASCII double-quote mark (34)>
// CRLF = CR LF
// LWS = [CRLF] 1*( SP | HT )
// TEXT = <any OCTET except CTLs, but including LWS>
// separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <">
// | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT
// token = 1*<any CHAR except CTLs or separators>
// qdtext = <any TEXT except <">>
for c := 0; c < 256; c++ {
var t byte
isCtl := c <= 31 || c == 127
isChar := 0 <= c && c <= 127
isSeparator := strings.IndexRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) >= 0
if strings.IndexRune(" \t\r\n", rune(c)) >= 0 {
t |= isSpaceOctet
}
if isChar && !isCtl && !isSeparator {
t |= isTokenOctet
}
octetTypes[c] = t
}
}
func skipSpace(s string) (rest string) {
i := 0
for ; i < len(s); i++ {
if octetTypes[s[i]]&isSpaceOctet == 0 {
break
}
}
return s[i:]
}
func nextToken(s string) (token, rest string) {
i := 0
for ; i < len(s); i++ {
if octetTypes[s[i]]&isTokenOctet == 0 {
break
}
}
return s[:i], s[i:]
}
func nextTokenOrQuoted(s string) (value string, rest string) {
if !strings.HasPrefix(s, "\"") {
return nextToken(s)
}
s = s[1:]
for i := 0; i < len(s); i++ {
switch s[i] {
case '"':
return s[:i], s[i+1:]
case '\\':
p := make([]byte, len(s)-1)
j := copy(p, s[:i])
escape := true
for i = i + 1; i < len(s); i++ {
b := s[i]
switch {
case escape:
escape = false
p[j] = b
j += 1
case b == '\\':
escape = true
case b == '"':
return string(p[:j]), s[i+1:]
default:
p[j] = b
j += 1
}
}
return "", ""
}
}
return "", ""
}
// tokenListContainsValue returns true if the 1#token header with the given
// name contains token.
func tokenListContainsValue(header http.Header, name string, value string) bool {
headers:
for _, s := range header[name] {
for {
var t string
t, s = nextToken(skipSpace(s))
if t == "" {
continue headers
}
s = skipSpace(s)
if s != "" && s[0] != ',' {
continue headers
}
if strings.EqualFold(t, value) {
return true
}
if s == "" {
continue headers
}
s = s[1:]
}
}
return false
}
// parseExtensiosn parses WebSocket extensions from a header.
func parseExtensions(header http.Header) []map[string]string {
// From RFC 6455:
//
// Sec-WebSocket-Extensions = extension-list
// extension-list = 1#extension
// extension = extension-token *( ";" extension-param )
// extension-token = registered-token
// registered-token = token
// extension-param = token [ "=" (token | quoted-string) ]
// ;When using the quoted-string syntax variant, the value
// ;after quoted-string unescaping MUST conform to the
// ;'token' ABNF.
var result []map[string]string
headers:
for _, s := range header["Sec-Websocket-Extensions"] {
for {
var t string
t, s = nextToken(skipSpace(s))
if t == "" {
continue headers
}
ext := map[string]string{"": t}
for {
s = skipSpace(s)
if !strings.HasPrefix(s, ";") {
break
}
var k string
k, s = nextToken(skipSpace(s[1:]))
if k == "" {
continue headers
}
s = skipSpace(s)
var v string
if strings.HasPrefix(s, "=") {
v, s = nextTokenOrQuoted(skipSpace(s[1:]))
s = skipSpace(s)
}
if s != "" && s[0] != ',' && s[0] != ';' {
continue headers
}
ext[k] = v
}
if s != "" && s[0] != ',' {
continue headers
}
result = append(result, ext)
if s == "" {
continue headers
}
s = s[1:]
}
}
return result
}

31
vendor/github.com/rancher/go-rancher/Dockerfile.dapper generated vendored Normal file
View File

@ -0,0 +1,31 @@
FROM ubuntu:16.04
# FROM arm=armhf/ubuntu:16.04
ARG DAPPER_HOST_ARCH
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
RUN wget -O - https://storage.googleapis.com/golang/go1.6.2.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local && \
go get github.com/rancher/trash && go get github.com/golang/lint/golint
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
ENV DAPPER_SOURCE /go/src/github.com/rancher/go-rancher/
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache
ENV HOME ${DAPPER_SOURCE}
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]

177
vendor/github.com/rancher/go-rancher/LICENSE generated vendored Normal file
View File

@ -0,0 +1,177 @@
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

23
vendor/github.com/rancher/go-rancher/Makefile generated vendored Normal file
View File

@ -0,0 +1,23 @@
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)

35
vendor/github.com/rancher/go-rancher/README.md generated vendored Normal file
View File

@ -0,0 +1,35 @@
# Go Bindings for Rancher API
# 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

@ -0,0 +1,7 @@
package client
type RancherBaseClient struct {
Opts *ClientOpts
Schemas *Schemas
Types map[string]Schema
}

565
vendor/github.com/rancher/go-rancher/client/common.go generated vendored Normal file
View File

@ -0,0 +1,565 @@
package client
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"regexp"
"time"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
)
const (
SELF = "self"
COLLECTION = "collection"
)
var (
debug = false
dialer = &websocket.Dialer{}
)
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 {
q.Add(k, fmt.Sprintf("%v", v))
}
u.RawQuery = q.Encode()
return u.String(), nil
}
func setupRancherBaseClient(rancherClient *RancherBaseClient, opts *ClientOpts) error {
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 *RancherBaseClient) setupRequest(req *http.Request) {
req.SetBasicAuth(rancherClient.Opts.AccessKey, rancherClient.Opts.SecretKey)
}
func (rancherClient *RancherBaseClient) newHttpClient() *http.Client {
if rancherClient.Opts.Timeout == 0 {
rancherClient.Opts.Timeout = time.Second * 10
}
return &http.Client{Timeout: rancherClient.Opts.Timeout}
}
func (rancherClient *RancherBaseClient) 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 *RancherBaseClient) Websocket(url string, headers map[string][]string) (*websocket.Conn, *http.Response, error) {
return dialer.Dial(url, http.Header(headers))
}
func (rancherClient *RancherBaseClient) 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 *RancherBaseClient) List(schemaType string, opts *ListOpts, respObject interface{}) error {
return rancherClient.doList(schemaType, opts, respObject)
}
func (rancherClient *RancherBaseClient) 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 *RancherBaseClient) Post(url string, createObj interface{}, respObject interface{}) error {
return rancherClient.doModify("POST", url, createObj, respObject)
}
func (rancherClient *RancherBaseClient) 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 *RancherBaseClient) 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")
req.Header.Set("Content-Length", string(len(bodyContent)))
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 *RancherBaseClient) Create(schemaType string, createObj interface{}, respObject interface{}) error {
return rancherClient.doCreate(schemaType, createObj, respObject)
}
func (rancherClient *RancherBaseClient) 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 *RancherBaseClient) Update(schemaType string, existing *Resource, updates interface{}, respObject interface{}) error {
return rancherClient.doUpdate(schemaType, existing, updates, respObject)
}
func (rancherClient *RancherBaseClient) 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 *RancherBaseClient) ById(schemaType string, id string, respObject interface{}) error {
return rancherClient.doById(schemaType, id, respObject)
}
func (rancherClient *RancherBaseClient) 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 *RancherBaseClient) Delete(existing *Resource) error {
if existing == nil {
return nil
}
return rancherClient.doResourceDelete(existing.Type, existing)
}
func (rancherClient *RancherBaseClient) 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 *RancherBaseClient) 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 *RancherBaseClient) Action(schemaType string, action string,
existing *Resource, inputObject, respObject interface{}) error {
return rancherClient.doAction(schemaType, action, existing, inputObject, respObject)
}
func (rancherClient *RancherBaseClient) 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 init() {
debug = os.Getenv("RANCHER_CLIENT_DEBUG") == "true"
if debug {
fmt.Println("Rancher client debug on")
}
}

View File

@ -0,0 +1,172 @@
package client
const (
ACCOUNT_TYPE = "account"
)
type Account struct {
Resource
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"`
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"`
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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type AccountCollection struct {
Collection
Data []Account `json:"data,omitempty"`
}
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)
ActionRestore(*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)
return resp, err
}
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) ActionRestore(resource *Account) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doAction(ACCOUNT_TYPE, "restore", &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

@ -0,0 +1,75 @@
package client
const (
ACTIVE_SETTING_TYPE = "activeSetting"
)
type ActiveSetting struct {
Resource
ActiveValue interface{} `json:"activeValue,omitempty" yaml:"active_value,omitempty"`
InDb bool `json:"inDb,omitempty" yaml:"in_db,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Source string `json:"source,omitempty" yaml:"source,omitempty"`
Value string `json:"value,omitempty" yaml:"value,omitempty"`
}
type ActiveSettingCollection struct {
Collection
Data []ActiveSetting `json:"data,omitempty"`
}
type ActiveSettingClient struct {
rancherClient *RancherClient
}
type ActiveSettingOperations interface {
List(opts *ListOpts) (*ActiveSettingCollection, error)
Create(opts *ActiveSetting) (*ActiveSetting, error)
Update(existing *ActiveSetting, updates interface{}) (*ActiveSetting, error)
ById(id string) (*ActiveSetting, error)
Delete(container *ActiveSetting) error
}
func newActiveSettingClient(rancherClient *RancherClient) *ActiveSettingClient {
return &ActiveSettingClient{
rancherClient: rancherClient,
}
}
func (c *ActiveSettingClient) Create(container *ActiveSetting) (*ActiveSetting, error) {
resp := &ActiveSetting{}
err := c.rancherClient.doCreate(ACTIVE_SETTING_TYPE, container, resp)
return resp, err
}
func (c *ActiveSettingClient) Update(existing *ActiveSetting, updates interface{}) (*ActiveSetting, error) {
resp := &ActiveSetting{}
err := c.rancherClient.doUpdate(ACTIVE_SETTING_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ActiveSettingClient) List(opts *ListOpts) (*ActiveSettingCollection, error) {
resp := &ActiveSettingCollection{}
err := c.rancherClient.doList(ACTIVE_SETTING_TYPE, opts, resp)
return resp, err
}
func (c *ActiveSettingClient) ById(id string) (*ActiveSetting, error) {
resp := &ActiveSetting{}
err := c.rancherClient.doById(ACTIVE_SETTING_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ActiveSettingClient) Delete(container *ActiveSetting) error {
return c.rancherClient.doResourceDelete(ACTIVE_SETTING_TYPE, &container.Resource)
}

View File

@ -0,0 +1,64 @@
package client
const (
ADD_LABEL_INPUT_TYPE = "addLabelInput"
)
type AddLabelInput struct {
Resource
Key string `json:"key,omitempty"`
Value string `json:"value,omitempty"`
}
type AddLabelInputCollection struct {
Collection
Data []AddLabelInput `json:"data,omitempty"`
}
type AddLabelInputClient struct {
rancherClient *RancherClient
}
type AddLabelInputOperations interface {
List(opts *ListOpts) (*AddLabelInputCollection, error)
Create(opts *AddLabelInput) (*AddLabelInput, error)
Update(existing *AddLabelInput, updates interface{}) (*AddLabelInput, error)
ById(id string) (*AddLabelInput, error)
Delete(container *AddLabelInput) error
}
func newAddLabelInputClient(rancherClient *RancherClient) *AddLabelInputClient {
return &AddLabelInputClient{
rancherClient: rancherClient,
}
}
func (c *AddLabelInputClient) Create(container *AddLabelInput) (*AddLabelInput, error) {
resp := &AddLabelInput{}
err := c.rancherClient.doCreate(ADD_LABEL_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddLabelInputClient) Update(existing *AddLabelInput, updates interface{}) (*AddLabelInput, error) {
resp := &AddLabelInput{}
err := c.rancherClient.doUpdate(ADD_LABEL_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddLabelInputClient) List(opts *ListOpts) (*AddLabelInputCollection, error) {
resp := &AddLabelInputCollection{}
err := c.rancherClient.doList(ADD_LABEL_INPUT_TYPE, opts, resp)
return resp, err
}
func (c *AddLabelInputClient) ById(id string) (*AddLabelInput, error) {
resp := &AddLabelInput{}
err := c.rancherClient.doById(ADD_LABEL_INPUT_TYPE, id, resp)
return resp, err
}
func (c *AddLabelInputClient) Delete(container *AddLabelInput) error {
return c.rancherClient.doResourceDelete(ADD_LABEL_INPUT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,69 @@
package client
const (
ADD_LOAD_BALANCER_INPUT_TYPE = "addLoadBalancerInput"
)
type AddLoadBalancerInput struct {
Resource
LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,omitempty"`
Weight int64 `json:"weight,omitempty" yaml:"weight,omitempty"`
}
type AddLoadBalancerInputCollection struct {
Collection
Data []AddLoadBalancerInput `json:"data,omitempty"`
}
type AddLoadBalancerInputClient struct {
rancherClient *RancherClient
}
type AddLoadBalancerInputOperations interface {
List(opts *ListOpts) (*AddLoadBalancerInputCollection, error)
Create(opts *AddLoadBalancerInput) (*AddLoadBalancerInput, error)
Update(existing *AddLoadBalancerInput, updates interface{}) (*AddLoadBalancerInput, error)
ById(id string) (*AddLoadBalancerInput, error)
Delete(container *AddLoadBalancerInput) error
}
func newAddLoadBalancerInputClient(rancherClient *RancherClient) *AddLoadBalancerInputClient {
return &AddLoadBalancerInputClient{
rancherClient: rancherClient,
}
}
func (c *AddLoadBalancerInputClient) Create(container *AddLoadBalancerInput) (*AddLoadBalancerInput, error) {
resp := &AddLoadBalancerInput{}
err := c.rancherClient.doCreate(ADD_LOAD_BALANCER_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddLoadBalancerInputClient) Update(existing *AddLoadBalancerInput, updates interface{}) (*AddLoadBalancerInput, error) {
resp := &AddLoadBalancerInput{}
err := c.rancherClient.doUpdate(ADD_LOAD_BALANCER_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddLoadBalancerInputClient) List(opts *ListOpts) (*AddLoadBalancerInputCollection, error) {
resp := &AddLoadBalancerInputCollection{}
err := c.rancherClient.doList(ADD_LOAD_BALANCER_INPUT_TYPE, opts, resp)
return resp, err
}
func (c *AddLoadBalancerInputClient) ById(id string) (*AddLoadBalancerInput, error) {
resp := &AddLoadBalancerInput{}
err := c.rancherClient.doById(ADD_LOAD_BALANCER_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AddLoadBalancerInputClient) Delete(container *AddLoadBalancerInput) error {
return c.rancherClient.doResourceDelete(ADD_LOAD_BALANCER_INPUT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,67 @@
package client
const (
ADD_OUTPUTS_INPUT_TYPE = "addOutputsInput"
)
type AddOutputsInput struct {
Resource
Outputs map[string]interface{} `json:"outputs,omitempty" yaml:"outputs,omitempty"`
}
type AddOutputsInputCollection struct {
Collection
Data []AddOutputsInput `json:"data,omitempty"`
}
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)
return resp, err
}
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

@ -0,0 +1,67 @@
package client
const (
ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE = "addRemoveClusterHostInput"
)
type AddRemoveClusterHostInput struct {
Resource
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
}
type AddRemoveClusterHostInputCollection struct {
Collection
Data []AddRemoveClusterHostInput `json:"data,omitempty"`
}
type AddRemoveClusterHostInputClient struct {
rancherClient *RancherClient
}
type AddRemoveClusterHostInputOperations interface {
List(opts *ListOpts) (*AddRemoveClusterHostInputCollection, error)
Create(opts *AddRemoveClusterHostInput) (*AddRemoveClusterHostInput, error)
Update(existing *AddRemoveClusterHostInput, updates interface{}) (*AddRemoveClusterHostInput, error)
ById(id string) (*AddRemoveClusterHostInput, error)
Delete(container *AddRemoveClusterHostInput) error
}
func newAddRemoveClusterHostInputClient(rancherClient *RancherClient) *AddRemoveClusterHostInputClient {
return &AddRemoveClusterHostInputClient{
rancherClient: rancherClient,
}
}
func (c *AddRemoveClusterHostInputClient) Create(container *AddRemoveClusterHostInput) (*AddRemoveClusterHostInput, error) {
resp := &AddRemoveClusterHostInput{}
err := c.rancherClient.doCreate(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddRemoveClusterHostInputClient) Update(existing *AddRemoveClusterHostInput, updates interface{}) (*AddRemoveClusterHostInput, error) {
resp := &AddRemoveClusterHostInput{}
err := c.rancherClient.doUpdate(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddRemoveClusterHostInputClient) List(opts *ListOpts) (*AddRemoveClusterHostInputCollection, error) {
resp := &AddRemoveClusterHostInputCollection{}
err := c.rancherClient.doList(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, opts, resp)
return resp, err
}
func (c *AddRemoveClusterHostInputClient) ById(id string) (*AddRemoveClusterHostInput, error) {
resp := &AddRemoveClusterHostInput{}
err := c.rancherClient.doById(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AddRemoveClusterHostInputClient) Delete(container *AddRemoveClusterHostInput) error {
return c.rancherClient.doResourceDelete(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,67 @@
package client
const (
ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE = "addRemoveLoadBalancerHostInput"
)
type AddRemoveLoadBalancerHostInput struct {
Resource
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
}
type AddRemoveLoadBalancerHostInputCollection struct {
Collection
Data []AddRemoveLoadBalancerHostInput `json:"data,omitempty"`
}
type AddRemoveLoadBalancerHostInputClient struct {
rancherClient *RancherClient
}
type AddRemoveLoadBalancerHostInputOperations interface {
List(opts *ListOpts) (*AddRemoveLoadBalancerHostInputCollection, error)
Create(opts *AddRemoveLoadBalancerHostInput) (*AddRemoveLoadBalancerHostInput, error)
Update(existing *AddRemoveLoadBalancerHostInput, updates interface{}) (*AddRemoveLoadBalancerHostInput, error)
ById(id string) (*AddRemoveLoadBalancerHostInput, error)
Delete(container *AddRemoveLoadBalancerHostInput) error
}
func newAddRemoveLoadBalancerHostInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerHostInputClient {
return &AddRemoveLoadBalancerHostInputClient{
rancherClient: rancherClient,
}
}
func (c *AddRemoveLoadBalancerHostInputClient) Create(container *AddRemoveLoadBalancerHostInput) (*AddRemoveLoadBalancerHostInput, error) {
resp := &AddRemoveLoadBalancerHostInput{}
err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerHostInputClient) Update(existing *AddRemoveLoadBalancerHostInput, updates interface{}) (*AddRemoveLoadBalancerHostInput, error) {
resp := &AddRemoveLoadBalancerHostInput{}
err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerHostInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerHostInputCollection, error) {
resp := &AddRemoveLoadBalancerHostInputCollection{}
err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, opts, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerHostInputClient) ById(id string) (*AddRemoveLoadBalancerHostInput, error) {
resp := &AddRemoveLoadBalancerHostInput{}
err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AddRemoveLoadBalancerHostInputClient) Delete(container *AddRemoveLoadBalancerHostInput) error {
return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,67 @@
package client
const (
ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE = "addRemoveLoadBalancerListenerInput"
)
type AddRemoveLoadBalancerListenerInput struct {
Resource
LoadBalancerListenerId string `json:"loadBalancerListenerId,omitempty" yaml:"load_balancer_listener_id,omitempty"`
}
type AddRemoveLoadBalancerListenerInputCollection struct {
Collection
Data []AddRemoveLoadBalancerListenerInput `json:"data,omitempty"`
}
type AddRemoveLoadBalancerListenerInputClient struct {
rancherClient *RancherClient
}
type AddRemoveLoadBalancerListenerInputOperations interface {
List(opts *ListOpts) (*AddRemoveLoadBalancerListenerInputCollection, error)
Create(opts *AddRemoveLoadBalancerListenerInput) (*AddRemoveLoadBalancerListenerInput, error)
Update(existing *AddRemoveLoadBalancerListenerInput, updates interface{}) (*AddRemoveLoadBalancerListenerInput, error)
ById(id string) (*AddRemoveLoadBalancerListenerInput, error)
Delete(container *AddRemoveLoadBalancerListenerInput) error
}
func newAddRemoveLoadBalancerListenerInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerListenerInputClient {
return &AddRemoveLoadBalancerListenerInputClient{
rancherClient: rancherClient,
}
}
func (c *AddRemoveLoadBalancerListenerInputClient) Create(container *AddRemoveLoadBalancerListenerInput) (*AddRemoveLoadBalancerListenerInput, error) {
resp := &AddRemoveLoadBalancerListenerInput{}
err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerListenerInputClient) Update(existing *AddRemoveLoadBalancerListenerInput, updates interface{}) (*AddRemoveLoadBalancerListenerInput, error) {
resp := &AddRemoveLoadBalancerListenerInput{}
err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerListenerInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerListenerInputCollection, error) {
resp := &AddRemoveLoadBalancerListenerInputCollection{}
err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, opts, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerListenerInputClient) ById(id string) (*AddRemoveLoadBalancerListenerInput, error) {
resp := &AddRemoveLoadBalancerListenerInput{}
err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AddRemoveLoadBalancerListenerInputClient) Delete(container *AddRemoveLoadBalancerListenerInput) error {
return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,67 @@
package client
const (
ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE = "addRemoveLoadBalancerServiceLinkInput"
)
type AddRemoveLoadBalancerServiceLinkInput struct {
Resource
ServiceLink LoadBalancerServiceLink `json:"serviceLink,omitempty" yaml:"service_link,omitempty"`
}
type AddRemoveLoadBalancerServiceLinkInputCollection struct {
Collection
Data []AddRemoveLoadBalancerServiceLinkInput `json:"data,omitempty"`
}
type AddRemoveLoadBalancerServiceLinkInputClient struct {
rancherClient *RancherClient
}
type AddRemoveLoadBalancerServiceLinkInputOperations interface {
List(opts *ListOpts) (*AddRemoveLoadBalancerServiceLinkInputCollection, error)
Create(opts *AddRemoveLoadBalancerServiceLinkInput) (*AddRemoveLoadBalancerServiceLinkInput, error)
Update(existing *AddRemoveLoadBalancerServiceLinkInput, updates interface{}) (*AddRemoveLoadBalancerServiceLinkInput, error)
ById(id string) (*AddRemoveLoadBalancerServiceLinkInput, error)
Delete(container *AddRemoveLoadBalancerServiceLinkInput) error
}
func newAddRemoveLoadBalancerServiceLinkInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerServiceLinkInputClient {
return &AddRemoveLoadBalancerServiceLinkInputClient{
rancherClient: rancherClient,
}
}
func (c *AddRemoveLoadBalancerServiceLinkInputClient) Create(container *AddRemoveLoadBalancerServiceLinkInput) (*AddRemoveLoadBalancerServiceLinkInput, error) {
resp := &AddRemoveLoadBalancerServiceLinkInput{}
err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerServiceLinkInputClient) Update(existing *AddRemoveLoadBalancerServiceLinkInput, updates interface{}) (*AddRemoveLoadBalancerServiceLinkInput, error) {
resp := &AddRemoveLoadBalancerServiceLinkInput{}
err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerServiceLinkInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerServiceLinkInputCollection, error) {
resp := &AddRemoveLoadBalancerServiceLinkInputCollection{}
err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, opts, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerServiceLinkInputClient) ById(id string) (*AddRemoveLoadBalancerServiceLinkInput, error) {
resp := &AddRemoveLoadBalancerServiceLinkInput{}
err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AddRemoveLoadBalancerServiceLinkInputClient) Delete(container *AddRemoveLoadBalancerServiceLinkInput) error {
return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,67 @@
package client
const (
ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE = "addRemoveLoadBalancerTargetInput"
)
type AddRemoveLoadBalancerTargetInput struct {
Resource
LoadBalancerTarget LoadBalancerTarget `json:"loadBalancerTarget,omitempty" yaml:"load_balancer_target,omitempty"`
}
type AddRemoveLoadBalancerTargetInputCollection struct {
Collection
Data []AddRemoveLoadBalancerTargetInput `json:"data,omitempty"`
}
type AddRemoveLoadBalancerTargetInputClient struct {
rancherClient *RancherClient
}
type AddRemoveLoadBalancerTargetInputOperations interface {
List(opts *ListOpts) (*AddRemoveLoadBalancerTargetInputCollection, error)
Create(opts *AddRemoveLoadBalancerTargetInput) (*AddRemoveLoadBalancerTargetInput, error)
Update(existing *AddRemoveLoadBalancerTargetInput, updates interface{}) (*AddRemoveLoadBalancerTargetInput, error)
ById(id string) (*AddRemoveLoadBalancerTargetInput, error)
Delete(container *AddRemoveLoadBalancerTargetInput) error
}
func newAddRemoveLoadBalancerTargetInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerTargetInputClient {
return &AddRemoveLoadBalancerTargetInputClient{
rancherClient: rancherClient,
}
}
func (c *AddRemoveLoadBalancerTargetInputClient) Create(container *AddRemoveLoadBalancerTargetInput) (*AddRemoveLoadBalancerTargetInput, error) {
resp := &AddRemoveLoadBalancerTargetInput{}
err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerTargetInputClient) Update(existing *AddRemoveLoadBalancerTargetInput, updates interface{}) (*AddRemoveLoadBalancerTargetInput, error) {
resp := &AddRemoveLoadBalancerTargetInput{}
err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerTargetInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerTargetInputCollection, error) {
resp := &AddRemoveLoadBalancerTargetInputCollection{}
err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, opts, resp)
return resp, err
}
func (c *AddRemoveLoadBalancerTargetInputClient) ById(id string) (*AddRemoveLoadBalancerTargetInput, error) {
resp := &AddRemoveLoadBalancerTargetInput{}
err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AddRemoveLoadBalancerTargetInputClient) Delete(container *AddRemoveLoadBalancerTargetInput) error {
return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,67 @@
package client
const (
ADD_REMOVE_SERVICE_LINK_INPUT_TYPE = "addRemoveServiceLinkInput"
)
type AddRemoveServiceLinkInput struct {
Resource
ServiceLink ServiceLink `json:"serviceLink,omitempty" yaml:"service_link,omitempty"`
}
type AddRemoveServiceLinkInputCollection struct {
Collection
Data []AddRemoveServiceLinkInput `json:"data,omitempty"`
}
type AddRemoveServiceLinkInputClient struct {
rancherClient *RancherClient
}
type AddRemoveServiceLinkInputOperations interface {
List(opts *ListOpts) (*AddRemoveServiceLinkInputCollection, error)
Create(opts *AddRemoveServiceLinkInput) (*AddRemoveServiceLinkInput, error)
Update(existing *AddRemoveServiceLinkInput, updates interface{}) (*AddRemoveServiceLinkInput, error)
ById(id string) (*AddRemoveServiceLinkInput, error)
Delete(container *AddRemoveServiceLinkInput) error
}
func newAddRemoveServiceLinkInputClient(rancherClient *RancherClient) *AddRemoveServiceLinkInputClient {
return &AddRemoveServiceLinkInputClient{
rancherClient: rancherClient,
}
}
func (c *AddRemoveServiceLinkInputClient) Create(container *AddRemoveServiceLinkInput) (*AddRemoveServiceLinkInput, error) {
resp := &AddRemoveServiceLinkInput{}
err := c.rancherClient.doCreate(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddRemoveServiceLinkInputClient) Update(existing *AddRemoveServiceLinkInput, updates interface{}) (*AddRemoveServiceLinkInput, error) {
resp := &AddRemoveServiceLinkInput{}
err := c.rancherClient.doUpdate(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddRemoveServiceLinkInputClient) List(opts *ListOpts) (*AddRemoveServiceLinkInputCollection, error) {
resp := &AddRemoveServiceLinkInputCollection{}
err := c.rancherClient.doList(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, opts, resp)
return resp, err
}
func (c *AddRemoveServiceLinkInputClient) ById(id string) (*AddRemoveServiceLinkInput, error) {
resp := &AddRemoveServiceLinkInput{}
err := c.rancherClient.doById(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AddRemoveServiceLinkInputClient) Delete(container *AddRemoveServiceLinkInput) error {
return c.rancherClient.doResourceDelete(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,183 @@
package client
const (
AGENT_TYPE = "agent"
)
type Agent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_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"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ManagedConfig bool `json:"managedConfig,omitempty" yaml:"managed_config,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,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"`
}
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)
ActionPurge(*Agent) (*Agent, error)
ActionReconnect(*Agent) (*Agent, error)
ActionRemove(*Agent) (*Agent, error)
ActionRestore(*Agent) (*Agent, error)
ActionUpdate(*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)
return resp, err
}
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) ActionPurge(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "purge", &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
}
func (c *AgentClient) ActionRestore(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "restore", &resource.Resource, nil, resp)
return resp, err
}
func (c *AgentClient) ActionUpdate(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,101 @@
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"`
IamInstanceProfile string `json:"iamInstanceProfile,omitempty" yaml:"iam_instance_profile,omitempty"`
InstanceType string `json:"instanceType,omitempty" yaml:"instance_type,omitempty"`
Monitoring bool `json:"monitoring,omitempty" yaml:"monitoring,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"`
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"`
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
SubnetId string `json:"subnetId,omitempty" yaml:"subnet_id,omitempty"`
UsePrivateAddress bool `json:"usePrivateAddress,omitempty" yaml:"use_private_address,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"`
}
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)
return resp, err
}
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

@ -0,0 +1,161 @@
package client
const (
API_KEY_TYPE = "apiKey"
)
type ApiKey struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_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"`
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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ApiKeyCollection struct {
Collection
Data []ApiKey `json:"data,omitempty"`
}
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)
ActionPurge(*ApiKey) (*Credential, error)
ActionRemove(*ApiKey) (*Credential, error)
ActionUpdate(*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)
return resp, err
}
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) ActionPurge(resource *ApiKey) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(API_KEY_TYPE, "purge", &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
}
func (c *ApiKeyClient) ActionUpdate(resource *ApiKey) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(API_KEY_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,93 @@
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 string `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"`
}
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)
return resp, err
}
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

@ -0,0 +1,87 @@
package client
const (
AZURE_CONFIG_TYPE = "azureConfig"
)
type AzureConfig struct {
Resource
DockerPort string `json:"dockerPort,omitempty" yaml:"docker_port,omitempty"`
DockerSwarmMasterPort string `json:"dockerSwarmMasterPort,omitempty" yaml:"docker_swarm_master_port,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
Location string `json:"location,omitempty" yaml:"location,omitempty"`
Password string `json:"password,omitempty" yaml:"password,omitempty"`
PublishSettingsFile string `json:"publishSettingsFile,omitempty" yaml:"publish_settings_file,omitempty"`
Size string `json:"size,omitempty" yaml:"size,omitempty"`
SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"`
SubscriptionCert string `json:"subscriptionCert,omitempty" yaml:"subscription_cert,omitempty"`
SubscriptionId string `json:"subscriptionId,omitempty" yaml:"subscription_id,omitempty"`
Username string `json:"username,omitempty" yaml:"username,omitempty"`
}
type AzureConfigCollection struct {
Collection
Data []AzureConfig `json:"data,omitempty"`
}
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)
return resp, err
}
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

@ -0,0 +1,81 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,121 @@
package client
const (
BACKUP_TYPE = "backup"
)
type Backup struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
BackupTargetId string `json:"backupTargetId,omitempty" yaml:"backup_target_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"`
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"`
SnapshotId string `json:"snapshotId,omitempty" yaml:"snapshot_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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
VolumeId string `json:"volumeId,omitempty" yaml:"volume_id,omitempty"`
}
type BackupCollection struct {
Collection
Data []Backup `json:"data,omitempty"`
}
type BackupClient struct {
rancherClient *RancherClient
}
type BackupOperations interface {
List(opts *ListOpts) (*BackupCollection, error)
Create(opts *Backup) (*Backup, error)
Update(existing *Backup, updates interface{}) (*Backup, error)
ById(id string) (*Backup, error)
Delete(container *Backup) error
ActionCreate(*Backup) (*Backup, error)
ActionRemove(*Backup) (*Backup, error)
}
func newBackupClient(rancherClient *RancherClient) *BackupClient {
return &BackupClient{
rancherClient: rancherClient,
}
}
func (c *BackupClient) Create(container *Backup) (*Backup, error) {
resp := &Backup{}
err := c.rancherClient.doCreate(BACKUP_TYPE, container, resp)
return resp, err
}
func (c *BackupClient) Update(existing *Backup, updates interface{}) (*Backup, error) {
resp := &Backup{}
err := c.rancherClient.doUpdate(BACKUP_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *BackupClient) List(opts *ListOpts) (*BackupCollection, error) {
resp := &BackupCollection{}
err := c.rancherClient.doList(BACKUP_TYPE, opts, resp)
return resp, err
}
func (c *BackupClient) ById(id string) (*Backup, error) {
resp := &Backup{}
err := c.rancherClient.doById(BACKUP_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *BackupClient) Delete(container *Backup) error {
return c.rancherClient.doResourceDelete(BACKUP_TYPE, &container.Resource)
}
func (c *BackupClient) ActionCreate(resource *Backup) (*Backup, error) {
resp := &Backup{}
err := c.rancherClient.doAction(BACKUP_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *BackupClient) ActionRemove(resource *Backup) (*Backup, error) {
resp := &Backup{}
err := c.rancherClient.doAction(BACKUP_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,115 @@
package client
const (
BACKUP_TARGET_TYPE = "backupTarget"
)
type BackupTarget struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_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"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NfsConfig *NfsConfig `json:"nfsConfig,omitempty" yaml:"nfs_config,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type BackupTargetCollection struct {
Collection
Data []BackupTarget `json:"data,omitempty"`
}
type BackupTargetClient struct {
rancherClient *RancherClient
}
type BackupTargetOperations interface {
List(opts *ListOpts) (*BackupTargetCollection, error)
Create(opts *BackupTarget) (*BackupTarget, error)
Update(existing *BackupTarget, updates interface{}) (*BackupTarget, error)
ById(id string) (*BackupTarget, error)
Delete(container *BackupTarget) error
ActionCreate(*BackupTarget) (*BackupTarget, error)
ActionRemove(*BackupTarget) (*BackupTarget, error)
}
func newBackupTargetClient(rancherClient *RancherClient) *BackupTargetClient {
return &BackupTargetClient{
rancherClient: rancherClient,
}
}
func (c *BackupTargetClient) Create(container *BackupTarget) (*BackupTarget, error) {
resp := &BackupTarget{}
err := c.rancherClient.doCreate(BACKUP_TARGET_TYPE, container, resp)
return resp, err
}
func (c *BackupTargetClient) Update(existing *BackupTarget, updates interface{}) (*BackupTarget, error) {
resp := &BackupTarget{}
err := c.rancherClient.doUpdate(BACKUP_TARGET_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *BackupTargetClient) List(opts *ListOpts) (*BackupTargetCollection, error) {
resp := &BackupTargetCollection{}
err := c.rancherClient.doList(BACKUP_TARGET_TYPE, opts, resp)
return resp, err
}
func (c *BackupTargetClient) ById(id string) (*BackupTarget, error) {
resp := &BackupTarget{}
err := c.rancherClient.doById(BACKUP_TARGET_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *BackupTargetClient) Delete(container *BackupTarget) error {
return c.rancherClient.doResourceDelete(BACKUP_TARGET_TYPE, &container.Resource)
}
func (c *BackupTargetClient) ActionCreate(resource *BackupTarget) (*BackupTarget, error) {
resp := &BackupTarget{}
err := c.rancherClient.doAction(BACKUP_TARGET_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *BackupTargetClient) ActionRemove(resource *BackupTarget) (*BackupTarget, error) {
resp := &BackupTarget{}
err := c.rancherClient.doAction(BACKUP_TARGET_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,65 @@
package client
const (
BASE_MACHINE_CONFIG_TYPE = "baseMachineConfig"
)
type BaseMachineConfig struct {
Resource
}
type BaseMachineConfigCollection struct {
Collection
Data []BaseMachineConfig `json:"data,omitempty"`
}
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)
return resp, err
}
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

@ -0,0 +1,75 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,150 @@
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"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,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"`
}
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)
return resp, err
}
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

@ -0,0 +1,69 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,304 @@
package client
type RancherClient struct {
RancherBaseClient
Account AccountOperations
ActiveSetting ActiveSettingOperations
AddOutputsInput AddOutputsInputOperations
AddRemoveLoadBalancerServiceLinkInput AddRemoveLoadBalancerServiceLinkInputOperations
AddRemoveServiceLinkInput AddRemoveServiceLinkInputOperations
Agent AgentOperations
ApiKey ApiKeyOperations
AuditLog AuditLogOperations
Azureadconfig AzureadconfigOperations
Backup BackupOperations
BackupTarget BackupTargetOperations
BaseMachineConfig BaseMachineConfigOperations
BlkioDeviceOption BlkioDeviceOptionOperations
Certificate CertificateOperations
ChangeSecretInput ChangeSecretInputOperations
ComposeConfig ComposeConfigOperations
ComposeConfigInput ComposeConfigInputOperations
ComposeProject ComposeProjectOperations
ComposeService ComposeServiceOperations
ConfigItem ConfigItemOperations
ConfigItemStatus ConfigItemStatusOperations
Container ContainerOperations
ContainerEvent ContainerEventOperations
ContainerExec ContainerExecOperations
ContainerLogs ContainerLogsOperations
ContainerProxy ContainerProxyOperations
Credential CredentialOperations
Databasechangelog DatabasechangelogOperations
Databasechangeloglock DatabasechangeloglockOperations
DnsService DnsServiceOperations
DockerBuild DockerBuildOperations
DynamicSchema DynamicSchemaOperations
Environment EnvironmentOperations
EnvironmentUpgrade EnvironmentUpgradeOperations
ExtensionImplementation ExtensionImplementationOperations
ExtensionPoint ExtensionPointOperations
ExternalDnsEvent ExternalDnsEventOperations
ExternalEvent ExternalEventOperations
ExternalHandler ExternalHandlerOperations
ExternalHandlerExternalHandlerProcessMap ExternalHandlerExternalHandlerProcessMapOperations
ExternalHandlerProcess ExternalHandlerProcessOperations
ExternalHandlerProcessConfig ExternalHandlerProcessConfigOperations
ExternalHostEvent ExternalHostEventOperations
ExternalService ExternalServiceOperations
ExternalServiceEvent ExternalServiceEventOperations
ExternalStoragePoolEvent ExternalStoragePoolEventOperations
ExternalVolumeEvent ExternalVolumeEventOperations
FieldDocumentation FieldDocumentationOperations
Githubconfig GithubconfigOperations
HaConfig HaConfigOperations
HaConfigInput HaConfigInputOperations
HaproxyConfig HaproxyConfigOperations
HealthcheckInstanceHostMap HealthcheckInstanceHostMapOperations
Host HostOperations
HostAccess HostAccessOperations
HostApiProxyToken HostApiProxyTokenOperations
Identity IdentityOperations
Image ImageOperations
InServiceUpgradeStrategy InServiceUpgradeStrategyOperations
Instance InstanceOperations
InstanceConsole InstanceConsoleOperations
InstanceConsoleInput InstanceConsoleInputOperations
InstanceHealthCheck InstanceHealthCheckOperations
InstanceLink InstanceLinkOperations
InstanceStop InstanceStopOperations
IpAddress IpAddressOperations
IpAddressAssociateInput IpAddressAssociateInputOperations
KubernetesService KubernetesServiceOperations
KubernetesStack KubernetesStackOperations
KubernetesStackUpgrade KubernetesStackUpgradeOperations
Label LabelOperations
LaunchConfig LaunchConfigOperations
Ldapconfig LdapconfigOperations
LoadBalancerAppCookieStickinessPolicy LoadBalancerAppCookieStickinessPolicyOperations
LoadBalancerConfig LoadBalancerConfigOperations
LoadBalancerCookieStickinessPolicy LoadBalancerCookieStickinessPolicyOperations
LoadBalancerService LoadBalancerServiceOperations
LoadBalancerServiceLink LoadBalancerServiceLinkOperations
LocalAuthConfig LocalAuthConfigOperations
LogConfig LogConfigOperations
Machine MachineOperations
MachineDriver MachineDriverOperations
Mount MountOperations
Network NetworkOperations
NfsConfig NfsConfigOperations
Openldapconfig OpenldapconfigOperations
Password PasswordOperations
PhysicalHost PhysicalHostOperations
Port PortOperations
ProcessDefinition ProcessDefinitionOperations
ProcessExecution ProcessExecutionOperations
ProcessInstance ProcessInstanceOperations
Project ProjectOperations
ProjectMember ProjectMemberOperations
PublicEndpoint PublicEndpointOperations
Publish PublishOperations
PullTask PullTaskOperations
RecreateOnQuorumStrategyConfig RecreateOnQuorumStrategyConfigOperations
Register RegisterOperations
RegistrationToken RegistrationTokenOperations
Registry RegistryOperations
RegistryCredential RegistryCredentialOperations
ResourceDefinition ResourceDefinitionOperations
RestartPolicy RestartPolicyOperations
RestoreFromBackupInput RestoreFromBackupInputOperations
RevertToSnapshotInput RevertToSnapshotInputOperations
RollingRestartStrategy RollingRestartStrategyOperations
ScalePolicy ScalePolicyOperations
SecondaryLaunchConfig SecondaryLaunchConfigOperations
Service ServiceOperations
ServiceConsumeMap ServiceConsumeMapOperations
ServiceEvent ServiceEventOperations
ServiceExposeMap ServiceExposeMapOperations
ServiceLink ServiceLinkOperations
ServiceProxy ServiceProxyOperations
ServiceRestart ServiceRestartOperations
ServiceUpgrade ServiceUpgradeOperations
ServiceUpgradeStrategy ServiceUpgradeStrategyOperations
ServicesPortRange ServicesPortRangeOperations
SetLabelsInput SetLabelsInputOperations
SetLoadBalancerServiceLinksInput SetLoadBalancerServiceLinksInputOperations
SetProjectMembersInput SetProjectMembersInputOperations
SetServiceLinksInput SetServiceLinksInputOperations
Setting SettingOperations
Snapshot SnapshotOperations
SnapshotBackupInput SnapshotBackupInputOperations
StateTransition StateTransitionOperations
StatsAccess StatsAccessOperations
StoragePool StoragePoolOperations
Subscribe SubscribeOperations
Task TaskOperations
TaskInstance TaskInstanceOperations
ToServiceUpgradeStrategy ToServiceUpgradeStrategyOperations
TypeDocumentation TypeDocumentationOperations
VirtualMachine VirtualMachineOperations
VirtualMachineDisk VirtualMachineDiskOperations
Volume VolumeOperations
VolumeSnapshotInput VolumeSnapshotInputOperations
}
func constructClient() *RancherClient {
client := &RancherClient{
RancherBaseClient: RancherBaseClient{
Types: map[string]Schema{},
},
}
client.Account = newAccountClient(client)
client.ActiveSetting = newActiveSettingClient(client)
client.AddOutputsInput = newAddOutputsInputClient(client)
client.AddRemoveLoadBalancerServiceLinkInput = newAddRemoveLoadBalancerServiceLinkInputClient(client)
client.AddRemoveServiceLinkInput = newAddRemoveServiceLinkInputClient(client)
client.Agent = newAgentClient(client)
client.ApiKey = newApiKeyClient(client)
client.AuditLog = newAuditLogClient(client)
client.Azureadconfig = newAzureadconfigClient(client)
client.Backup = newBackupClient(client)
client.BackupTarget = newBackupTargetClient(client)
client.BaseMachineConfig = newBaseMachineConfigClient(client)
client.BlkioDeviceOption = newBlkioDeviceOptionClient(client)
client.Certificate = newCertificateClient(client)
client.ChangeSecretInput = newChangeSecretInputClient(client)
client.ComposeConfig = newComposeConfigClient(client)
client.ComposeConfigInput = newComposeConfigInputClient(client)
client.ComposeProject = newComposeProjectClient(client)
client.ComposeService = newComposeServiceClient(client)
client.ConfigItem = newConfigItemClient(client)
client.ConfigItemStatus = newConfigItemStatusClient(client)
client.Container = newContainerClient(client)
client.ContainerEvent = newContainerEventClient(client)
client.ContainerExec = newContainerExecClient(client)
client.ContainerLogs = newContainerLogsClient(client)
client.ContainerProxy = newContainerProxyClient(client)
client.Credential = newCredentialClient(client)
client.Databasechangelog = newDatabasechangelogClient(client)
client.Databasechangeloglock = newDatabasechangeloglockClient(client)
client.DnsService = newDnsServiceClient(client)
client.DockerBuild = newDockerBuildClient(client)
client.DynamicSchema = newDynamicSchemaClient(client)
client.Environment = newEnvironmentClient(client)
client.EnvironmentUpgrade = newEnvironmentUpgradeClient(client)
client.ExtensionImplementation = newExtensionImplementationClient(client)
client.ExtensionPoint = newExtensionPointClient(client)
client.ExternalDnsEvent = newExternalDnsEventClient(client)
client.ExternalEvent = newExternalEventClient(client)
client.ExternalHandler = newExternalHandlerClient(client)
client.ExternalHandlerExternalHandlerProcessMap = newExternalHandlerExternalHandlerProcessMapClient(client)
client.ExternalHandlerProcess = newExternalHandlerProcessClient(client)
client.ExternalHandlerProcessConfig = newExternalHandlerProcessConfigClient(client)
client.ExternalHostEvent = newExternalHostEventClient(client)
client.ExternalService = newExternalServiceClient(client)
client.ExternalServiceEvent = newExternalServiceEventClient(client)
client.ExternalStoragePoolEvent = newExternalStoragePoolEventClient(client)
client.ExternalVolumeEvent = newExternalVolumeEventClient(client)
client.FieldDocumentation = newFieldDocumentationClient(client)
client.Githubconfig = newGithubconfigClient(client)
client.HaConfig = newHaConfigClient(client)
client.HaConfigInput = newHaConfigInputClient(client)
client.HaproxyConfig = newHaproxyConfigClient(client)
client.HealthcheckInstanceHostMap = newHealthcheckInstanceHostMapClient(client)
client.Host = newHostClient(client)
client.HostAccess = newHostAccessClient(client)
client.HostApiProxyToken = newHostApiProxyTokenClient(client)
client.Identity = newIdentityClient(client)
client.Image = newImageClient(client)
client.InServiceUpgradeStrategy = newInServiceUpgradeStrategyClient(client)
client.Instance = newInstanceClient(client)
client.InstanceConsole = newInstanceConsoleClient(client)
client.InstanceConsoleInput = newInstanceConsoleInputClient(client)
client.InstanceHealthCheck = newInstanceHealthCheckClient(client)
client.InstanceLink = newInstanceLinkClient(client)
client.InstanceStop = newInstanceStopClient(client)
client.IpAddress = newIpAddressClient(client)
client.IpAddressAssociateInput = newIpAddressAssociateInputClient(client)
client.KubernetesService = newKubernetesServiceClient(client)
client.KubernetesStack = newKubernetesStackClient(client)
client.KubernetesStackUpgrade = newKubernetesStackUpgradeClient(client)
client.Label = newLabelClient(client)
client.LaunchConfig = newLaunchConfigClient(client)
client.Ldapconfig = newLdapconfigClient(client)
client.LoadBalancerAppCookieStickinessPolicy = newLoadBalancerAppCookieStickinessPolicyClient(client)
client.LoadBalancerConfig = newLoadBalancerConfigClient(client)
client.LoadBalancerCookieStickinessPolicy = newLoadBalancerCookieStickinessPolicyClient(client)
client.LoadBalancerService = newLoadBalancerServiceClient(client)
client.LoadBalancerServiceLink = newLoadBalancerServiceLinkClient(client)
client.LocalAuthConfig = newLocalAuthConfigClient(client)
client.LogConfig = newLogConfigClient(client)
client.Machine = newMachineClient(client)
client.MachineDriver = newMachineDriverClient(client)
client.Mount = newMountClient(client)
client.Network = newNetworkClient(client)
client.NfsConfig = newNfsConfigClient(client)
client.Openldapconfig = newOpenldapconfigClient(client)
client.Password = newPasswordClient(client)
client.PhysicalHost = newPhysicalHostClient(client)
client.Port = newPortClient(client)
client.ProcessDefinition = newProcessDefinitionClient(client)
client.ProcessExecution = newProcessExecutionClient(client)
client.ProcessInstance = newProcessInstanceClient(client)
client.Project = newProjectClient(client)
client.ProjectMember = newProjectMemberClient(client)
client.PublicEndpoint = newPublicEndpointClient(client)
client.Publish = newPublishClient(client)
client.PullTask = newPullTaskClient(client)
client.RecreateOnQuorumStrategyConfig = newRecreateOnQuorumStrategyConfigClient(client)
client.Register = newRegisterClient(client)
client.RegistrationToken = newRegistrationTokenClient(client)
client.Registry = newRegistryClient(client)
client.RegistryCredential = newRegistryCredentialClient(client)
client.ResourceDefinition = newResourceDefinitionClient(client)
client.RestartPolicy = newRestartPolicyClient(client)
client.RestoreFromBackupInput = newRestoreFromBackupInputClient(client)
client.RevertToSnapshotInput = newRevertToSnapshotInputClient(client)
client.RollingRestartStrategy = newRollingRestartStrategyClient(client)
client.ScalePolicy = newScalePolicyClient(client)
client.SecondaryLaunchConfig = newSecondaryLaunchConfigClient(client)
client.Service = newServiceClient(client)
client.ServiceConsumeMap = newServiceConsumeMapClient(client)
client.ServiceEvent = newServiceEventClient(client)
client.ServiceExposeMap = newServiceExposeMapClient(client)
client.ServiceLink = newServiceLinkClient(client)
client.ServiceProxy = newServiceProxyClient(client)
client.ServiceRestart = newServiceRestartClient(client)
client.ServiceUpgrade = newServiceUpgradeClient(client)
client.ServiceUpgradeStrategy = newServiceUpgradeStrategyClient(client)
client.ServicesPortRange = newServicesPortRangeClient(client)
client.SetLabelsInput = newSetLabelsInputClient(client)
client.SetLoadBalancerServiceLinksInput = newSetLoadBalancerServiceLinksInputClient(client)
client.SetProjectMembersInput = newSetProjectMembersInputClient(client)
client.SetServiceLinksInput = newSetServiceLinksInputClient(client)
client.Setting = newSettingClient(client)
client.Snapshot = newSnapshotClient(client)
client.SnapshotBackupInput = newSnapshotBackupInputClient(client)
client.StateTransition = newStateTransitionClient(client)
client.StatsAccess = newStatsAccessClient(client)
client.StoragePool = newStoragePoolClient(client)
client.Subscribe = newSubscribeClient(client)
client.Task = newTaskClient(client)
client.TaskInstance = newTaskInstanceClient(client)
client.ToServiceUpgradeStrategy = newToServiceUpgradeStrategyClient(client)
client.TypeDocumentation = newTypeDocumentationClient(client)
client.VirtualMachine = newVirtualMachineClient(client)
client.VirtualMachineDisk = newVirtualMachineDiskClient(client)
client.Volume = newVolumeClient(client)
client.VolumeSnapshotInput = newVolumeSnapshotInputClient(client)
return client
}
func NewRancherClient(opts *ClientOpts) (*RancherClient, error) {
client := constructClient()
err := setupRancherBaseClient(&client.RancherBaseClient, opts)
if err != nil {
return nil, err
}
return client, nil
}

View File

@ -0,0 +1,223 @@
package client
const (
CLUSTER_TYPE = "cluster"
)
type Cluster struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
AgentState string `json:"agentState,omitempty" yaml:"agent_state,omitempty"`
ApiProxy string `json:"apiProxy,omitempty" yaml:"api_proxy,omitempty"`
ComputeTotal int64 `json:"computeTotal,omitempty" yaml:"compute_total,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"`
DiscoverySpec string `json:"discoverySpec,omitempty" yaml:"discovery_spec,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
Info interface{} `json:"info,omitempty" yaml:"info,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PhysicalHostId string `json:"physicalHostId,omitempty" yaml:"physical_host_id,omitempty"`
Port int64 `json:"port,omitempty" yaml:"port,omitempty"`
PublicEndpoints []interface{} `json:"publicEndpoints,omitempty" yaml:"public_endpoints,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ClusterCollection struct {
Collection
Data []Cluster `json:"data,omitempty"`
}
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) (*Host, error)
ActionAddhost(*Cluster, *AddRemoveClusterHostInput) (*Cluster, error)
ActionCreate(*Cluster) (*Host, error)
ActionDeactivate(*Cluster) (*Host, error)
ActionDockersocket(*Cluster) (*HostAccess, error)
ActionPurge(*Cluster) (*Host, error)
ActionRemove(*Cluster) (*Host, error)
ActionRemovehost(*Cluster, *AddRemoveClusterHostInput) (*Cluster, error)
ActionRestore(*Cluster) (*Host, error)
ActionUpdate(*Cluster) (*Host, 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)
return resp, err
}
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) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionAddhost(resource *Cluster, input *AddRemoveClusterHostInput) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "addhost", &resource.Resource, input, resp)
return resp, err
}
func (c *ClusterClient) ActionCreate(resource *Cluster) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionDeactivate(resource *Cluster) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionDockersocket(resource *Cluster) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "dockersocket", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionPurge(resource *Cluster) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "purge", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionRemove(resource *Cluster) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionRemovehost(resource *Cluster, input *AddRemoveClusterHostInput) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "removehost", &resource.Resource, input, resp)
return resp, err
}
func (c *ClusterClient) ActionRestore(resource *Cluster) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "restore", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionUpdate(resource *Cluster) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,69 @@
package client
const (
COMPOSE_CONFIG_TYPE = "composeConfig"
)
type ComposeConfig struct {
Resource
DockerComposeConfig string `json:"dockerComposeConfig,omitempty" yaml:"docker_compose_config,omitempty"`
RancherComposeConfig string `json:"rancherComposeConfig,omitempty" yaml:"rancher_compose_config,omitempty"`
}
type ComposeConfigCollection struct {
Collection
Data []ComposeConfig `json:"data,omitempty"`
}
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)
return resp, err
}
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

@ -0,0 +1,67 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,180 @@
package client
const (
COMPOSE_PROJECT_TYPE = "composeProject"
)
type ComposeProject struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_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"`
Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PreviousEnvironment map[string]interface{} `json:"previousEnvironment,omitempty" yaml:"previous_environment,omitempty"`
PreviousExternalId string `json:"previousExternalId,omitempty" yaml:"previous_external_id,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"`
Templates map[string]interface{} `json:"templates,omitempty" yaml:"templates,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ComposeProjectCollection struct {
Collection
Data []ComposeProject `json:"data,omitempty"`
}
type ComposeProjectClient struct {
rancherClient *RancherClient
}
type ComposeProjectOperations interface {
List(opts *ListOpts) (*ComposeProjectCollection, error)
Create(opts *ComposeProject) (*ComposeProject, error)
Update(existing *ComposeProject, updates interface{}) (*ComposeProject, error)
ById(id string) (*ComposeProject, error)
Delete(container *ComposeProject) error
ActionCancelrollback(*ComposeProject) (*Environment, error)
ActionCancelupgrade(*ComposeProject) (*Environment, error)
ActionCreate(*ComposeProject) (*Environment, error)
ActionError(*ComposeProject) (*Environment, error)
ActionFinishupgrade(*ComposeProject) (*Environment, error)
ActionRemove(*ComposeProject) (*Environment, error)
ActionRollback(*ComposeProject) (*Environment, error)
}
func newComposeProjectClient(rancherClient *RancherClient) *ComposeProjectClient {
return &ComposeProjectClient{
rancherClient: rancherClient,
}
}
func (c *ComposeProjectClient) Create(container *ComposeProject) (*ComposeProject, error) {
resp := &ComposeProject{}
err := c.rancherClient.doCreate(COMPOSE_PROJECT_TYPE, container, resp)
return resp, err
}
func (c *ComposeProjectClient) Update(existing *ComposeProject, updates interface{}) (*ComposeProject, error) {
resp := &ComposeProject{}
err := c.rancherClient.doUpdate(COMPOSE_PROJECT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ComposeProjectClient) List(opts *ListOpts) (*ComposeProjectCollection, error) {
resp := &ComposeProjectCollection{}
err := c.rancherClient.doList(COMPOSE_PROJECT_TYPE, opts, resp)
return resp, err
}
func (c *ComposeProjectClient) ById(id string) (*ComposeProject, error) {
resp := &ComposeProject{}
err := c.rancherClient.doById(COMPOSE_PROJECT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ComposeProjectClient) Delete(container *ComposeProject) error {
return c.rancherClient.doResourceDelete(COMPOSE_PROJECT_TYPE, &container.Resource)
}
func (c *ComposeProjectClient) ActionCancelrollback(resource *ComposeProject) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "cancelrollback", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeProjectClient) ActionCancelupgrade(resource *ComposeProject) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeProjectClient) ActionCreate(resource *ComposeProject) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeProjectClient) ActionError(resource *ComposeProject) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeProjectClient) ActionFinishupgrade(resource *ComposeProject) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "finishupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeProjectClient) ActionRemove(resource *ComposeProject) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeProjectClient) ActionRollback(resource *ComposeProject) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "rollback", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,194 @@
package client
const (
COMPOSE_SERVICE_TYPE = "composeService"
)
type ComposeService struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
CurrentScale int64 `json:"currentScale,omitempty" yaml:"current_scale,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,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"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PublicEndpoints []interface{} `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
Scale int64 `json:"scale,omitempty" yaml:"scale,omitempty"`
ScalePolicy *ScalePolicy `json:"scalePolicy,omitempty" yaml:"scale_policy,omitempty"`
SelectorContainer string `json:"selectorContainer,omitempty" yaml:"selector_container,omitempty"`
SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"`
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
Vip string `json:"vip,omitempty" yaml:"vip,omitempty"`
}
type ComposeServiceCollection struct {
Collection
Data []ComposeService `json:"data,omitempty"`
}
type ComposeServiceClient struct {
rancherClient *RancherClient
}
type ComposeServiceOperations interface {
List(opts *ListOpts) (*ComposeServiceCollection, error)
Create(opts *ComposeService) (*ComposeService, error)
Update(existing *ComposeService, updates interface{}) (*ComposeService, error)
ById(id string) (*ComposeService, error)
Delete(container *ComposeService) error
ActionActivate(*ComposeService) (*Service, error)
ActionCancelrollback(*ComposeService) (*Service, error)
ActionCancelupgrade(*ComposeService) (*Service, error)
ActionCreate(*ComposeService) (*Service, error)
ActionFinishupgrade(*ComposeService) (*Service, error)
ActionRemove(*ComposeService) (*Service, error)
ActionRollback(*ComposeService) (*Service, error)
}
func newComposeServiceClient(rancherClient *RancherClient) *ComposeServiceClient {
return &ComposeServiceClient{
rancherClient: rancherClient,
}
}
func (c *ComposeServiceClient) Create(container *ComposeService) (*ComposeService, error) {
resp := &ComposeService{}
err := c.rancherClient.doCreate(COMPOSE_SERVICE_TYPE, container, resp)
return resp, err
}
func (c *ComposeServiceClient) Update(existing *ComposeService, updates interface{}) (*ComposeService, error) {
resp := &ComposeService{}
err := c.rancherClient.doUpdate(COMPOSE_SERVICE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ComposeServiceClient) List(opts *ListOpts) (*ComposeServiceCollection, error) {
resp := &ComposeServiceCollection{}
err := c.rancherClient.doList(COMPOSE_SERVICE_TYPE, opts, resp)
return resp, err
}
func (c *ComposeServiceClient) ById(id string) (*ComposeService, error) {
resp := &ComposeService{}
err := c.rancherClient.doById(COMPOSE_SERVICE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ComposeServiceClient) Delete(container *ComposeService) error {
return c.rancherClient.doResourceDelete(COMPOSE_SERVICE_TYPE, &container.Resource)
}
func (c *ComposeServiceClient) ActionActivate(resource *ComposeService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeServiceClient) ActionCancelrollback(resource *ComposeService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "cancelrollback", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeServiceClient) ActionCancelupgrade(resource *ComposeService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeServiceClient) ActionCreate(resource *ComposeService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeServiceClient) ActionFinishupgrade(resource *ComposeService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeServiceClient) ActionRemove(resource *ComposeService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ComposeServiceClient) ActionRollback(resource *ComposeService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,69 @@
package client
const (
CONFIG_ITEM_TYPE = "configItem"
)
type ConfigItem struct {
Resource
Name string `json:"name,omitempty" yaml:"name,omitempty"`
SourceVersion string `json:"sourceVersion,omitempty" yaml:"source_version,omitempty"`
}
type ConfigItemCollection struct {
Collection
Data []ConfigItem `json:"data,omitempty"`
}
type ConfigItemClient struct {
rancherClient *RancherClient
}
type ConfigItemOperations interface {
List(opts *ListOpts) (*ConfigItemCollection, error)
Create(opts *ConfigItem) (*ConfigItem, error)
Update(existing *ConfigItem, updates interface{}) (*ConfigItem, error)
ById(id string) (*ConfigItem, error)
Delete(container *ConfigItem) error
}
func newConfigItemClient(rancherClient *RancherClient) *ConfigItemClient {
return &ConfigItemClient{
rancherClient: rancherClient,
}
}
func (c *ConfigItemClient) Create(container *ConfigItem) (*ConfigItem, error) {
resp := &ConfigItem{}
err := c.rancherClient.doCreate(CONFIG_ITEM_TYPE, container, resp)
return resp, err
}
func (c *ConfigItemClient) Update(existing *ConfigItem, updates interface{}) (*ConfigItem, error) {
resp := &ConfigItem{}
err := c.rancherClient.doUpdate(CONFIG_ITEM_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ConfigItemClient) List(opts *ListOpts) (*ConfigItemCollection, error) {
resp := &ConfigItemCollection{}
err := c.rancherClient.doList(CONFIG_ITEM_TYPE, opts, resp)
return resp, err
}
func (c *ConfigItemClient) ById(id string) (*ConfigItem, error) {
resp := &ConfigItem{}
err := c.rancherClient.doById(CONFIG_ITEM_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ConfigItemClient) Delete(container *ConfigItem) error {
return c.rancherClient.doResourceDelete(CONFIG_ITEM_TYPE, &container.Resource)
}

View File

@ -0,0 +1,81 @@
package client
const (
CONFIG_ITEM_STATUS_TYPE = "configItemStatus"
)
type ConfigItemStatus struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
AppliedUpdated string `json:"appliedUpdated,omitempty" yaml:"applied_updated,omitempty"`
AppliedVersion int64 `json:"appliedVersion,omitempty" yaml:"applied_version,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
RequestedUpdated string `json:"requestedUpdated,omitempty" yaml:"requested_updated,omitempty"`
RequestedVersion int64 `json:"requestedVersion,omitempty" yaml:"requested_version,omitempty"`
SourceVersion string `json:"sourceVersion,omitempty" yaml:"source_version,omitempty"`
}
type ConfigItemStatusCollection struct {
Collection
Data []ConfigItemStatus `json:"data,omitempty"`
}
type ConfigItemStatusClient struct {
rancherClient *RancherClient
}
type ConfigItemStatusOperations interface {
List(opts *ListOpts) (*ConfigItemStatusCollection, error)
Create(opts *ConfigItemStatus) (*ConfigItemStatus, error)
Update(existing *ConfigItemStatus, updates interface{}) (*ConfigItemStatus, error)
ById(id string) (*ConfigItemStatus, error)
Delete(container *ConfigItemStatus) error
}
func newConfigItemStatusClient(rancherClient *RancherClient) *ConfigItemStatusClient {
return &ConfigItemStatusClient{
rancherClient: rancherClient,
}
}
func (c *ConfigItemStatusClient) Create(container *ConfigItemStatus) (*ConfigItemStatus, error) {
resp := &ConfigItemStatus{}
err := c.rancherClient.doCreate(CONFIG_ITEM_STATUS_TYPE, container, resp)
return resp, err
}
func (c *ConfigItemStatusClient) Update(existing *ConfigItemStatus, updates interface{}) (*ConfigItemStatus, error) {
resp := &ConfigItemStatus{}
err := c.rancherClient.doUpdate(CONFIG_ITEM_STATUS_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ConfigItemStatusClient) List(opts *ListOpts) (*ConfigItemStatusCollection, error) {
resp := &ConfigItemStatusCollection{}
err := c.rancherClient.doList(CONFIG_ITEM_STATUS_TYPE, opts, resp)
return resp, err
}
func (c *ConfigItemStatusClient) ById(id string) (*ConfigItemStatus, error) {
resp := &ConfigItemStatus{}
err := c.rancherClient.doById(CONFIG_ITEM_STATUS_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ConfigItemStatusClient) Delete(container *ConfigItemStatus) error {
return c.rancherClient.doResourceDelete(CONFIG_ITEM_STATUS_TYPE, &container.Resource)
}

View File

@ -0,0 +1,431 @@
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"`
AllocationState string `json:"allocationState,omitempty" yaml:"allocation_state,omitempty"`
BlkioDeviceOptions map[string]interface{} `json:"blkioDeviceOptions,omitempty" yaml:"blkio_device_options,omitempty"`
Build *DockerBuild `json:"build,omitempty" yaml:"build,omitempty"`
CapAdd []string `json:"capAdd,omitempty" yaml:"cap_add,omitempty"`
CapDrop []string `json:"capDrop,omitempty" yaml:"cap_drop,omitempty"`
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
Count int64 `json:"count,omitempty" yaml:"count,omitempty"`
CpuSet string `json:"cpuSet,omitempty" yaml:"cpu_set,omitempty"`
CpuShares int64 `json:"cpuShares,omitempty" yaml:"cpu_shares,omitempty"`
CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,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"`
DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Devices []string `json:"devices,omitempty" yaml:"devices,omitempty"`
Dns []string `json:"dns,omitempty" yaml:"dns,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]interface{} `json:"environment,omitempty" yaml:"environment,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"`
HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"`
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"`
InstanceLinks map[string]interface{} `json:"instanceLinks,omitempty" yaml:"instance_links,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"`
LogConfig *LogConfig `json:"logConfig,omitempty" yaml:"log_config,omitempty"`
LxcConf map[string]interface{} `json:"lxcConf,omitempty" yaml:"lxc_conf,omitempty"`
Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"`
MemorySwap int64 `json:"memorySwap,omitempty" yaml:"memory_swap,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NativeContainer bool `json:"nativeContainer,omitempty" yaml:"native_container,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"`
PidMode string `json:"pidMode,omitempty" yaml:"pid_mode,omitempty"`
Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"`
PrimaryIpAddress string `json:"primaryIpAddress,omitempty" yaml:"primary_ip_address,omitempty"`
Privileged bool `json:"privileged,omitempty" yaml:"privileged,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"`
RestartPolicy *RestartPolicy `json:"restartPolicy,omitempty" yaml:"restart_policy,omitempty"`
SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"`
StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"`
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
StdinOpen bool `json:"stdinOpen,omitempty" yaml:"stdin_open,omitempty"`
SystemContainer string `json:"systemContainer,omitempty" yaml:"system_container,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"`
User string `json:"user,omitempty" yaml:"user,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"`
}
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
ActionAllocate(*Container) (*Instance, error)
ActionConsole(*Container, *InstanceConsoleInput) (*InstanceConsole, error)
ActionCreate(*Container) (*Instance, error)
ActionDeallocate(*Container) (*Instance, error)
ActionError(*Container) (*Instance, error)
ActionExecute(*Container, *ContainerExec) (*HostAccess, error)
ActionLogs(*Container, *ContainerLogs) (*HostAccess, error)
ActionMigrate(*Container) (*Instance, error)
ActionProxy(*Container, *ContainerProxy) (*HostAccess, error)
ActionPurge(*Container) (*Instance, error)
ActionRemove(*Container) (*Instance, error)
ActionRestart(*Container) (*Instance, error)
ActionRestore(*Container) (*Instance, error)
ActionSetlabels(*Container, *SetLabelsInput) (*Container, error)
ActionStart(*Container) (*Instance, error)
ActionStop(*Container, *InstanceStop) (*Instance, error)
ActionUpdate(*Container) (*Instance, error)
ActionUpdatehealthy(*Container) (*Instance, error)
ActionUpdatereinitializing(*Container) (*Instance, error)
ActionUpdateunhealthy(*Container) (*Instance, 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)
return resp, err
}
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) ActionAllocate(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "allocate", &resource.Resource, nil, resp)
return resp, err
}
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) ActionCreate(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionDeallocate(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "deallocate", &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) ActionMigrate(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "migrate", &resource.Resource, nil, 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) ActionPurge(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "purge", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionRemove(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "remove", &resource.Resource, nil, 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) ActionRestore(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "restore", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionSetlabels(resource *Container, input *SetLabelsInput) (*Container, error) {
resp := &Container{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "setlabels", &resource.Resource, input, 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) ActionUpdate(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionUpdatehealthy(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "updatehealthy", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionUpdatereinitializing(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "updatereinitializing", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionUpdateunhealthy(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "updateunhealthy", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,117 @@
package client
const (
CONTAINER_EVENT_TYPE = "containerEvent"
)
type ContainerEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
DockerInspect interface{} `json:"dockerInspect,omitempty" yaml:"docker_inspect,omitempty"`
ExternalFrom string `json:"externalFrom,omitempty" yaml:"external_from,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
ExternalStatus string `json:"externalStatus,omitempty" yaml:"external_status,omitempty"`
ExternalTimestamp int64 `json:"externalTimestamp,omitempty" yaml:"external_timestamp,omitempty"`
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ReportedHostUuid string `json:"reportedHostUuid,omitempty" yaml:"reported_host_uuid,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
}
type ContainerEventCollection struct {
Collection
Data []ContainerEvent `json:"data,omitempty"`
}
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
ActionCreate(*ContainerEvent) (*ContainerEvent, error)
ActionRemove(*ContainerEvent) (*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)
return resp, err
}
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)
}
func (c *ContainerEventClient) ActionCreate(resource *ContainerEvent) (*ContainerEvent, error) {
resp := &ContainerEvent{}
err := c.rancherClient.doAction(CONTAINER_EVENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerEventClient) ActionRemove(resource *ContainerEvent) (*ContainerEvent, error) {
resp := &ContainerEvent{}
err := c.rancherClient.doAction(CONTAINER_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,73 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,69 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,69 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,161 @@
package client
const (
CREDENTIAL_TYPE = "credential"
)
type Credential struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_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"`
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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type CredentialCollection struct {
Collection
Data []Credential `json:"data,omitempty"`
}
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)
ActionPurge(*Credential) (*Credential, error)
ActionRemove(*Credential) (*Credential, error)
ActionUpdate(*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)
return resp, err
}
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) ActionPurge(resource *Credential) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "purge", &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
}
func (c *CredentialClient) ActionUpdate(resource *Credential) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,85 @@
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"`
Dateexecuted string `json:"dateexecuted,omitempty" yaml:"dateexecuted,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"`
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,71 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,81 @@
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"`
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
}
type DigitaloceanConfigCollection struct {
Collection
Data []DigitaloceanConfig `json:"data,omitempty"`
}
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)
return resp, err
}
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

@ -0,0 +1,267 @@
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"`
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"`
EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,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"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,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"`
RetainIp bool `json:"retainIp,omitempty" yaml:"retain_ip,omitempty"`
SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"`
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,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"`
}
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)
ActionAddservicelink(*DnsService, *AddRemoveServiceLinkInput) (*Service, error)
ActionCancelrollback(*DnsService) (*Service, error)
ActionCancelupgrade(*DnsService) (*Service, error)
ActionCreate(*DnsService) (*Service, error)
ActionDeactivate(*DnsService) (*Service, error)
ActionFinishupgrade(*DnsService) (*Service, error)
ActionRemove(*DnsService) (*Service, error)
ActionRemoveservicelink(*DnsService, *AddRemoveServiceLinkInput) (*Service, error)
ActionRestart(*DnsService, *ServiceRestart) (*Service, error)
ActionRollback(*DnsService) (*Service, error)
ActionSetservicelinks(*DnsService, *SetServiceLinksInput) (*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)
return resp, err
}
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) ActionAddservicelink(resource *DnsService, input *AddRemoveServiceLinkInput) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "addservicelink", &resource.Resource, input, resp)
return resp, err
}
func (c *DnsServiceClient) ActionCancelrollback(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "cancelrollback", &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) 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) 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) ActionRemoveservicelink(resource *DnsService, input *AddRemoveServiceLinkInput) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "removeservicelink", &resource.Resource, input, resp)
return resp, err
}
func (c *DnsServiceClient) ActionRestart(resource *DnsService, input *ServiceRestart) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "restart", &resource.Resource, input, resp)
return resp, err
}
func (c *DnsServiceClient) ActionRollback(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionSetservicelinks(resource *DnsService, input *SetServiceLinksInput) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "setservicelinks", &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

@ -0,0 +1,77 @@
package client
const (
DOCKER_BUILD_TYPE = "dockerBuild"
)
type DockerBuild struct {
Resource
Context string `json:"context,omitempty" yaml:"context,omitempty"`
Dockerfile string `json:"dockerfile,omitempty" yaml:"dockerfile,omitempty"`
Forcerm bool `json:"forcerm,omitempty" yaml:"forcerm,omitempty"`
Nocache bool `json:"nocache,omitempty" yaml:"nocache,omitempty"`
Remote string `json:"remote,omitempty" yaml:"remote,omitempty"`
Rm bool `json:"rm,omitempty" yaml:"rm,omitempty"`
}
type DockerBuildCollection struct {
Collection
Data []DockerBuild `json:"data,omitempty"`
}
type DockerBuildClient struct {
rancherClient *RancherClient
}
type DockerBuildOperations interface {
List(opts *ListOpts) (*DockerBuildCollection, error)
Create(opts *DockerBuild) (*DockerBuild, error)
Update(existing *DockerBuild, updates interface{}) (*DockerBuild, error)
ById(id string) (*DockerBuild, error)
Delete(container *DockerBuild) error
}
func newDockerBuildClient(rancherClient *RancherClient) *DockerBuildClient {
return &DockerBuildClient{
rancherClient: rancherClient,
}
}
func (c *DockerBuildClient) Create(container *DockerBuild) (*DockerBuild, error) {
resp := &DockerBuild{}
err := c.rancherClient.doCreate(DOCKER_BUILD_TYPE, container, resp)
return resp, err
}
func (c *DockerBuildClient) Update(existing *DockerBuild, updates interface{}) (*DockerBuild, error) {
resp := &DockerBuild{}
err := c.rancherClient.doUpdate(DOCKER_BUILD_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DockerBuildClient) List(opts *ListOpts) (*DockerBuildCollection, error) {
resp := &DockerBuildCollection{}
err := c.rancherClient.doList(DOCKER_BUILD_TYPE, opts, resp)
return resp, err
}
func (c *DockerBuildClient) ById(id string) (*DockerBuild, error) {
resp := &DockerBuild{}
err := c.rancherClient.doById(DOCKER_BUILD_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DockerBuildClient) Delete(container *DockerBuild) error {
return c.rancherClient.doResourceDelete(DOCKER_BUILD_TYPE, &container.Resource)
}

View File

@ -0,0 +1,117 @@
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"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type DynamicSchemaCollection struct {
Collection
Data []DynamicSchema `json:"data,omitempty"`
}
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)
return resp, err
}
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

@ -0,0 +1,252 @@
package client
const (
ENVIRONMENT_TYPE = "environment"
)
type Environment struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_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"`
DockerCompose string `json:"dockerCompose,omitempty" yaml:"docker_compose,omitempty"`
Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Outputs map[string]interface{} `json:"outputs,omitempty" yaml:"outputs,omitempty"`
PreviousEnvironment map[string]interface{} `json:"previousEnvironment,omitempty" yaml:"previous_environment,omitempty"`
PreviousExternalId string `json:"previousExternalId,omitempty" yaml:"previous_external_id,omitempty"`
RancherCompose string `json:"rancherCompose,omitempty" yaml:"rancher_compose,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type EnvironmentCollection struct {
Collection
Data []Environment `json:"data,omitempty"`
}
type EnvironmentClient struct {
rancherClient *RancherClient
}
type EnvironmentOperations interface {
List(opts *ListOpts) (*EnvironmentCollection, error)
Create(opts *Environment) (*Environment, error)
Update(existing *Environment, updates interface{}) (*Environment, error)
ById(id string) (*Environment, error)
Delete(container *Environment) error
ActionActivateservices(*Environment) (*Environment, error)
ActionAddoutputs(*Environment, *AddOutputsInput) (*Environment, error)
ActionCancelrollback(*Environment) (*Environment, error)
ActionCancelupgrade(*Environment) (*Environment, error)
ActionCreate(*Environment) (*Environment, error)
ActionDeactivateservices(*Environment) (*Environment, error)
ActionError(*Environment) (*Environment, error)
ActionExportconfig(*Environment, *ComposeConfigInput) (*ComposeConfig, error)
ActionFinishupgrade(*Environment) (*Environment, error)
ActionRemove(*Environment) (*Environment, error)
ActionRollback(*Environment) (*Environment, error)
ActionUpdate(*Environment) (*Environment, error)
ActionUpgrade(*Environment, *EnvironmentUpgrade) (*Environment, error)
}
func newEnvironmentClient(rancherClient *RancherClient) *EnvironmentClient {
return &EnvironmentClient{
rancherClient: rancherClient,
}
}
func (c *EnvironmentClient) Create(container *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doCreate(ENVIRONMENT_TYPE, container, resp)
return resp, err
}
func (c *EnvironmentClient) Update(existing *Environment, updates interface{}) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doUpdate(ENVIRONMENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *EnvironmentClient) List(opts *ListOpts) (*EnvironmentCollection, error) {
resp := &EnvironmentCollection{}
err := c.rancherClient.doList(ENVIRONMENT_TYPE, opts, resp)
return resp, err
}
func (c *EnvironmentClient) ById(id string) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doById(ENVIRONMENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *EnvironmentClient) Delete(container *Environment) error {
return c.rancherClient.doResourceDelete(ENVIRONMENT_TYPE, &container.Resource)
}
func (c *EnvironmentClient) ActionActivateservices(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "activateservices", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionAddoutputs(resource *Environment, input *AddOutputsInput) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "addoutputs", &resource.Resource, input, resp)
return resp, err
}
func (c *EnvironmentClient) ActionCancelrollback(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "cancelrollback", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionCancelupgrade(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionCreate(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionDeactivateservices(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "deactivateservices", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionError(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionExportconfig(resource *Environment, input *ComposeConfigInput) (*ComposeConfig, error) {
resp := &ComposeConfig{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "exportconfig", &resource.Resource, input, resp)
return resp, err
}
func (c *EnvironmentClient) ActionFinishupgrade(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "finishupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionRemove(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionRollback(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "rollback", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionUpdate(resource *Environment) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}
func (c *EnvironmentClient) ActionUpgrade(resource *Environment, input *EnvironmentUpgrade) (*Environment, error) {
resp := &Environment{}
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "upgrade", &resource.Resource, input, resp)
return resp, err
}

View File

@ -0,0 +1,73 @@
package client
const (
ENVIRONMENT_UPGRADE_TYPE = "environmentUpgrade"
)
type EnvironmentUpgrade struct {
Resource
DockerCompose string `json:"dockerCompose,omitempty" yaml:"docker_compose,omitempty"`
Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
RancherCompose string `json:"rancherCompose,omitempty" yaml:"rancher_compose,omitempty"`
}
type EnvironmentUpgradeCollection struct {
Collection
Data []EnvironmentUpgrade `json:"data,omitempty"`
}
type EnvironmentUpgradeClient struct {
rancherClient *RancherClient
}
type EnvironmentUpgradeOperations interface {
List(opts *ListOpts) (*EnvironmentUpgradeCollection, error)
Create(opts *EnvironmentUpgrade) (*EnvironmentUpgrade, error)
Update(existing *EnvironmentUpgrade, updates interface{}) (*EnvironmentUpgrade, error)
ById(id string) (*EnvironmentUpgrade, error)
Delete(container *EnvironmentUpgrade) error
}
func newEnvironmentUpgradeClient(rancherClient *RancherClient) *EnvironmentUpgradeClient {
return &EnvironmentUpgradeClient{
rancherClient: rancherClient,
}
}
func (c *EnvironmentUpgradeClient) Create(container *EnvironmentUpgrade) (*EnvironmentUpgrade, error) {
resp := &EnvironmentUpgrade{}
err := c.rancherClient.doCreate(ENVIRONMENT_UPGRADE_TYPE, container, resp)
return resp, err
}
func (c *EnvironmentUpgradeClient) Update(existing *EnvironmentUpgrade, updates interface{}) (*EnvironmentUpgrade, error) {
resp := &EnvironmentUpgrade{}
err := c.rancherClient.doUpdate(ENVIRONMENT_UPGRADE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *EnvironmentUpgradeClient) List(opts *ListOpts) (*EnvironmentUpgradeCollection, error) {
resp := &EnvironmentUpgradeCollection{}
err := c.rancherClient.doList(ENVIRONMENT_UPGRADE_TYPE, opts, resp)
return resp, err
}
func (c *EnvironmentUpgradeClient) ById(id string) (*EnvironmentUpgrade, error) {
resp := &EnvironmentUpgrade{}
err := c.rancherClient.doById(ENVIRONMENT_UPGRADE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *EnvironmentUpgradeClient) Delete(container *EnvironmentUpgrade) error {
return c.rancherClient.doResourceDelete(ENVIRONMENT_UPGRADE_TYPE, &container.Resource)
}

View File

@ -0,0 +1,81 @@
package client
const (
EXOSCALE_CONFIG_TYPE = "exoscaleConfig"
)
type ExoscaleConfig struct {
Resource
ApiKey string `json:"apiKey,omitempty" yaml:"api_key,omitempty"`
ApiSecretKey string `json:"apiSecretKey,omitempty" yaml:"api_secret_key,omitempty"`
AvailabilityZone string `json:"availabilityZone,omitempty" yaml:"availability_zone,omitempty"`
DiskSize string `json:"diskSize,omitempty" yaml:"disk_size,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
InstanceProfile string `json:"instanceProfile,omitempty" yaml:"instance_profile,omitempty"`
SecurityGroup []string `json:"securityGroup,omitempty" yaml:"security_group,omitempty"`
Url string `json:"url,omitempty" yaml:"url,omitempty"`
}
type ExoscaleConfigCollection struct {
Collection
Data []ExoscaleConfig `json:"data,omitempty"`
}
type ExoscaleConfigClient struct {
rancherClient *RancherClient
}
type ExoscaleConfigOperations interface {
List(opts *ListOpts) (*ExoscaleConfigCollection, error)
Create(opts *ExoscaleConfig) (*ExoscaleConfig, error)
Update(existing *ExoscaleConfig, updates interface{}) (*ExoscaleConfig, error)
ById(id string) (*ExoscaleConfig, error)
Delete(container *ExoscaleConfig) error
}
func newExoscaleConfigClient(rancherClient *RancherClient) *ExoscaleConfigClient {
return &ExoscaleConfigClient{
rancherClient: rancherClient,
}
}
func (c *ExoscaleConfigClient) Create(container *ExoscaleConfig) (*ExoscaleConfig, error) {
resp := &ExoscaleConfig{}
err := c.rancherClient.doCreate(EXOSCALE_CONFIG_TYPE, container, resp)
return resp, err
}
func (c *ExoscaleConfigClient) Update(existing *ExoscaleConfig, updates interface{}) (*ExoscaleConfig, error) {
resp := &ExoscaleConfig{}
err := c.rancherClient.doUpdate(EXOSCALE_CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExoscaleConfigClient) List(opts *ListOpts) (*ExoscaleConfigCollection, error) {
resp := &ExoscaleConfigCollection{}
err := c.rancherClient.doList(EXOSCALE_CONFIG_TYPE, opts, resp)
return resp, err
}
func (c *ExoscaleConfigClient) ById(id string) (*ExoscaleConfig, error) {
resp := &ExoscaleConfig{}
err := c.rancherClient.doById(EXOSCALE_CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExoscaleConfigClient) Delete(container *ExoscaleConfig) error {
return c.rancherClient.doResourceDelete(EXOSCALE_CONFIG_TYPE, &container.Resource)
}

View File

@ -0,0 +1,71 @@
package client
const (
EXTENSION_IMPLEMENTATION_TYPE = "extensionImplementation"
)
type ExtensionImplementation struct {
Resource
ClassName string `json:"className,omitempty" yaml:"class_name,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty" yaml:"properties,omitempty"`
}
type ExtensionImplementationCollection struct {
Collection
Data []ExtensionImplementation `json:"data,omitempty"`
}
type ExtensionImplementationClient struct {
rancherClient *RancherClient
}
type ExtensionImplementationOperations interface {
List(opts *ListOpts) (*ExtensionImplementationCollection, error)
Create(opts *ExtensionImplementation) (*ExtensionImplementation, error)
Update(existing *ExtensionImplementation, updates interface{}) (*ExtensionImplementation, error)
ById(id string) (*ExtensionImplementation, error)
Delete(container *ExtensionImplementation) error
}
func newExtensionImplementationClient(rancherClient *RancherClient) *ExtensionImplementationClient {
return &ExtensionImplementationClient{
rancherClient: rancherClient,
}
}
func (c *ExtensionImplementationClient) Create(container *ExtensionImplementation) (*ExtensionImplementation, error) {
resp := &ExtensionImplementation{}
err := c.rancherClient.doCreate(EXTENSION_IMPLEMENTATION_TYPE, container, resp)
return resp, err
}
func (c *ExtensionImplementationClient) Update(existing *ExtensionImplementation, updates interface{}) (*ExtensionImplementation, error) {
resp := &ExtensionImplementation{}
err := c.rancherClient.doUpdate(EXTENSION_IMPLEMENTATION_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExtensionImplementationClient) List(opts *ListOpts) (*ExtensionImplementationCollection, error) {
resp := &ExtensionImplementationCollection{}
err := c.rancherClient.doList(EXTENSION_IMPLEMENTATION_TYPE, opts, resp)
return resp, err
}
func (c *ExtensionImplementationClient) ById(id string) (*ExtensionImplementation, error) {
resp := &ExtensionImplementation{}
err := c.rancherClient.doById(EXTENSION_IMPLEMENTATION_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExtensionImplementationClient) Delete(container *ExtensionImplementation) error {
return c.rancherClient.doResourceDelete(EXTENSION_IMPLEMENTATION_TYPE, &container.Resource)
}

View File

@ -0,0 +1,75 @@
package client
const (
EXTENSION_POINT_TYPE = "extensionPoint"
)
type ExtensionPoint struct {
Resource
ExcludeSetting string `json:"excludeSetting,omitempty" yaml:"exclude_setting,omitempty"`
Implementations []interface{} `json:"implementations,omitempty" yaml:"implementations,omitempty"`
IncludeSetting string `json:"includeSetting,omitempty" yaml:"include_setting,omitempty"`
ListSetting string `json:"listSetting,omitempty" yaml:"list_setting,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
}
type ExtensionPointCollection struct {
Collection
Data []ExtensionPoint `json:"data,omitempty"`
}
type ExtensionPointClient struct {
rancherClient *RancherClient
}
type ExtensionPointOperations interface {
List(opts *ListOpts) (*ExtensionPointCollection, error)
Create(opts *ExtensionPoint) (*ExtensionPoint, error)
Update(existing *ExtensionPoint, updates interface{}) (*ExtensionPoint, error)
ById(id string) (*ExtensionPoint, error)
Delete(container *ExtensionPoint) error
}
func newExtensionPointClient(rancherClient *RancherClient) *ExtensionPointClient {
return &ExtensionPointClient{
rancherClient: rancherClient,
}
}
func (c *ExtensionPointClient) Create(container *ExtensionPoint) (*ExtensionPoint, error) {
resp := &ExtensionPoint{}
err := c.rancherClient.doCreate(EXTENSION_POINT_TYPE, container, resp)
return resp, err
}
func (c *ExtensionPointClient) Update(existing *ExtensionPoint, updates interface{}) (*ExtensionPoint, error) {
resp := &ExtensionPoint{}
err := c.rancherClient.doUpdate(EXTENSION_POINT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExtensionPointClient) List(opts *ListOpts) (*ExtensionPointCollection, error) {
resp := &ExtensionPointCollection{}
err := c.rancherClient.doList(EXTENSION_POINT_TYPE, opts, resp)
return resp, err
}
func (c *ExtensionPointClient) ById(id string) (*ExtensionPoint, error) {
resp := &ExtensionPoint{}
err := c.rancherClient.doById(EXTENSION_POINT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExtensionPointClient) Delete(container *ExtensionPoint) error {
return c.rancherClient.doResourceDelete(EXTENSION_POINT_TYPE, &container.Resource)
}

View File

@ -0,0 +1,117 @@
package client
const (
EXTERNAL_DNS_EVENT_TYPE = "externalDnsEvent"
)
type ExternalDnsEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,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"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalDnsEventCollection struct {
Collection
Data []ExternalDnsEvent `json:"data,omitempty"`
}
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
ActionCreate(*ExternalDnsEvent) (*ExternalEvent, error)
ActionRemove(*ExternalDnsEvent) (*ExternalEvent, 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)
return resp, err
}
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)
}
func (c *ExternalDnsEventClient) ActionCreate(resource *ExternalDnsEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_DNS_EVENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalDnsEventClient) ActionRemove(resource *ExternalDnsEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_DNS_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,111 @@
package client
const (
EXTERNAL_EVENT_TYPE = "externalEvent"
)
type ExternalEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,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"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalEventCollection struct {
Collection
Data []ExternalEvent `json:"data,omitempty"`
}
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
ActionCreate(*ExternalEvent) (*ExternalEvent, error)
ActionRemove(*ExternalEvent) (*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)
return resp, err
}
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)
}
func (c *ExternalEventClient) ActionCreate(resource *ExternalEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_EVENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalEventClient) ActionRemove(resource *ExternalEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,174 @@
package client
const (
EXTERNAL_HANDLER_TYPE = "externalHandler"
)
type ExternalHandler struct {
Resource
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"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Priority int64 `json:"priority,omitempty" yaml:"priority,omitempty"`
ProcessConfigs []interface{} `json:"processConfigs,omitempty" yaml:"process_configs,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
Retries int64 `json:"retries,omitempty" yaml:"retries,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
TimeoutMillis int64 `json:"timeoutMillis,omitempty" yaml:"timeout_millis,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalHandlerCollection struct {
Collection
Data []ExternalHandler `json:"data,omitempty"`
}
type ExternalHandlerClient struct {
rancherClient *RancherClient
}
type ExternalHandlerOperations interface {
List(opts *ListOpts) (*ExternalHandlerCollection, error)
Create(opts *ExternalHandler) (*ExternalHandler, error)
Update(existing *ExternalHandler, updates interface{}) (*ExternalHandler, error)
ById(id string) (*ExternalHandler, error)
Delete(container *ExternalHandler) error
ActionActivate(*ExternalHandler) (*ExternalHandler, error)
ActionCreate(*ExternalHandler) (*ExternalHandler, error)
ActionDeactivate(*ExternalHandler) (*ExternalHandler, error)
ActionPurge(*ExternalHandler) (*ExternalHandler, error)
ActionRemove(*ExternalHandler) (*ExternalHandler, error)
ActionRestore(*ExternalHandler) (*ExternalHandler, error)
ActionUpdate(*ExternalHandler) (*ExternalHandler, error)
}
func newExternalHandlerClient(rancherClient *RancherClient) *ExternalHandlerClient {
return &ExternalHandlerClient{
rancherClient: rancherClient,
}
}
func (c *ExternalHandlerClient) Create(container *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_TYPE, container, resp)
return resp, err
}
func (c *ExternalHandlerClient) Update(existing *ExternalHandler, updates interface{}) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalHandlerClient) List(opts *ListOpts) (*ExternalHandlerCollection, error) {
resp := &ExternalHandlerCollection{}
err := c.rancherClient.doList(EXTERNAL_HANDLER_TYPE, opts, resp)
return resp, err
}
func (c *ExternalHandlerClient) ById(id string) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doById(EXTERNAL_HANDLER_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalHandlerClient) Delete(container *ExternalHandler) error {
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_TYPE, &container.Resource)
}
func (c *ExternalHandlerClient) ActionActivate(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionCreate(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionDeactivate(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionPurge(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "purge", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionRemove(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionRestore(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "restore", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionUpdate(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,172 @@
package client
const (
EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE = "externalHandlerExternalHandlerProcessMap"
)
type ExternalHandlerExternalHandlerProcessMap struct {
Resource
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"`
ExternalHandlerId string `json:"externalHandlerId,omitempty" yaml:"external_handler_id,omitempty"`
ExternalHandlerProcessId string `json:"externalHandlerProcessId,omitempty" yaml:"external_handler_process_id,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
OnError string `json:"onError,omitempty" yaml:"on_error,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalHandlerExternalHandlerProcessMapCollection struct {
Collection
Data []ExternalHandlerExternalHandlerProcessMap `json:"data,omitempty"`
}
type ExternalHandlerExternalHandlerProcessMapClient struct {
rancherClient *RancherClient
}
type ExternalHandlerExternalHandlerProcessMapOperations interface {
List(opts *ListOpts) (*ExternalHandlerExternalHandlerProcessMapCollection, error)
Create(opts *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
Update(existing *ExternalHandlerExternalHandlerProcessMap, updates interface{}) (*ExternalHandlerExternalHandlerProcessMap, error)
ById(id string) (*ExternalHandlerExternalHandlerProcessMap, error)
Delete(container *ExternalHandlerExternalHandlerProcessMap) error
ActionActivate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
ActionCreate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
ActionDeactivate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
ActionPurge(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
ActionRemove(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
ActionRestore(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
ActionUpdate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
}
func newExternalHandlerExternalHandlerProcessMapClient(rancherClient *RancherClient) *ExternalHandlerExternalHandlerProcessMapClient {
return &ExternalHandlerExternalHandlerProcessMapClient{
rancherClient: rancherClient,
}
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) Create(container *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, container, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) Update(existing *ExternalHandlerExternalHandlerProcessMap, updates interface{}) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) List(opts *ListOpts) (*ExternalHandlerExternalHandlerProcessMapCollection, error) {
resp := &ExternalHandlerExternalHandlerProcessMapCollection{}
err := c.rancherClient.doList(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, opts, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) ById(id string) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doById(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) Delete(container *ExternalHandlerExternalHandlerProcessMap) error {
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, &container.Resource)
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionActivate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionCreate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionDeactivate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionPurge(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "purge", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionRemove(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionRestore(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "restore", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionUpdate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
resp := &ExternalHandlerExternalHandlerProcessMap{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,166 @@
package client
const (
EXTERNAL_HANDLER_PROCESS_TYPE = "externalHandlerProcess"
)
type ExternalHandlerProcess struct {
Resource
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"`
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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalHandlerProcessCollection struct {
Collection
Data []ExternalHandlerProcess `json:"data,omitempty"`
}
type ExternalHandlerProcessClient struct {
rancherClient *RancherClient
}
type ExternalHandlerProcessOperations interface {
List(opts *ListOpts) (*ExternalHandlerProcessCollection, error)
Create(opts *ExternalHandlerProcess) (*ExternalHandlerProcess, error)
Update(existing *ExternalHandlerProcess, updates interface{}) (*ExternalHandlerProcess, error)
ById(id string) (*ExternalHandlerProcess, error)
Delete(container *ExternalHandlerProcess) error
ActionActivate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
ActionCreate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
ActionDeactivate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
ActionPurge(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
ActionRemove(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
ActionRestore(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
ActionUpdate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
}
func newExternalHandlerProcessClient(rancherClient *RancherClient) *ExternalHandlerProcessClient {
return &ExternalHandlerProcessClient{
rancherClient: rancherClient,
}
}
func (c *ExternalHandlerProcessClient) Create(container *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_PROCESS_TYPE, container, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) Update(existing *ExternalHandlerProcess, updates interface{}) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_PROCESS_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) List(opts *ListOpts) (*ExternalHandlerProcessCollection, error) {
resp := &ExternalHandlerProcessCollection{}
err := c.rancherClient.doList(EXTERNAL_HANDLER_PROCESS_TYPE, opts, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) ById(id string) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doById(EXTERNAL_HANDLER_PROCESS_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalHandlerProcessClient) Delete(container *ExternalHandlerProcess) error {
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_PROCESS_TYPE, &container.Resource)
}
func (c *ExternalHandlerProcessClient) ActionActivate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) ActionCreate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) ActionDeactivate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) ActionPurge(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "purge", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) ActionRemove(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) ActionRestore(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "restore", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerProcessClient) ActionUpdate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
resp := &ExternalHandlerProcess{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,69 @@
package client
const (
EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE = "externalHandlerProcessConfig"
)
type ExternalHandlerProcessConfig struct {
Resource
Name string `json:"name,omitempty" yaml:"name,omitempty"`
OnError string `json:"onError,omitempty" yaml:"on_error,omitempty"`
}
type ExternalHandlerProcessConfigCollection struct {
Collection
Data []ExternalHandlerProcessConfig `json:"data,omitempty"`
}
type ExternalHandlerProcessConfigClient struct {
rancherClient *RancherClient
}
type ExternalHandlerProcessConfigOperations interface {
List(opts *ListOpts) (*ExternalHandlerProcessConfigCollection, error)
Create(opts *ExternalHandlerProcessConfig) (*ExternalHandlerProcessConfig, error)
Update(existing *ExternalHandlerProcessConfig, updates interface{}) (*ExternalHandlerProcessConfig, error)
ById(id string) (*ExternalHandlerProcessConfig, error)
Delete(container *ExternalHandlerProcessConfig) error
}
func newExternalHandlerProcessConfigClient(rancherClient *RancherClient) *ExternalHandlerProcessConfigClient {
return &ExternalHandlerProcessConfigClient{
rancherClient: rancherClient,
}
}
func (c *ExternalHandlerProcessConfigClient) Create(container *ExternalHandlerProcessConfig) (*ExternalHandlerProcessConfig, error) {
resp := &ExternalHandlerProcessConfig{}
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, container, resp)
return resp, err
}
func (c *ExternalHandlerProcessConfigClient) Update(existing *ExternalHandlerProcessConfig, updates interface{}) (*ExternalHandlerProcessConfig, error) {
resp := &ExternalHandlerProcessConfig{}
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalHandlerProcessConfigClient) List(opts *ListOpts) (*ExternalHandlerProcessConfigCollection, error) {
resp := &ExternalHandlerProcessConfigCollection{}
err := c.rancherClient.doList(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, opts, resp)
return resp, err
}
func (c *ExternalHandlerProcessConfigClient) ById(id string) (*ExternalHandlerProcessConfig, error) {
resp := &ExternalHandlerProcessConfig{}
err := c.rancherClient.doById(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalHandlerProcessConfigClient) Delete(container *ExternalHandlerProcessConfig) error {
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, &container.Resource)
}

View File

@ -0,0 +1,117 @@
package client
const (
EXTERNAL_HOST_EVENT_TYPE = "externalHostEvent"
)
type ExternalHostEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,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"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalHostEventCollection struct {
Collection
Data []ExternalHostEvent `json:"data,omitempty"`
}
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
ActionCreate(*ExternalHostEvent) (*ExternalEvent, error)
ActionRemove(*ExternalHostEvent) (*ExternalEvent, 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)
return resp, err
}
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)
}
func (c *ExternalHostEventClient) ActionCreate(resource *ExternalHostEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_HOST_EVENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHostEventClient) ActionRemove(resource *ExternalHostEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_HOST_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,234 @@
package client
const (
EXTERNAL_SERVICE_TYPE = "externalService"
)
type ExternalService struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_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"`
EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,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"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,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"`
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,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"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,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"`
}
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)
ActionCancelrollback(*ExternalService) (*Service, error)
ActionCancelupgrade(*ExternalService) (*Service, error)
ActionCreate(*ExternalService) (*Service, error)
ActionDeactivate(*ExternalService) (*Service, error)
ActionFinishupgrade(*ExternalService) (*Service, error)
ActionRemove(*ExternalService) (*Service, error)
ActionRestart(*ExternalService, *ServiceRestart) (*Service, error)
ActionRollback(*ExternalService) (*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)
return resp, err
}
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) ActionCancelrollback(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "cancelrollback", &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) 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) 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, input *ServiceRestart) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "restart", &resource.Resource, input, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionRollback(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "rollback", &resource.Resource, nil, 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

@ -0,0 +1,115 @@
package client
const (
EXTERNAL_SERVICE_EVENT_TYPE = "externalServiceEvent"
)
type ExternalServiceEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,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"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalServiceEventCollection struct {
Collection
Data []ExternalServiceEvent `json:"data,omitempty"`
}
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
ActionCreate(*ExternalServiceEvent) (*ExternalEvent, error)
ActionRemove(*ExternalServiceEvent) (*ExternalEvent, 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)
return resp, err
}
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)
}
func (c *ExternalServiceEventClient) ActionCreate(resource *ExternalServiceEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_EVENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceEventClient) ActionRemove(resource *ExternalServiceEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,115 @@
package client
const (
EXTERNAL_STORAGE_POOL_EVENT_TYPE = "externalStoragePoolEvent"
)
type ExternalStoragePoolEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
HostUuids []string `json:"hostUuids,omitempty" yaml:"host_uuids,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"`
StoragePool StoragePool `json:"storagePool,omitempty" yaml:"storage_pool,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalStoragePoolEventCollection struct {
Collection
Data []ExternalStoragePoolEvent `json:"data,omitempty"`
}
type ExternalStoragePoolEventClient struct {
rancherClient *RancherClient
}
type ExternalStoragePoolEventOperations interface {
List(opts *ListOpts) (*ExternalStoragePoolEventCollection, error)
Create(opts *ExternalStoragePoolEvent) (*ExternalStoragePoolEvent, error)
Update(existing *ExternalStoragePoolEvent, updates interface{}) (*ExternalStoragePoolEvent, error)
ById(id string) (*ExternalStoragePoolEvent, error)
Delete(container *ExternalStoragePoolEvent) error
ActionCreate(*ExternalStoragePoolEvent) (*ExternalEvent, error)
ActionRemove(*ExternalStoragePoolEvent) (*ExternalEvent, error)
}
func newExternalStoragePoolEventClient(rancherClient *RancherClient) *ExternalStoragePoolEventClient {
return &ExternalStoragePoolEventClient{
rancherClient: rancherClient,
}
}
func (c *ExternalStoragePoolEventClient) Create(container *ExternalStoragePoolEvent) (*ExternalStoragePoolEvent, error) {
resp := &ExternalStoragePoolEvent{}
err := c.rancherClient.doCreate(EXTERNAL_STORAGE_POOL_EVENT_TYPE, container, resp)
return resp, err
}
func (c *ExternalStoragePoolEventClient) Update(existing *ExternalStoragePoolEvent, updates interface{}) (*ExternalStoragePoolEvent, error) {
resp := &ExternalStoragePoolEvent{}
err := c.rancherClient.doUpdate(EXTERNAL_STORAGE_POOL_EVENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalStoragePoolEventClient) List(opts *ListOpts) (*ExternalStoragePoolEventCollection, error) {
resp := &ExternalStoragePoolEventCollection{}
err := c.rancherClient.doList(EXTERNAL_STORAGE_POOL_EVENT_TYPE, opts, resp)
return resp, err
}
func (c *ExternalStoragePoolEventClient) ById(id string) (*ExternalStoragePoolEvent, error) {
resp := &ExternalStoragePoolEvent{}
err := c.rancherClient.doById(EXTERNAL_STORAGE_POOL_EVENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalStoragePoolEventClient) Delete(container *ExternalStoragePoolEvent) error {
return c.rancherClient.doResourceDelete(EXTERNAL_STORAGE_POOL_EVENT_TYPE, &container.Resource)
}
func (c *ExternalStoragePoolEventClient) ActionCreate(resource *ExternalStoragePoolEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_STORAGE_POOL_EVENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalStoragePoolEventClient) ActionRemove(resource *ExternalStoragePoolEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_STORAGE_POOL_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,113 @@
package client
const (
EXTERNAL_VOLUME_EVENT_TYPE = "externalVolumeEvent"
)
type ExternalVolumeEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,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"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
Volume Volume `json:"volume,omitempty" yaml:"volume,omitempty"`
}
type ExternalVolumeEventCollection struct {
Collection
Data []ExternalVolumeEvent `json:"data,omitempty"`
}
type ExternalVolumeEventClient struct {
rancherClient *RancherClient
}
type ExternalVolumeEventOperations interface {
List(opts *ListOpts) (*ExternalVolumeEventCollection, error)
Create(opts *ExternalVolumeEvent) (*ExternalVolumeEvent, error)
Update(existing *ExternalVolumeEvent, updates interface{}) (*ExternalVolumeEvent, error)
ById(id string) (*ExternalVolumeEvent, error)
Delete(container *ExternalVolumeEvent) error
ActionCreate(*ExternalVolumeEvent) (*ExternalEvent, error)
ActionRemove(*ExternalVolumeEvent) (*ExternalEvent, error)
}
func newExternalVolumeEventClient(rancherClient *RancherClient) *ExternalVolumeEventClient {
return &ExternalVolumeEventClient{
rancherClient: rancherClient,
}
}
func (c *ExternalVolumeEventClient) Create(container *ExternalVolumeEvent) (*ExternalVolumeEvent, error) {
resp := &ExternalVolumeEvent{}
err := c.rancherClient.doCreate(EXTERNAL_VOLUME_EVENT_TYPE, container, resp)
return resp, err
}
func (c *ExternalVolumeEventClient) Update(existing *ExternalVolumeEvent, updates interface{}) (*ExternalVolumeEvent, error) {
resp := &ExternalVolumeEvent{}
err := c.rancherClient.doUpdate(EXTERNAL_VOLUME_EVENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalVolumeEventClient) List(opts *ListOpts) (*ExternalVolumeEventCollection, error) {
resp := &ExternalVolumeEventCollection{}
err := c.rancherClient.doList(EXTERNAL_VOLUME_EVENT_TYPE, opts, resp)
return resp, err
}
func (c *ExternalVolumeEventClient) ById(id string) (*ExternalVolumeEvent, error) {
resp := &ExternalVolumeEvent{}
err := c.rancherClient.doById(EXTERNAL_VOLUME_EVENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalVolumeEventClient) Delete(container *ExternalVolumeEvent) error {
return c.rancherClient.doResourceDelete(EXTERNAL_VOLUME_EVENT_TYPE, &container.Resource)
}
func (c *ExternalVolumeEventClient) ActionCreate(resource *ExternalVolumeEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_VOLUME_EVENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalVolumeEventClient) ActionRemove(resource *ExternalVolumeEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doAction(EXTERNAL_VOLUME_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@ -0,0 +1,67 @@
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"`
}
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)
return resp, err
}
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

@ -0,0 +1,81 @@
package client
const (
GITHUBCONFIG_TYPE = "githubconfig"
)
type Githubconfig struct {
Resource
AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"`
AllowedIdentities []interface{} `json:"allowedIdentities,omitempty" yaml:"allowed_identities,omitempty"`
ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"`
ClientSecret string `json:"clientSecret,omitempty" yaml:"client_secret,omitempty"`
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
}
type GithubconfigCollection struct {
Collection
Data []Githubconfig `json:"data,omitempty"`
}
type GithubconfigClient struct {
rancherClient *RancherClient
}
type GithubconfigOperations interface {
List(opts *ListOpts) (*GithubconfigCollection, error)
Create(opts *Githubconfig) (*Githubconfig, error)
Update(existing *Githubconfig, updates interface{}) (*Githubconfig, error)
ById(id string) (*Githubconfig, error)
Delete(container *Githubconfig) error
}
func newGithubconfigClient(rancherClient *RancherClient) *GithubconfigClient {
return &GithubconfigClient{
rancherClient: rancherClient,
}
}
func (c *GithubconfigClient) Create(container *Githubconfig) (*Githubconfig, error) {
resp := &Githubconfig{}
err := c.rancherClient.doCreate(GITHUBCONFIG_TYPE, container, resp)
return resp, err
}
func (c *GithubconfigClient) Update(existing *Githubconfig, updates interface{}) (*Githubconfig, error) {
resp := &Githubconfig{}
err := c.rancherClient.doUpdate(GITHUBCONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *GithubconfigClient) List(opts *ListOpts) (*GithubconfigCollection, error) {
resp := &GithubconfigCollection{}
err := c.rancherClient.doList(GITHUBCONFIG_TYPE, opts, resp)
return resp, err
}
func (c *GithubconfigClient) ById(id string) (*Githubconfig, error) {
resp := &Githubconfig{}
err := c.rancherClient.doById(GITHUBCONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *GithubconfigClient) Delete(container *Githubconfig) error {
return c.rancherClient.doResourceDelete(GITHUBCONFIG_TYPE, &container.Resource)
}

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