diff --git a/cmd/cli.go b/cmd/cli.go index 953249e9..d62bdde3 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -17,6 +17,7 @@ import ( initPkg "github.com/equinix/metal-cli/internal/init" "github.com/equinix/metal-cli/internal/interconnections" "github.com/equinix/metal-cli/internal/ips" + "github.com/equinix/metal-cli/internal/loadbalancers" "github.com/equinix/metal-cli/internal/metros" "github.com/equinix/metal-cli/internal/organizations" "github.com/equinix/metal-cli/internal/os" @@ -99,5 +100,6 @@ func (cli *Cli) RegisterCommands(client *root.Client) { interconnections.NewClient(client, cli.Outputer).NewCommand(), vrf.NewClient(client, cli.Outputer).NewCommand(), virtualcircuit.NewClient(client, cli.Outputer).NewCommand(), + loadbalancers.NewClient(client, cli.Outputer).NewCommand(), ) } diff --git a/docs/metal.md b/docs/metal.md index 73472e66..5b777742 100644 --- a/docs/metal.md +++ b/docs/metal.md @@ -38,6 +38,7 @@ Command line interface for Equinix Metal * [metal init](metal_init.md) - Create a configuration file. * [metal interconnections](metal_interconnections.md) - interconnections operations: create, get, update, delete * [metal ip](metal_ip.md) - IP address, reservations, and assignment operations: assign, unassign, remove, available, request and get. +* [metal loadbalancer-beta](metal_loadbalancer-beta.md) - LoadBalancer BETA operations: create, get, update, and delete. * [metal metros](metal_metros.md) - Metro operations: get. * [metal operating-systems](metal_operating-systems.md) - Operating system operations: get. * [metal organization](metal_organization.md) - Organization operations: create, get, update, payment-methods, and delete. diff --git a/docs/metal_loadbalancer-beta.md b/docs/metal_loadbalancer-beta.md new file mode 100644 index 00000000..31a66ae4 --- /dev/null +++ b/docs/metal_loadbalancer-beta.md @@ -0,0 +1,36 @@ +## metal loadbalancer-beta + +LoadBalancer BETA operations: create, get, update, and delete. + +### Synopsis + +Information and management for LoadBalancers is on https://deploy.equinix.com/developers/docs/metal/networking/load-balancers/. + +### Options + +``` + -h, --help help for loadbalancer-beta +``` + +### Options inherited from parent commands + +``` + --config string Path to JSON or YAML configuration file (METAL_CONFIG) + --exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep + --filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters. + --http-header strings Headers to add to requests (in format key=value) + --include strings Comma separated Href references to expand in results, may be dotted three levels deep + -o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp). + --search string Search keyword for use in 'get' actions. Search is not supported by all resources. + --sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources. + --sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources. + --token string Metal API Token (METAL_AUTH_TOKEN) +``` + +### SEE ALSO + +* [metal](metal.md) - Command line interface for Equinix Metal +* [metal loadbalancer-beta create](metal_loadbalancer-beta_create.md) - Creates a loadbalancer. +* [metal loadbalancer-beta delete](metal_loadbalancer-beta_delete.md) - Deletes a loadbalancer. +* [metal loadbalancer-beta get](metal_loadbalancer-beta_get.md) - Retrieves all the project loadbalancers or the details of a specified loadbalancer. + diff --git a/docs/metal_loadbalancer-beta_create.md b/docs/metal_loadbalancer-beta_create.md new file mode 100644 index 00000000..7750d13c --- /dev/null +++ b/docs/metal_loadbalancer-beta_create.md @@ -0,0 +1,52 @@ +## metal loadbalancer-beta create + +Creates a loadbalancer. + +### Synopsis + +Creates a loadbalancer with the specified name. + +``` +metal loadbalancer-beta create -n -l [-p ] [--provider ] [--port ] [flags] +``` + +### Examples + +``` + # Creates a new loadbalancer named dev-loadbal in the Dallas metro: + metal loadbalancer create --name dev-loadbal -l da + + # Creates a new loadbalancer named prod-loadbal in the DC metro: + metal loadbalancer create -n prod-loadbal -l dc +``` + +### Options + +``` + -h, --help help for create + -l, --location string The location's ID. This flag is required. + -n, --name string Name of the loadbalancer + --port strings The port(s) UUID + -p, --project-id string The project's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PROJECT_ID environment variable. + -r, --provider string The provider ID. (default "loadpvd-gOB_-byp5ebFo7A3LHv2B") +``` + +### Options inherited from parent commands + +``` + --config string Path to JSON or YAML configuration file (METAL_CONFIG) + --exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep + --filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters. + --http-header strings Headers to add to requests (in format key=value) + --include strings Comma separated Href references to expand in results, may be dotted three levels deep + -o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp). + --search string Search keyword for use in 'get' actions. Search is not supported by all resources. + --sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources. + --sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources. + --token string Metal API Token (METAL_AUTH_TOKEN) +``` + +### SEE ALSO + +* [metal loadbalancer-beta](metal_loadbalancer-beta.md) - LoadBalancer BETA operations: create, get, update, and delete. + diff --git a/docs/metal_loadbalancer-beta_delete.md b/docs/metal_loadbalancer-beta_delete.md new file mode 100644 index 00000000..a8d65a4c --- /dev/null +++ b/docs/metal_loadbalancer-beta_delete.md @@ -0,0 +1,51 @@ +## metal loadbalancer-beta delete + +Deletes a loadbalancer. + +### Synopsis + +Deletes the specified loadbalancer with a confirmation prompt. To skip the confirmation use --force. + +``` +metal loadbalancer-beta delete --id [--force] [flags] +``` + +### Examples + +``` + # Deletes loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375: + metal loadbalancer delete -i 50693ba9-e4e4-4d8a-9eb2-4840b11e9375 + > + ✔ Are you sure you want to delete loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375: y + + # Deletes loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375, skipping confirmation: + metal loadbalancer delete -i 50693ba9-e4e4-4d8a-9eb2-4840b11e9375 -f +``` + +### Options + +``` + -f, --force Force removal of the loadbalancer + -h, --help help for delete + -i, --id string The loadbalancer's ID. This flag is required. +``` + +### Options inherited from parent commands + +``` + --config string Path to JSON or YAML configuration file (METAL_CONFIG) + --exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep + --filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters. + --http-header strings Headers to add to requests (in format key=value) + --include strings Comma separated Href references to expand in results, may be dotted three levels deep + -o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp). + --search string Search keyword for use in 'get' actions. Search is not supported by all resources. + --sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources. + --sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources. + --token string Metal API Token (METAL_AUTH_TOKEN) +``` + +### SEE ALSO + +* [metal loadbalancer-beta](metal_loadbalancer-beta.md) - LoadBalancer BETA operations: create, get, update, and delete. + diff --git a/docs/metal_loadbalancer-beta_get.md b/docs/metal_loadbalancer-beta_get.md new file mode 100644 index 00000000..e21edbe2 --- /dev/null +++ b/docs/metal_loadbalancer-beta_get.md @@ -0,0 +1,53 @@ +## metal loadbalancer-beta get + +Retrieves all the project loadbalancers or the details of a specified loadbalancer. + +### Synopsis + +Retrieves all the project loadbalancers or the details of a specified loadbalancer. You can specify which loadbalancer by UUID or name. + +``` +metal loadbalancer-beta get [-i | -n ] [flags] +``` + +### Examples + +``` + # Retrieve all loadbalancers: + metal loadbalancer get + + # Retrieve a specific loadbalancer by UUID: + metal loadbalancer get -i 2008f885-1aac-406b-8d99-e6963fd21333 + + # Retrieve a specific loadbalancer by name: + metal loadbalancer get -n dev-cluster03 +``` + +### Options + +``` + -h, --help help for get + -i, --id string The loadbalancer's UUID, which can be specified in the config created by metal init or set as METAL_PROJECT_ID environment variable. + -n, --loadbalancer string The name of the loadbalancer. + -p, --project-id string The project's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PROJECT_ID environment variable. +``` + +### Options inherited from parent commands + +``` + --config string Path to JSON or YAML configuration file (METAL_CONFIG) + --exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep + --filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters. + --http-header strings Headers to add to requests (in format key=value) + --include strings Comma separated Href references to expand in results, may be dotted three levels deep + -o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp). + --search string Search keyword for use in 'get' actions. Search is not supported by all resources. + --sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources. + --sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources. + --token string Metal API Token (METAL_AUTH_TOKEN) +``` + +### SEE ALSO + +* [metal loadbalancer-beta](metal_loadbalancer-beta.md) - LoadBalancer BETA operations: create, get, update, and delete. + diff --git a/go.mod b/go.mod index 7b887930..cd5c5dde 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.8.4 golang.org/x/exp v0.0.0-20240119083558-1b970713d09a + golang.org/x/oauth2 v0.15.0 golang.org/x/term v0.16.0 sigs.k8s.io/yaml v1.3.0 ) @@ -20,6 +21,7 @@ require ( github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -36,8 +38,11 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect + golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 488dcbc5..28f59aca 100644 --- a/go.sum +++ b/go.sum @@ -6,13 +6,16 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/equinix/equinix-sdk-go v0.31.2 h1:7aFyKtuja2OSd7ocIHW/YugeubWIQUcVb1+g1cRbiZo= -github.com/equinix/equinix-sdk-go v0.31.2/go.mod h1:qnpdRzVftHFNaJFk1VSIrAOTLrIoeDrxzUr3l8ARyvQ= github.com/equinix/equinix-sdk-go v0.32.0 h1:zUn0Em5FJe6f6bntftrDBpO9L+XhbpFMPuQ7RKEOgXM= github.com/equinix/equinix-sdk-go v0.32.0/go.mod h1:qnpdRzVftHFNaJFk1VSIrAOTLrIoeDrxzUr3l8ARyvQ= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -79,6 +82,11 @@ golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= +golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= @@ -86,9 +94,17 @@ golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= diff --git a/internal/cli/root.go b/internal/cli/root.go index e96d95bc..34a9c736 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -21,6 +21,7 @@ package cli import ( + "context" "fmt" "log" "net/http" @@ -34,7 +35,10 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" + "golang.org/x/oauth2" + v1 "github.com/equinix/metal-cli/internal/loadbalancers/api/v1" + "github.com/equinix/metal-cli/internal/loadbalancers/infrastructure" outputPkg "github.com/equinix/metal-cli/internal/outputs" ) @@ -48,6 +52,7 @@ type Client struct { // apiClient client apiClient *packngo.Client metalApiClient *metal.APIClient + lbaasApiClient *v1.APIClient includes *[]string // nolint:unused excludes *[]string // nolint:unused @@ -93,12 +98,14 @@ func checkEnvForDebug() bool { return os.Getenv(debugVar) != "" } +var uaFormat = "metal-cli/%s %s" + func (c *Client) apiConnect(httpClient *http.Client) error { client, err := packngo.NewClientWithBaseURL(c.consumerToken, c.metalToken, httpClient, c.apiURL) if err != nil { return fmt.Errorf("could not create client: %w", err) } - client.UserAgent = fmt.Sprintf("metal-cli/%s %s", c.Version, client.UserAgent) + client.UserAgent = fmt.Sprintf(uaFormat, c.Version, client.UserAgent) c.apiClient = client return nil } @@ -118,6 +125,35 @@ func (c *Client) metalApiConnect(httpClient *http.Client) error { return nil } +func (c *Client) lbaasApiConnect(header http.Header) error { + ctx := context.Background() + config := oauth2.Config{ + Endpoint: oauth2.Endpoint{ + TokenURL: "https://iam.metalctrl.io/token", + }, + } + ts := infrastructure.NewTokenExchanger(c.Token(), nil) + token, err := ts.Token() + if err != nil { + return err + } + client := &http.Client{ + Transport: &headerTransport{ + header: header, + }, + } + ctx = context.WithValue(ctx, oauth2.HTTPClient, client) + client = config.Client(ctx, token) + + configuration := v1.NewConfiguration() + configuration.Debug = checkEnvForDebug() + configuration.HTTPClient = client + configuration.UserAgent = fmt.Sprintf(uaFormat, c.Version, configuration.UserAgent) + + c.lbaasApiClient = v1.NewAPIClient(configuration) + return nil +} + func (c *Client) Config(cmd *cobra.Command) *viper.Viper { if c.viper == nil { v := viper.New() @@ -219,6 +255,20 @@ func (c *Client) MetalAPI(cmd *cobra.Command) *metal.APIClient { return c.metalApiClient } +func (c *Client) LoadbalancerAPI(cmd *cobra.Command) *v1.APIClient { + if c.metalToken == "" { + log.Fatal("Equinix Metal authentication token not provided. Please set the 'METAL_AUTH_TOKEN' environment variable or create a configuration file using 'metal init'.") + } + + if c.lbaasApiClient == nil { + err := c.lbaasApiConnect(getAdditionalHeaders(cmd)) + if err != nil { + log.Fatal(err) + } + } + return c.lbaasApiClient +} + func (c *Client) Token() string { return c.metalToken } diff --git a/internal/loadbalancers/api/v1/.gitignore b/internal/loadbalancers/api/v1/.gitignore new file mode 100644 index 00000000..daf913b1 --- /dev/null +++ b/internal/loadbalancers/api/v1/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/internal/loadbalancers/api/v1/.openapi-generator-ignore b/internal/loadbalancers/api/v1/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/internal/loadbalancers/api/v1/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/internal/loadbalancers/api/v1/.openapi-generator/FILES b/internal/loadbalancers/api/v1/.openapi-generator/FILES new file mode 100644 index 00000000..ff37cfc1 --- /dev/null +++ b/internal/loadbalancers/api/v1/.openapi-generator/FILES @@ -0,0 +1,75 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +api_load_balancers.go +api_origins.go +api_pools.go +api_ports.go +api_loadbalancers.go +client.go +configuration.go +docs/LoadBalancer.md +docs/LoadBalancerCollection.md +docs/LoadBalancerCreate.md +docs/LoadBalancerLocation.md +docs/LoadBalancerPool.md +docs/LoadBalancerPoolCollection.md +docs/LoadBalancerPoolCreate.md +docs/LoadBalancerPoolCreateProtocol.md +docs/LoadBalancerPoolOrigin.md +docs/LoadBalancerPoolOriginCollection.md +docs/LoadBalancerPoolOriginCreate.md +docs/LoadBalancerPoolOriginPortNumber.md +docs/LoadBalancerPoolOriginUpdate.md +docs/LoadBalancerPoolProtocol.md +docs/LoadBalancerPoolShort.md +docs/LoadBalancerPoolUpdate.md +docs/LoadBalancerPort.md +docs/LoadBalancerPortCollection.md +docs/LoadBalancerPortCreate.md +docs/LoadBalancerPortUpdate.md +docs/LoadBalancerShort.md +docs/LoadBalancerUpdate.md +docs/LoadBalancersApi.md +docs/OriginsApi.md +docs/PoolsApi.md +docs/PortsApi.md +docs/ProjectsApi.md +docs/Provider.md +docs/ResourceCreatedResponse.md +git_push.sh +go.mod +go.sum +model_load_balancer.go +model_load_balancer_collection.go +model_load_balancer_create.go +model_load_balancer_location.go +model_load_balancer_pool.go +model_load_balancer_pool_collection.go +model_load_balancer_pool_create.go +model_load_balancer_pool_create_protocol.go +model_load_balancer_pool_origin.go +model_load_balancer_pool_origin_collection.go +model_load_balancer_pool_origin_create.go +model_load_balancer_pool_origin_port_number.go +model_load_balancer_pool_origin_update.go +model_load_balancer_pool_protocol.go +model_load_balancer_pool_short.go +model_load_balancer_pool_update.go +model_load_balancer_port.go +model_load_balancer_port_collection.go +model_load_balancer_port_create.go +model_load_balancer_port_update.go +model_load_balancer_short.go +model_load_balancer_update.go +model_provider.go +model_resource_created_response.go +response.go +test/api_load_balancers_test.go +test/api_origins_test.go +test/api_pools_test.go +test/api_ports_test.go +test/api_loadbalancers_test.go +utils.go diff --git a/internal/loadbalancers/api/v1/.openapi-generator/VERSION b/internal/loadbalancers/api/v1/.openapi-generator/VERSION new file mode 100644 index 00000000..41225218 --- /dev/null +++ b/internal/loadbalancers/api/v1/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.0.0 \ No newline at end of file diff --git a/internal/loadbalancers/api/v1/api_load_balancers.go b/internal/loadbalancers/api/v1/api_load_balancers.go new file mode 100644 index 00000000..f4805d5f --- /dev/null +++ b/internal/loadbalancers/api/v1/api_load_balancers.go @@ -0,0 +1,328 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// LoadBalancersApiService LoadBalancersApi service +type LoadBalancersApiService service + +type ApiDeleteLoadBalancerRequest struct { + ctx context.Context + ApiService *LoadBalancersApiService + loadBalancerID string +} + +func (r ApiDeleteLoadBalancerRequest) Execute() (*http.Response, error) { + return r.ApiService.DeleteLoadBalancerExecute(r) +} + +/* +DeleteLoadBalancer Delete a load balancer. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerID ID of the load balancer + @return ApiDeleteLoadBalancerRequest +*/ +func (a *LoadBalancersApiService) DeleteLoadBalancer(ctx context.Context, loadBalancerID string) ApiDeleteLoadBalancerRequest { + return ApiDeleteLoadBalancerRequest{ + ApiService: a, + ctx: ctx, + loadBalancerID: loadBalancerID, + } +} + +// Execute executes the request +func (a *LoadBalancersApiService) DeleteLoadBalancerExecute(r ApiDeleteLoadBalancerRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LoadBalancersApiService.DeleteLoadBalancer") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/{loadBalancerID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerID, "loadBalancerID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiGetLoadBalancerRequest struct { + ctx context.Context + ApiService *LoadBalancersApiService + loadBalancerID string +} + +func (r ApiGetLoadBalancerRequest) Execute() (*LoadBalancer, *http.Response, error) { + return r.ApiService.GetLoadBalancerExecute(r) +} + +/* +GetLoadBalancer Gets a load balancer by ID + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerID ID of the load balancer + @return ApiGetLoadBalancerRequest +*/ +func (a *LoadBalancersApiService) GetLoadBalancer(ctx context.Context, loadBalancerID string) ApiGetLoadBalancerRequest { + return ApiGetLoadBalancerRequest{ + ApiService: a, + ctx: ctx, + loadBalancerID: loadBalancerID, + } +} + +// Execute executes the request +// +// @return LoadBalancer +func (a *LoadBalancersApiService) GetLoadBalancerExecute(r ApiGetLoadBalancerRequest) (*LoadBalancer, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancer + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LoadBalancersApiService.GetLoadBalancer") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/{loadBalancerID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerID, "loadBalancerID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiUpdateLoadBalancerRequest struct { + ctx context.Context + ApiService *LoadBalancersApiService + loadBalancerID string + loadBalancerUpdate *LoadBalancerUpdate +} + +func (r ApiUpdateLoadBalancerRequest) LoadBalancerUpdate(loadBalancerUpdate LoadBalancerUpdate) ApiUpdateLoadBalancerRequest { + r.loadBalancerUpdate = &loadBalancerUpdate + return r +} + +func (r ApiUpdateLoadBalancerRequest) Execute() (*ResourceCreatedResponse, *http.Response, error) { + return r.ApiService.UpdateLoadBalancerExecute(r) +} + +/* +UpdateLoadBalancer Update a load balancer. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerID ID of the load balancer + @return ApiUpdateLoadBalancerRequest +*/ +func (a *LoadBalancersApiService) UpdateLoadBalancer(ctx context.Context, loadBalancerID string) ApiUpdateLoadBalancerRequest { + return ApiUpdateLoadBalancerRequest{ + ApiService: a, + ctx: ctx, + loadBalancerID: loadBalancerID, + } +} + +// Execute executes the request +// +// @return ResourceCreatedResponse +func (a *LoadBalancersApiService) UpdateLoadBalancerExecute(r ApiUpdateLoadBalancerRequest) (*ResourceCreatedResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResourceCreatedResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LoadBalancersApiService.UpdateLoadBalancer") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/{loadBalancerID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerID, "loadBalancerID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.loadBalancerUpdate == nil { + return localVarReturnValue, nil, reportError("loadBalancerUpdate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.loadBalancerUpdate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/internal/loadbalancers/api/v1/api_origins.go b/internal/loadbalancers/api/v1/api_origins.go new file mode 100644 index 00000000..a2a82c64 --- /dev/null +++ b/internal/loadbalancers/api/v1/api_origins.go @@ -0,0 +1,328 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// OriginsApiService OriginsApi service +type OriginsApiService service + +type ApiDeleteLoadBalancerOriginRequest struct { + ctx context.Context + ApiService *OriginsApiService + loadBalancerOriginID string +} + +func (r ApiDeleteLoadBalancerOriginRequest) Execute() (*http.Response, error) { + return r.ApiService.DeleteLoadBalancerOriginExecute(r) +} + +/* +DeleteLoadBalancerOrigin Delete a load balancer origin. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerOriginID ID of the load balancer origin + @return ApiDeleteLoadBalancerOriginRequest +*/ +func (a *OriginsApiService) DeleteLoadBalancerOrigin(ctx context.Context, loadBalancerOriginID string) ApiDeleteLoadBalancerOriginRequest { + return ApiDeleteLoadBalancerOriginRequest{ + ApiService: a, + ctx: ctx, + loadBalancerOriginID: loadBalancerOriginID, + } +} + +// Execute executes the request +func (a *OriginsApiService) DeleteLoadBalancerOriginExecute(r ApiDeleteLoadBalancerOriginRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OriginsApiService.DeleteLoadBalancerOrigin") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/pools/origins/{loadBalancerOriginID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerOriginID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerOriginID, "loadBalancerOriginID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiGetLoadBalancerOriginRequest struct { + ctx context.Context + ApiService *OriginsApiService + loadBalancerOriginID string +} + +func (r ApiGetLoadBalancerOriginRequest) Execute() (*LoadBalancerPoolOrigin, *http.Response, error) { + return r.ApiService.GetLoadBalancerOriginExecute(r) +} + +/* +GetLoadBalancerOrigin Gets a load balancer origin by ID + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerOriginID ID of the load balancer origin + @return ApiGetLoadBalancerOriginRequest +*/ +func (a *OriginsApiService) GetLoadBalancerOrigin(ctx context.Context, loadBalancerOriginID string) ApiGetLoadBalancerOriginRequest { + return ApiGetLoadBalancerOriginRequest{ + ApiService: a, + ctx: ctx, + loadBalancerOriginID: loadBalancerOriginID, + } +} + +// Execute executes the request +// +// @return LoadBalancerPoolOrigin +func (a *OriginsApiService) GetLoadBalancerOriginExecute(r ApiGetLoadBalancerOriginRequest) (*LoadBalancerPoolOrigin, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPoolOrigin + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OriginsApiService.GetLoadBalancerOrigin") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/pools/origins/{loadBalancerOriginID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerOriginID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerOriginID, "loadBalancerOriginID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiUpdateLoadBalancerOriginRequest struct { + ctx context.Context + ApiService *OriginsApiService + loadBalancerOriginID string + loadBalancerPoolOriginUpdate *LoadBalancerPoolOriginUpdate +} + +func (r ApiUpdateLoadBalancerOriginRequest) LoadBalancerPoolOriginUpdate(loadBalancerPoolOriginUpdate LoadBalancerPoolOriginUpdate) ApiUpdateLoadBalancerOriginRequest { + r.loadBalancerPoolOriginUpdate = &loadBalancerPoolOriginUpdate + return r +} + +func (r ApiUpdateLoadBalancerOriginRequest) Execute() (*LoadBalancerPoolOrigin, *http.Response, error) { + return r.ApiService.UpdateLoadBalancerOriginExecute(r) +} + +/* +UpdateLoadBalancerOrigin Update a load balancer origin. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerOriginID ID of the load balancer origin + @return ApiUpdateLoadBalancerOriginRequest +*/ +func (a *OriginsApiService) UpdateLoadBalancerOrigin(ctx context.Context, loadBalancerOriginID string) ApiUpdateLoadBalancerOriginRequest { + return ApiUpdateLoadBalancerOriginRequest{ + ApiService: a, + ctx: ctx, + loadBalancerOriginID: loadBalancerOriginID, + } +} + +// Execute executes the request +// +// @return LoadBalancerPoolOrigin +func (a *OriginsApiService) UpdateLoadBalancerOriginExecute(r ApiUpdateLoadBalancerOriginRequest) (*LoadBalancerPoolOrigin, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPoolOrigin + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OriginsApiService.UpdateLoadBalancerOrigin") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/pools/origins/{loadBalancerOriginID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerOriginID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerOriginID, "loadBalancerOriginID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.loadBalancerPoolOriginUpdate == nil { + return localVarReturnValue, nil, reportError("loadBalancerPoolOriginUpdate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.loadBalancerPoolOriginUpdate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/internal/loadbalancers/api/v1/api_pools.go b/internal/loadbalancers/api/v1/api_pools.go new file mode 100644 index 00000000..bfd5908e --- /dev/null +++ b/internal/loadbalancers/api/v1/api_pools.go @@ -0,0 +1,543 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// PoolsApiService PoolsApi service +type PoolsApiService service + +type ApiCreateLoadBalancerPoolOriginRequest struct { + ctx context.Context + ApiService *PoolsApiService + loadBalancerPoolID string + loadBalancerPoolOriginCreate *LoadBalancerPoolOriginCreate +} + +func (r ApiCreateLoadBalancerPoolOriginRequest) LoadBalancerPoolOriginCreate(loadBalancerPoolOriginCreate LoadBalancerPoolOriginCreate) ApiCreateLoadBalancerPoolOriginRequest { + r.loadBalancerPoolOriginCreate = &loadBalancerPoolOriginCreate + return r +} + +func (r ApiCreateLoadBalancerPoolOriginRequest) Execute() (*ResourceCreatedResponse, *http.Response, error) { + return r.ApiService.CreateLoadBalancerPoolOriginExecute(r) +} + +/* +CreateLoadBalancerPoolOrigin Create a load balancer origin for a pool. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerPoolID ID of the load balancer pool to get + @return ApiCreateLoadBalancerPoolOriginRequest +*/ +func (a *PoolsApiService) CreateLoadBalancerPoolOrigin(ctx context.Context, loadBalancerPoolID string) ApiCreateLoadBalancerPoolOriginRequest { + return ApiCreateLoadBalancerPoolOriginRequest{ + ApiService: a, + ctx: ctx, + loadBalancerPoolID: loadBalancerPoolID, + } +} + +// Execute executes the request +// +// @return ResourceCreatedResponse +func (a *PoolsApiService) CreateLoadBalancerPoolOriginExecute(r ApiCreateLoadBalancerPoolOriginRequest) (*ResourceCreatedResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResourceCreatedResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PoolsApiService.CreateLoadBalancerPoolOrigin") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/pools/{loadBalancerPoolID}/origins" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerPoolID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerPoolID, "loadBalancerPoolID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.loadBalancerPoolOriginCreate == nil { + return localVarReturnValue, nil, reportError("loadBalancerPoolOriginCreate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.loadBalancerPoolOriginCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiDeleteLoadBalancerPoolRequest struct { + ctx context.Context + ApiService *PoolsApiService + loadBalancerPoolID string +} + +func (r ApiDeleteLoadBalancerPoolRequest) Execute() (*http.Response, error) { + return r.ApiService.DeleteLoadBalancerPoolExecute(r) +} + +/* +DeleteLoadBalancerPool Delete a load balancer pool. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerPoolID ID of the load balancer pool to get + @return ApiDeleteLoadBalancerPoolRequest +*/ +func (a *PoolsApiService) DeleteLoadBalancerPool(ctx context.Context, loadBalancerPoolID string) ApiDeleteLoadBalancerPoolRequest { + return ApiDeleteLoadBalancerPoolRequest{ + ApiService: a, + ctx: ctx, + loadBalancerPoolID: loadBalancerPoolID, + } +} + +// Execute executes the request +func (a *PoolsApiService) DeleteLoadBalancerPoolExecute(r ApiDeleteLoadBalancerPoolRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PoolsApiService.DeleteLoadBalancerPool") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/pools/{loadBalancerPoolID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerPoolID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerPoolID, "loadBalancerPoolID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiGetLoadBalancerPoolRequest struct { + ctx context.Context + ApiService *PoolsApiService + loadBalancerPoolID string +} + +func (r ApiGetLoadBalancerPoolRequest) Execute() (*LoadBalancerPool, *http.Response, error) { + return r.ApiService.GetLoadBalancerPoolExecute(r) +} + +/* +GetLoadBalancerPool Gets a load balancer pool by ID + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerPoolID ID of the load balancer pool to get + @return ApiGetLoadBalancerPoolRequest +*/ +func (a *PoolsApiService) GetLoadBalancerPool(ctx context.Context, loadBalancerPoolID string) ApiGetLoadBalancerPoolRequest { + return ApiGetLoadBalancerPoolRequest{ + ApiService: a, + ctx: ctx, + loadBalancerPoolID: loadBalancerPoolID, + } +} + +// Execute executes the request +// +// @return LoadBalancerPool +func (a *PoolsApiService) GetLoadBalancerPoolExecute(r ApiGetLoadBalancerPoolRequest) (*LoadBalancerPool, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPool + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PoolsApiService.GetLoadBalancerPool") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/pools/{loadBalancerPoolID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerPoolID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerPoolID, "loadBalancerPoolID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiListLoadBalancerPoolOriginsRequest struct { + ctx context.Context + ApiService *PoolsApiService + loadBalancerPoolID string +} + +func (r ApiListLoadBalancerPoolOriginsRequest) Execute() (*LoadBalancerPoolOriginCollection, *http.Response, error) { + return r.ApiService.ListLoadBalancerPoolOriginsExecute(r) +} + +/* +ListLoadBalancerPoolOrigins Gets the origins for a pool. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerPoolID ID of the load balancer pool to get + @return ApiListLoadBalancerPoolOriginsRequest +*/ +func (a *PoolsApiService) ListLoadBalancerPoolOrigins(ctx context.Context, loadBalancerPoolID string) ApiListLoadBalancerPoolOriginsRequest { + return ApiListLoadBalancerPoolOriginsRequest{ + ApiService: a, + ctx: ctx, + loadBalancerPoolID: loadBalancerPoolID, + } +} + +// Execute executes the request +// +// @return LoadBalancerPoolOriginCollection +func (a *PoolsApiService) ListLoadBalancerPoolOriginsExecute(r ApiListLoadBalancerPoolOriginsRequest) (*LoadBalancerPoolOriginCollection, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPoolOriginCollection + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PoolsApiService.ListLoadBalancerPoolOrigins") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/pools/{loadBalancerPoolID}/origins" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerPoolID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerPoolID, "loadBalancerPoolID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiUpdateLoadBalancerPoolRequest struct { + ctx context.Context + ApiService *PoolsApiService + loadBalancerPoolID string + loadBalancerPoolUpdate *LoadBalancerPoolUpdate +} + +func (r ApiUpdateLoadBalancerPoolRequest) LoadBalancerPoolUpdate(loadBalancerPoolUpdate LoadBalancerPoolUpdate) ApiUpdateLoadBalancerPoolRequest { + r.loadBalancerPoolUpdate = &loadBalancerPoolUpdate + return r +} + +func (r ApiUpdateLoadBalancerPoolRequest) Execute() (*LoadBalancerPool, *http.Response, error) { + return r.ApiService.UpdateLoadBalancerPoolExecute(r) +} + +/* +UpdateLoadBalancerPool Update a load balancer pool. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerPoolID ID of the load balancer pool to get + @return ApiUpdateLoadBalancerPoolRequest +*/ +func (a *PoolsApiService) UpdateLoadBalancerPool(ctx context.Context, loadBalancerPoolID string) ApiUpdateLoadBalancerPoolRequest { + return ApiUpdateLoadBalancerPoolRequest{ + ApiService: a, + ctx: ctx, + loadBalancerPoolID: loadBalancerPoolID, + } +} + +// Execute executes the request +// +// @return LoadBalancerPool +func (a *PoolsApiService) UpdateLoadBalancerPoolExecute(r ApiUpdateLoadBalancerPoolRequest) (*LoadBalancerPool, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPool + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PoolsApiService.UpdateLoadBalancerPool") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/pools/{loadBalancerPoolID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerPoolID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerPoolID, "loadBalancerPoolID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.loadBalancerPoolUpdate == nil { + return localVarReturnValue, nil, reportError("loadBalancerPoolUpdate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.loadBalancerPoolUpdate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/internal/loadbalancers/api/v1/api_ports.go b/internal/loadbalancers/api/v1/api_ports.go new file mode 100644 index 00000000..58b7d927 --- /dev/null +++ b/internal/loadbalancers/api/v1/api_ports.go @@ -0,0 +1,547 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// PortsApiService PortsApi service +type PortsApiService service + +type ApiCreateLoadBalancerPortRequest struct { + ctx context.Context + ApiService *PortsApiService + loadBalancerID string + loadBalancerPortCreate *LoadBalancerPortCreate +} + +func (r ApiCreateLoadBalancerPortRequest) LoadBalancerPortCreate(loadBalancerPortCreate LoadBalancerPortCreate) ApiCreateLoadBalancerPortRequest { + r.loadBalancerPortCreate = &loadBalancerPortCreate + return r +} + +func (r ApiCreateLoadBalancerPortRequest) Execute() (*ResourceCreatedResponse, *http.Response, error) { + return r.ApiService.CreateLoadBalancerPortExecute(r) +} + +/* +CreateLoadBalancerPort Create a load balancer port. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerID ID of the load balancer + @return ApiCreateLoadBalancerPortRequest +*/ +func (a *PortsApiService) CreateLoadBalancerPort(ctx context.Context, loadBalancerID string) ApiCreateLoadBalancerPortRequest { + return ApiCreateLoadBalancerPortRequest{ + ApiService: a, + ctx: ctx, + loadBalancerID: loadBalancerID, + } +} + +// Execute executes the request +// +// @return ResourceCreatedResponse +func (a *PortsApiService) CreateLoadBalancerPortExecute(r ApiCreateLoadBalancerPortRequest) (*ResourceCreatedResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResourceCreatedResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PortsApiService.CreateLoadBalancerPort") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/{loadBalancerID}/ports" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerID, "loadBalancerID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.loadBalancerPortCreate == nil { + return localVarReturnValue, nil, reportError("loadBalancerPortCreate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.loadBalancerPortCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiDeleteLoadBalancerPortRequest struct { + ctx context.Context + ApiService *PortsApiService + loadBalancerPortID string +} + +func (r ApiDeleteLoadBalancerPortRequest) Execute() (*http.Response, error) { + return r.ApiService.DeleteLoadBalancerPortExecute(r) +} + +/* +DeleteLoadBalancerPort Delete a load balancer port. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerPortID ID of the load balancer port + @return ApiDeleteLoadBalancerPortRequest +*/ +func (a *PortsApiService) DeleteLoadBalancerPort(ctx context.Context, loadBalancerPortID string) ApiDeleteLoadBalancerPortRequest { + return ApiDeleteLoadBalancerPortRequest{ + ApiService: a, + ctx: ctx, + loadBalancerPortID: loadBalancerPortID, + } +} + +// Execute executes the request +func (a *PortsApiService) DeleteLoadBalancerPortExecute(r ApiDeleteLoadBalancerPortRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PortsApiService.DeleteLoadBalancerPort") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/ports/{loadBalancerPortID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerPortID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerPortID, "loadBalancerPortID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiGetLoadBalancerPortRequest struct { + ctx context.Context + ApiService *PortsApiService + loadBalancerID string + portNumber int32 +} + +func (r ApiGetLoadBalancerPortRequest) Execute() (*LoadBalancerPort, *http.Response, error) { + return r.ApiService.GetLoadBalancerPortExecute(r) +} + +/* +GetLoadBalancerPort Gets a load balancer port by ID + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerID ID of the load balancer + @param portNumber Port number + @return ApiGetLoadBalancerPortRequest +*/ +func (a *PortsApiService) GetLoadBalancerPort(ctx context.Context, loadBalancerID string, portNumber int32) ApiGetLoadBalancerPortRequest { + return ApiGetLoadBalancerPortRequest{ + ApiService: a, + ctx: ctx, + loadBalancerID: loadBalancerID, + portNumber: portNumber, + } +} + +// Execute executes the request +// +// @return LoadBalancerPort +func (a *PortsApiService) GetLoadBalancerPortExecute(r ApiGetLoadBalancerPortRequest) (*LoadBalancerPort, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPort + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PortsApiService.GetLoadBalancerPort") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/{loadBalancerID}/ports/{portNumber}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerID, "loadBalancerID")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"portNumber"+"}", url.PathEscape(parameterValueToString(r.portNumber, "portNumber")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiListLoadBalancerPortsRequest struct { + ctx context.Context + ApiService *PortsApiService + loadBalancerID string +} + +func (r ApiListLoadBalancerPortsRequest) Execute() (*LoadBalancerPortCollection, *http.Response, error) { + return r.ApiService.ListLoadBalancerPortsExecute(r) +} + +/* +ListLoadBalancerPorts Gets the load balancer's ports. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerID ID of the load balancer + @return ApiListLoadBalancerPortsRequest +*/ +func (a *PortsApiService) ListLoadBalancerPorts(ctx context.Context, loadBalancerID string) ApiListLoadBalancerPortsRequest { + return ApiListLoadBalancerPortsRequest{ + ApiService: a, + ctx: ctx, + loadBalancerID: loadBalancerID, + } +} + +// Execute executes the request +// +// @return LoadBalancerPortCollection +func (a *PortsApiService) ListLoadBalancerPortsExecute(r ApiListLoadBalancerPortsRequest) (*LoadBalancerPortCollection, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPortCollection + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PortsApiService.ListLoadBalancerPorts") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/{loadBalancerID}/ports" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerID, "loadBalancerID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiUpdateLoadBalancerPortRequest struct { + ctx context.Context + ApiService *PortsApiService + loadBalancerPortID string + loadBalancerPortUpdate *LoadBalancerPortUpdate +} + +func (r ApiUpdateLoadBalancerPortRequest) LoadBalancerPortUpdate(loadBalancerPortUpdate LoadBalancerPortUpdate) ApiUpdateLoadBalancerPortRequest { + r.loadBalancerPortUpdate = &loadBalancerPortUpdate + return r +} + +func (r ApiUpdateLoadBalancerPortRequest) Execute() (*LoadBalancerPort, *http.Response, error) { + return r.ApiService.UpdateLoadBalancerPortExecute(r) +} + +/* +UpdateLoadBalancerPort Update a load balancer port. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param loadBalancerPortID ID of the load balancer port + @return ApiUpdateLoadBalancerPortRequest +*/ +func (a *PortsApiService) UpdateLoadBalancerPort(ctx context.Context, loadBalancerPortID string) ApiUpdateLoadBalancerPortRequest { + return ApiUpdateLoadBalancerPortRequest{ + ApiService: a, + ctx: ctx, + loadBalancerPortID: loadBalancerPortID, + } +} + +// Execute executes the request +// +// @return LoadBalancerPort +func (a *PortsApiService) UpdateLoadBalancerPortExecute(r ApiUpdateLoadBalancerPortRequest) (*LoadBalancerPort, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPort + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PortsApiService.UpdateLoadBalancerPort") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/loadbalancers/ports/{loadBalancerPortID}" + localVarPath = strings.Replace(localVarPath, "{"+"loadBalancerPortID"+"}", url.PathEscape(parameterValueToString(r.loadBalancerPortID, "loadBalancerPortID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.loadBalancerPortUpdate == nil { + return localVarReturnValue, nil, reportError("loadBalancerPortUpdate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.loadBalancerPortUpdate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/internal/loadbalancers/api/v1/api_projects.go b/internal/loadbalancers/api/v1/api_projects.go new file mode 100644 index 00000000..5808f96f --- /dev/null +++ b/internal/loadbalancers/api/v1/api_projects.go @@ -0,0 +1,453 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// ProjectsApiService ProjectsApi service +type ProjectsApiService service + +type ApiCreateLoadBalancerRequest struct { + ctx context.Context + ApiService *ProjectsApiService + projectID string + loadBalancerCreate *LoadBalancerCreate +} + +func (r ApiCreateLoadBalancerRequest) LoadBalancerCreate(loadBalancerCreate LoadBalancerCreate) ApiCreateLoadBalancerRequest { + r.loadBalancerCreate = &loadBalancerCreate + return r +} + +func (r ApiCreateLoadBalancerRequest) Execute() (*ResourceCreatedResponse, *http.Response, error) { + return r.ApiService.CreateLoadBalancerExecute(r) +} + +/* +CreateLoadBalancer Create a load balancer for project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectID ID of project + @return ApiCreateLoadBalancerRequest +*/ +func (a *ProjectsApiService) CreateLoadBalancer(ctx context.Context, projectID string) ApiCreateLoadBalancerRequest { + return ApiCreateLoadBalancerRequest{ + ApiService: a, + ctx: ctx, + projectID: projectID, + } +} + +// Execute executes the request +// +// @return ResourceCreatedResponse +func (a *ProjectsApiService) CreateLoadBalancerExecute(r ApiCreateLoadBalancerRequest) (*ResourceCreatedResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResourceCreatedResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ProjectsApiService.CreateLoadBalancer") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectID}/loadbalancers" + localVarPath = strings.Replace(localVarPath, "{"+"projectID"+"}", url.PathEscape(parameterValueToString(r.projectID, "projectID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.loadBalancerCreate == nil { + return localVarReturnValue, nil, reportError("loadBalancerCreate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.loadBalancerCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiCreatePoolRequest struct { + ctx context.Context + ApiService *ProjectsApiService + projectID string + loadBalancerPoolCreate *LoadBalancerPoolCreate +} + +func (r ApiCreatePoolRequest) LoadBalancerPoolCreate(loadBalancerPoolCreate LoadBalancerPoolCreate) ApiCreatePoolRequest { + r.loadBalancerPoolCreate = &loadBalancerPoolCreate + return r +} + +func (r ApiCreatePoolRequest) Execute() (*ResourceCreatedResponse, *http.Response, error) { + return r.ApiService.CreatePoolExecute(r) +} + +/* +CreatePool Create a load balancer pool for project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectID ID of project + @return ApiCreatePoolRequest +*/ +func (a *ProjectsApiService) CreatePool(ctx context.Context, projectID string) ApiCreatePoolRequest { + return ApiCreatePoolRequest{ + ApiService: a, + ctx: ctx, + projectID: projectID, + } +} + +// Execute executes the request +// +// @return ResourceCreatedResponse +func (a *ProjectsApiService) CreatePoolExecute(r ApiCreatePoolRequest) (*ResourceCreatedResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResourceCreatedResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ProjectsApiService.CreatePool") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectID}/loadbalancers/pools" + localVarPath = strings.Replace(localVarPath, "{"+"projectID"+"}", url.PathEscape(parameterValueToString(r.projectID, "projectID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.loadBalancerPoolCreate == nil { + return localVarReturnValue, nil, reportError("loadBalancerPoolCreate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.loadBalancerPoolCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiListLoadBalancersRequest struct { + ctx context.Context + ApiService *ProjectsApiService + projectID string +} + +func (r ApiListLoadBalancersRequest) Execute() (*LoadBalancerCollection, *http.Response, error) { + return r.ApiService.ListLoadBalancersExecute(r) +} + +/* +ListLoadBalancers Gets the load balancers for a project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectID ID of project + @return ApiListLoadBalancersRequest +*/ +func (a *ProjectsApiService) ListLoadBalancers(ctx context.Context, projectID string) ApiListLoadBalancersRequest { + return ApiListLoadBalancersRequest{ + ApiService: a, + ctx: ctx, + projectID: projectID, + } +} + +// Execute executes the request +// +// @return LoadBalancerCollection +func (a *ProjectsApiService) ListLoadBalancersExecute(r ApiListLoadBalancersRequest) (*LoadBalancerCollection, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerCollection + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ProjectsApiService.ListLoadBalancers") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectID}/loadbalancers" + localVarPath = strings.Replace(localVarPath, "{"+"projectID"+"}", url.PathEscape(parameterValueToString(r.projectID, "projectID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiListPoolsRequest struct { + ctx context.Context + ApiService *ProjectsApiService + projectID string +} + +func (r ApiListPoolsRequest) Execute() (*LoadBalancerPoolCollection, *http.Response, error) { + return r.ApiService.ListPoolsExecute(r) +} + +/* +ListPools Gets the pools for a project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectID ID of project + @return ApiListPoolsRequest +*/ +func (a *ProjectsApiService) ListPools(ctx context.Context, projectID string) ApiListPoolsRequest { + return ApiListPoolsRequest{ + ApiService: a, + ctx: ctx, + projectID: projectID, + } +} + +// Execute executes the request +// +// @return LoadBalancerPoolCollection +func (a *ProjectsApiService) ListPoolsExecute(r ApiListPoolsRequest) (*LoadBalancerPoolCollection, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *LoadBalancerPoolCollection + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ProjectsApiService.ListPools") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectID}/loadbalancers/pools" + localVarPath = strings.Replace(localVarPath, "{"+"projectID"+"}", url.PathEscape(parameterValueToString(r.projectID, "projectID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/internal/loadbalancers/api/v1/client.go b/internal/loadbalancers/api/v1/client.go new file mode 100644 index 00000000..2dddafb6 --- /dev/null +++ b/internal/loadbalancers/api/v1/client.go @@ -0,0 +1,686 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/oauth2" +) + +var ( + jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") +) + +// APIClient manages communication with the Load Balancer Management API API v0.0.1 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + LoadBalancersApi *LoadBalancersApiService + + OriginsApi *OriginsApiService + + PoolsApi *PoolsApiService + + PortsApi *PortsApiService + + ProjectsApi *ProjectsApiService +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.LoadBalancersApi = (*LoadBalancersApiService)(&c.common) + c.OriginsApi = (*OriginsApiService)(&c.common) + c.PoolsApi = (*PoolsApiService)(&c.common) + c.PortsApi = (*PortsApiService)(&c.common) + c.ProjectsApi = (*ProjectsApiService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString(obj interface{}, key string) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return fmt.Sprintf("%v", obj) + } + var param, ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap, err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + case reflect.Invalid: + value = "invalid" + + case reflect.Struct: + if t, ok := obj.(MappedNullable); ok { + dataMap, err := t.ToMap() + if err != nil { + return + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType) + return + } + value = v.Type().String() + " value" + case reflect.Slice: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + var lenIndValue = indValue.Len() + for i := 0; i < lenIndValue; i++ { + var arrayValue = indValue.Index(i) + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, arrayValue.Interface(), collectionType) + } + return + + case reflect.Map: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + iter := indValue.MapRange() + for iter.Next() { + k, v := iter.Key(), iter.Value() + parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType) + } + return + + case reflect.Interface: + fallthrough + case reflect.Ptr: + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), collectionType) + return + + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + value = strconv.FormatInt(v.Int(), 10) + case reflect.Uint, reflect.Uint8, reflect.Uint16, + reflect.Uint32, reflect.Uint64, reflect.Uintptr: + value = strconv.FormatUint(v.Uint(), 10) + case reflect.Float32, reflect.Float64: + value = strconv.FormatFloat(v.Float(), 'g', -1, 32) + case reflect.Bool: + value = strconv.FormatBool(v.Bool()) + case reflect.String: + value = v.String() + default: + value = v.Type().String() + " value" + } + } + + switch valuesMap := headerOrQueryParams.(type) { + case url.Values: + if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" { + valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value) + } else { + valuesMap.Add(keyPrefix, value) + } + break + case map[string]string: + valuesMap[keyPrefix] = value + break + } +} + +// helper for converting interface{} parameters to json strings +func parameterToJson(obj interface{}) (string, error) { + jsonBuf, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(jsonBuf), err +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(request, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + return resp, err + } + log.Printf("\n%s\n", string(dump)) + } + return resp, err +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *Configuration { + return c.cfg +} + +type formFile struct { + fileBytes []byte + fileName string + formFileName string +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + formFiles []formFile) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if f, ok := v.(*os.File); ok { + f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = f.Write(b) + if err != nil { + return + } + _, err = f.Seek(0, io.SeekStart) + err = os.Remove(f.Name()) + return + } + if f, ok := v.(**os.File); ok { + *f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + if err != nil { + return + } + _, err = (*f).Seek(0, io.SeekStart) + err = os.Remove((*f).Name()) + return + } + if xmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if jsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(filepath.Clean(path)) + if err != nil { + return err + } + err = file.Close() + if err != nil { + return err + } + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if fp, ok := body.(*os.File); ok { + _, err = bodyBuf.ReadFrom(fp) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + var bs []byte + bs, err = xml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericOpenAPIError Provides access to the body, error and model on returned errors. +type GenericOpenAPIError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericOpenAPIError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericOpenAPIError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericOpenAPIError) Model() interface{} { + return e.model +} + +// format error message using title and detail when model implements rfc7807 +func formatErrorMessage(status string, v interface{}) string { + str := "" + metaValue := reflect.ValueOf(v).Elem() + + if metaValue.Kind() == reflect.Struct { + field := metaValue.FieldByName("Title") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s", field.Interface()) + } + + field = metaValue.FieldByName("Detail") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s (%s)", str, field.Interface()) + } + } + + return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) +} diff --git a/internal/loadbalancers/api/v1/configuration.go b/internal/loadbalancers/api/v1/configuration.go new file mode 100644 index 00000000..cc055b00 --- /dev/null +++ b/internal/loadbalancers/api/v1/configuration.go @@ -0,0 +1,217 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "context" + "fmt" + "net/http" + "strings" +) + +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextServerIndex uses a server configuration from the index. + ContextServerIndex = contextKey("serverIndex") + + // ContextOperationServerIndices uses a server configuration from the index mapping. + ContextOperationServerIndices = contextKey("serverOperationIndices") + + // ContextServerVariables overrides a server configuration variables. + ContextServerVariables = contextKey("serverVariables") + + // ContextOperationServerVariables overrides a server configuration variables using operation specific values. + ContextOperationServerVariables = contextKey("serverOperationVariables") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} + +// ServerVariable stores the information about a server variable +type ServerVariable struct { + Description string + DefaultValue string + EnumValues []string +} + +// ServerConfiguration stores the information about a server +type ServerConfiguration struct { + URL string + Description string + Variables map[string]ServerVariable +} + +// ServerConfigurations stores multiple ServerConfiguration items +type ServerConfigurations []ServerConfiguration + +// Configuration stores the configuration of the API client +type Configuration struct { + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + Debug bool `json:"debug,omitempty"` + Servers ServerConfigurations + OperationServers map[string]ServerConfigurations + HTTPClient *http.Client +} + +// NewConfiguration returns a new Configuration object +func NewConfiguration() *Configuration { + cfg := &Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "metal-lbaas-go/0.22.2", + Debug: false, + Servers: ServerConfigurations{ + { + URL: "https://lb.metalctrl.io", + Description: "Production Server", + }, + }, + OperationServers: map[string]ServerConfigurations{}, + } + return cfg +} + +// AddDefaultHeader adds a new HTTP header to the default header in the request +func (c *Configuration) AddDefaultHeader(key string, value string) { + c.DefaultHeader[key] = value +} + +// URL formats template on a index using given variables +func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) { + if index < 0 || len(sc) <= index { + return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1) + } + server := sc[index] + url := server.URL + + // go through variables and replace placeholders + for name, variable := range server.Variables { + if value, ok := variables[name]; ok { + found := bool(len(variable.EnumValues) == 0) + for _, enumValue := range variable.EnumValues { + if value == enumValue { + found = true + } + } + if !found { + return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) + } + url = strings.Replace(url, "{"+name+"}", value, -1) + } else { + url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + } + } + return url, nil +} + +// ServerURL returns URL based on server settings +func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) { + return c.Servers.URL(index, variables) +} + +func getServerIndex(ctx context.Context) (int, error) { + si := ctx.Value(ContextServerIndex) + if si != nil { + if index, ok := si.(int); ok { + return index, nil + } + return 0, reportError("Invalid type %T should be int", si) + } + return 0, nil +} + +func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) { + osi := ctx.Value(ContextOperationServerIndices) + if osi != nil { + if operationIndices, ok := osi.(map[string]int); !ok { + return 0, reportError("Invalid type %T should be map[string]int", osi) + } else { + index, ok := operationIndices[endpoint] + if ok { + return index, nil + } + } + } + return getServerIndex(ctx) +} + +func getServerVariables(ctx context.Context) (map[string]string, error) { + sv := ctx.Value(ContextServerVariables) + if sv != nil { + if variables, ok := sv.(map[string]string); ok { + return variables, nil + } + return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv) + } + return nil, nil +} + +func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) { + osv := ctx.Value(ContextOperationServerVariables) + if osv != nil { + if operationVariables, ok := osv.(map[string]map[string]string); !ok { + return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv) + } else { + variables, ok := operationVariables[endpoint] + if ok { + return variables, nil + } + } + } + return getServerVariables(ctx) +} + +// ServerURLWithContext returns a new server URL given an endpoint +func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) { + sc, ok := c.OperationServers[endpoint] + if !ok { + sc = c.Servers + } + + if ctx == nil { + return sc.URL(0, nil) + } + + index, err := getServerOperationIndex(ctx, endpoint) + if err != nil { + return "", err + } + + variables, err := getServerOperationVariables(ctx, endpoint) + if err != nil { + return "", err + } + + return sc.URL(index, variables) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer.go b/internal/loadbalancers/api/v1/model_load_balancer.go new file mode 100644 index 00000000..793d399d --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer.go @@ -0,0 +1,403 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "time" +) + +// checks if the LoadBalancer type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancer{} + +// LoadBalancer struct for LoadBalancer +type LoadBalancer struct { + // ID of the load balancer + Id string `json:"id"` + // Date and time of creation + CreatedAt time.Time `json:"created_at"` + // Date and time of last update + UpdatedAt time.Time `json:"updated_at"` + // A name for the load balancer + Name string `json:"name"` + Provider Provider `json:"provider"` + // A list of ports assigned to the load balancer + Ports []LoadBalancerPort `json:"ports"` + // A list of pool names and ids assigned to the load balancer + Pools [][]LoadBalancerPoolShort `json:"pools,omitempty"` + // A list of associated ip addresses + Ips []string `json:"ips,omitempty"` + Location *LoadBalancerLocation `json:"location,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancer LoadBalancer + +// NewLoadBalancer instantiates a new LoadBalancer object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancer(id string, createdAt time.Time, updatedAt time.Time, name string, provider Provider, ports []LoadBalancerPort) *LoadBalancer { + this := LoadBalancer{} + this.Id = id + this.CreatedAt = createdAt + this.UpdatedAt = updatedAt + this.Name = name + this.Provider = provider + this.Ports = ports + return &this +} + +// NewLoadBalancerWithDefaults instantiates a new LoadBalancer object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerWithDefaults() *LoadBalancer { + this := LoadBalancer{} + return &this +} + +// GetId returns the Id field value +func (o *LoadBalancer) GetId() string { + if o == nil { + var ret string + return ret + } + + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *LoadBalancer) SetId(v string) { + o.Id = v +} + +// GetCreatedAt returns the CreatedAt field value +func (o *LoadBalancer) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value +func (o *LoadBalancer) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetUpdatedAt returns the UpdatedAt field value +func (o *LoadBalancer) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value +func (o *LoadBalancer) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// GetName returns the Name field value +func (o *LoadBalancer) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *LoadBalancer) SetName(v string) { + o.Name = v +} + +// GetProvider returns the Provider field value +func (o *LoadBalancer) GetProvider() Provider { + if o == nil { + var ret Provider + return ret + } + + return o.Provider +} + +// GetProviderOk returns a tuple with the Provider field value +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetProviderOk() (*Provider, bool) { + if o == nil { + return nil, false + } + return &o.Provider, true +} + +// SetProvider sets field value +func (o *LoadBalancer) SetProvider(v Provider) { + o.Provider = v +} + +// GetPorts returns the Ports field value +func (o *LoadBalancer) GetPorts() []LoadBalancerPort { + if o == nil { + var ret []LoadBalancerPort + return ret + } + + return o.Ports +} + +// GetPortsOk returns a tuple with the Ports field value +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetPortsOk() ([]LoadBalancerPort, bool) { + if o == nil { + return nil, false + } + return o.Ports, true +} + +// SetPorts sets field value +func (o *LoadBalancer) SetPorts(v []LoadBalancerPort) { + o.Ports = v +} + +// GetPools returns the Pools field value if set, zero value otherwise. +func (o *LoadBalancer) GetPools() [][]LoadBalancerPoolShort { + if o == nil || IsNil(o.Pools) { + var ret [][]LoadBalancerPoolShort + return ret + } + return o.Pools +} + +// GetPoolsOk returns a tuple with the Pools field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetPoolsOk() ([][]LoadBalancerPoolShort, bool) { + if o == nil || IsNil(o.Pools) { + return nil, false + } + return o.Pools, true +} + +// HasPools returns a boolean if a field has been set. +func (o *LoadBalancer) HasPools() bool { + if o != nil && !IsNil(o.Pools) { + return true + } + + return false +} + +// SetPools gets a reference to the given []LoadBalancerPoolShort and assigns it to the Pools field. +func (o *LoadBalancer) SetPools(v [][]LoadBalancerPoolShort) { + o.Pools = v +} + +// GetIps returns the Ips field value if set, zero value otherwise. +func (o *LoadBalancer) GetIps() []string { + if o == nil || IsNil(o.Ips) { + var ret []string + return ret + } + return o.Ips +} + +// GetIpsOk returns a tuple with the Ips field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetIpsOk() ([]string, bool) { + if o == nil || IsNil(o.Ips) { + return nil, false + } + return o.Ips, true +} + +// HasIps returns a boolean if a field has been set. +func (o *LoadBalancer) HasIps() bool { + if o != nil && !IsNil(o.Ips) { + return true + } + + return false +} + +// SetIps gets a reference to the given []string and assigns it to the Ips field. +func (o *LoadBalancer) SetIps(v []string) { + o.Ips = v +} + +// GetLocation returns the Location field value if set, zero value otherwise. +func (o *LoadBalancer) GetLocation() LoadBalancerLocation { + if o == nil || IsNil(o.Location) { + var ret LoadBalancerLocation + return ret + } + return *o.Location +} + +// GetLocationOk returns a tuple with the Location field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancer) GetLocationOk() (*LoadBalancerLocation, bool) { + if o == nil || IsNil(o.Location) { + return nil, false + } + return o.Location, true +} + +// HasLocation returns a boolean if a field has been set. +func (o *LoadBalancer) HasLocation() bool { + if o != nil && !IsNil(o.Location) { + return true + } + + return false +} + +// SetLocation gets a reference to the given LoadBalancerLocation and assigns it to the Location field. +func (o *LoadBalancer) SetLocation(v LoadBalancerLocation) { + o.Location = &v +} + +func (o LoadBalancer) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancer) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["id"] = o.Id + toSerialize["created_at"] = o.CreatedAt + toSerialize["updated_at"] = o.UpdatedAt + toSerialize["name"] = o.Name + toSerialize["provider"] = o.Provider + toSerialize["ports"] = o.Ports + if !IsNil(o.Pools) { + toSerialize["pools"] = o.Pools + } + if !IsNil(o.Ips) { + toSerialize["ips"] = o.Ips + } + if !IsNil(o.Location) { + toSerialize["location"] = o.Location + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancer) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancer := _LoadBalancer{} + + err = json.Unmarshal(bytes, &varLoadBalancer) + + if err != nil { + return err + } + + *o = LoadBalancer(varLoadBalancer) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "created_at") + delete(additionalProperties, "updated_at") + delete(additionalProperties, "name") + delete(additionalProperties, "provider") + delete(additionalProperties, "ports") + delete(additionalProperties, "pools") + delete(additionalProperties, "ips") + delete(additionalProperties, "location") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancer struct { + value *LoadBalancer + isSet bool +} + +func (v NullableLoadBalancer) Get() *LoadBalancer { + return v.value +} + +func (v *NullableLoadBalancer) Set(val *LoadBalancer) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancer) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancer) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancer(val *LoadBalancer) *NullableLoadBalancer { + return &NullableLoadBalancer{value: val, isSet: true} +} + +func (v NullableLoadBalancer) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancer) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_collection.go b/internal/loadbalancers/api/v1/model_load_balancer_collection.go new file mode 100644 index 00000000..4159c5f8 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_collection.go @@ -0,0 +1,144 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerCollection type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerCollection{} + +// LoadBalancerCollection struct for LoadBalancerCollection +type LoadBalancerCollection struct { + Loadbalancers []LoadBalancer `json:"loadbalancers"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerCollection LoadBalancerCollection + +// NewLoadBalancerCollection instantiates a new LoadBalancerCollection object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerCollection(loadbalancers []LoadBalancer) *LoadBalancerCollection { + this := LoadBalancerCollection{} + this.Loadbalancers = loadbalancers + return &this +} + +// NewLoadBalancerCollectionWithDefaults instantiates a new LoadBalancerCollection object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerCollectionWithDefaults() *LoadBalancerCollection { + this := LoadBalancerCollection{} + return &this +} + +// GetLoadbalancers returns the Loadbalancers field value +func (o *LoadBalancerCollection) GetLoadbalancers() []LoadBalancer { + if o == nil { + var ret []LoadBalancer + return ret + } + + return o.Loadbalancers +} + +// GetLoadbalancersOk returns a tuple with the Loadbalancers field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerCollection) GetLoadbalancersOk() ([]LoadBalancer, bool) { + if o == nil { + return nil, false + } + return o.Loadbalancers, true +} + +// SetLoadbalancers sets field value +func (o *LoadBalancerCollection) SetLoadbalancers(v []LoadBalancer) { + o.Loadbalancers = v +} + +func (o LoadBalancerCollection) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerCollection) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["loadbalancers"] = o.Loadbalancers + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerCollection) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerCollection := _LoadBalancerCollection{} + + err = json.Unmarshal(bytes, &varLoadBalancerCollection) + + if err != nil { + return err + } + + *o = LoadBalancerCollection(varLoadBalancerCollection) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "loadbalancers") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerCollection struct { + value *LoadBalancerCollection + isSet bool +} + +func (v NullableLoadBalancerCollection) Get() *LoadBalancerCollection { + return v.value +} + +func (v *NullableLoadBalancerCollection) Set(val *LoadBalancerCollection) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerCollection) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerCollection) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerCollection(val *LoadBalancerCollection) *NullableLoadBalancerCollection { + return &NullableLoadBalancerCollection{value: val, isSet: true} +} + +func (v NullableLoadBalancerCollection) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerCollection) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_create.go b/internal/loadbalancers/api/v1/model_load_balancer_create.go new file mode 100644 index 00000000..23f3564d --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_create.go @@ -0,0 +1,232 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerCreate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerCreate{} + +// LoadBalancerCreate struct for LoadBalancerCreate +type LoadBalancerCreate struct { + // Name of load balancer + Name string `json:"name"` + // ID of location load balancer to be deployed in + LocationId string `json:"location_id"` + // Port IDs to associate with load balancer + PortIds []string `json:"port_ids"` + // ID of load balancer provider + ProviderId string `json:"provider_id"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerCreate LoadBalancerCreate + +// NewLoadBalancerCreate instantiates a new LoadBalancerCreate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerCreate(name string, locationId string, portIds []string, providerId string) *LoadBalancerCreate { + this := LoadBalancerCreate{} + this.Name = name + this.LocationId = locationId + this.PortIds = portIds + this.ProviderId = providerId + return &this +} + +// NewLoadBalancerCreateWithDefaults instantiates a new LoadBalancerCreate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerCreateWithDefaults() *LoadBalancerCreate { + this := LoadBalancerCreate{} + return &this +} + +// GetName returns the Name field value +func (o *LoadBalancerCreate) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerCreate) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *LoadBalancerCreate) SetName(v string) { + o.Name = v +} + +// GetLocationId returns the LocationId field value +func (o *LoadBalancerCreate) GetLocationId() string { + if o == nil { + var ret string + return ret + } + + return o.LocationId +} + +// GetLocationIdOk returns a tuple with the LocationId field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerCreate) GetLocationIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.LocationId, true +} + +// SetLocationId sets field value +func (o *LoadBalancerCreate) SetLocationId(v string) { + o.LocationId = v +} + +// GetPortIds returns the PortIds field value +func (o *LoadBalancerCreate) GetPortIds() []string { + if o == nil { + var ret []string + return ret + } + + return o.PortIds +} + +// GetPortIdsOk returns a tuple with the PortIds field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerCreate) GetPortIdsOk() ([]string, bool) { + if o == nil { + return nil, false + } + return o.PortIds, true +} + +// SetPortIds sets field value +func (o *LoadBalancerCreate) SetPortIds(v []string) { + o.PortIds = v +} + +// GetProviderId returns the ProviderId field value +func (o *LoadBalancerCreate) GetProviderId() string { + if o == nil { + var ret string + return ret + } + + return o.ProviderId +} + +// GetProviderIdOk returns a tuple with the ProviderId field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerCreate) GetProviderIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ProviderId, true +} + +// SetProviderId sets field value +func (o *LoadBalancerCreate) SetProviderId(v string) { + o.ProviderId = v +} + +func (o LoadBalancerCreate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerCreate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["name"] = o.Name + toSerialize["location_id"] = o.LocationId + toSerialize["port_ids"] = o.PortIds + toSerialize["provider_id"] = o.ProviderId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerCreate) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerCreate := _LoadBalancerCreate{} + + err = json.Unmarshal(bytes, &varLoadBalancerCreate) + + if err != nil { + return err + } + + *o = LoadBalancerCreate(varLoadBalancerCreate) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "location_id") + delete(additionalProperties, "port_ids") + delete(additionalProperties, "provider_id") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerCreate struct { + value *LoadBalancerCreate + isSet bool +} + +func (v NullableLoadBalancerCreate) Get() *LoadBalancerCreate { + return v.value +} + +func (v *NullableLoadBalancerCreate) Set(val *LoadBalancerCreate) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerCreate(val *LoadBalancerCreate) *NullableLoadBalancerCreate { + return &NullableLoadBalancerCreate{value: val, isSet: true} +} + +func (v NullableLoadBalancerCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_location.go b/internal/loadbalancers/api/v1/model_load_balancer_location.go new file mode 100644 index 00000000..f266f840 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_location.go @@ -0,0 +1,269 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "time" +) + +// checks if the LoadBalancerLocation type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerLocation{} + +// LoadBalancerLocation struct for LoadBalancerLocation +type LoadBalancerLocation struct { + // ID of a location + Id *string `json:"id,omitempty"` + // Date and time of creation + CreatedAt *time.Time `json:"created_at,omitempty"` + // Date and time of last update + UpdatedAt *time.Time `json:"updated_at,omitempty"` + // A name for the location + Name *string `json:"name,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerLocation LoadBalancerLocation + +// NewLoadBalancerLocation instantiates a new LoadBalancerLocation object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerLocation() *LoadBalancerLocation { + this := LoadBalancerLocation{} + return &this +} + +// NewLoadBalancerLocationWithDefaults instantiates a new LoadBalancerLocation object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerLocationWithDefaults() *LoadBalancerLocation { + this := LoadBalancerLocation{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *LoadBalancerLocation) GetId() string { + if o == nil || IsNil(o.Id) { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerLocation) GetIdOk() (*string, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *LoadBalancerLocation) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *LoadBalancerLocation) SetId(v string) { + o.Id = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *LoadBalancerLocation) GetCreatedAt() time.Time { + if o == nil || IsNil(o.CreatedAt) { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerLocation) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.CreatedAt) { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *LoadBalancerLocation) HasCreatedAt() bool { + if o != nil && !IsNil(o.CreatedAt) { + return true + } + + return false +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *LoadBalancerLocation) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *LoadBalancerLocation) GetUpdatedAt() time.Time { + if o == nil || IsNil(o.UpdatedAt) { + var ret time.Time + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerLocation) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.UpdatedAt) { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *LoadBalancerLocation) HasUpdatedAt() bool { + if o != nil && !IsNil(o.UpdatedAt) { + return true + } + + return false +} + +// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. +func (o *LoadBalancerLocation) SetUpdatedAt(v time.Time) { + o.UpdatedAt = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *LoadBalancerLocation) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerLocation) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *LoadBalancerLocation) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *LoadBalancerLocation) SetName(v string) { + o.Name = &v +} + +func (o LoadBalancerLocation) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerLocation) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } + if !IsNil(o.CreatedAt) { + toSerialize["created_at"] = o.CreatedAt + } + if !IsNil(o.UpdatedAt) { + toSerialize["updated_at"] = o.UpdatedAt + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerLocation) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerLocation := _LoadBalancerLocation{} + + err = json.Unmarshal(bytes, &varLoadBalancerLocation) + + if err != nil { + return err + } + + *o = LoadBalancerLocation(varLoadBalancerLocation) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "created_at") + delete(additionalProperties, "updated_at") + delete(additionalProperties, "name") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerLocation struct { + value *LoadBalancerLocation + isSet bool +} + +func (v NullableLoadBalancerLocation) Get() *LoadBalancerLocation { + return v.value +} + +func (v *NullableLoadBalancerLocation) Set(val *LoadBalancerLocation) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerLocation) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerLocation) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerLocation(val *LoadBalancerLocation) *NullableLoadBalancerLocation { + return &NullableLoadBalancerLocation{value: val, isSet: true} +} + +func (v NullableLoadBalancerLocation) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerLocation) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool.go b/internal/loadbalancers/api/v1/model_load_balancer_pool.go new file mode 100644 index 00000000..3e828ef7 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool.go @@ -0,0 +1,404 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "time" +) + +// checks if the LoadBalancerPool type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPool{} + +// LoadBalancerPool struct for LoadBalancerPool +type LoadBalancerPool struct { + // ID of the pool + Id string `json:"id"` + // Date and time of creation + CreatedAt time.Time `json:"created_at"` + // Date and time of last update + UpdatedAt time.Time `json:"updated_at"` + // A name for the pool + Name string `json:"name"` + Protocol LoadBalancerPoolProtocol `json:"protocol"` + // ID of project pool is assigned to + ProjectId string `json:"project_id"` + // A list of ports associated with the pool + Ports []LoadBalancerPort `json:"ports,omitempty"` + // A list of origins assigned to the pool + Origins []LoadBalancerPoolOrigin `json:"origins,omitempty"` + // A list of load balancers assigned to the pool + Loadbalancers []LoadBalancerShort `json:"loadbalancers,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPool LoadBalancerPool + +// NewLoadBalancerPool instantiates a new LoadBalancerPool object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPool(id string, createdAt time.Time, updatedAt time.Time, name string, protocol LoadBalancerPoolProtocol, projectId string) *LoadBalancerPool { + this := LoadBalancerPool{} + this.Id = id + this.CreatedAt = createdAt + this.UpdatedAt = updatedAt + this.Name = name + this.Protocol = protocol + this.ProjectId = projectId + return &this +} + +// NewLoadBalancerPoolWithDefaults instantiates a new LoadBalancerPool object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolWithDefaults() *LoadBalancerPool { + this := LoadBalancerPool{} + return &this +} + +// GetId returns the Id field value +func (o *LoadBalancerPool) GetId() string { + if o == nil { + var ret string + return ret + } + + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *LoadBalancerPool) SetId(v string) { + o.Id = v +} + +// GetCreatedAt returns the CreatedAt field value +func (o *LoadBalancerPool) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value +func (o *LoadBalancerPool) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetUpdatedAt returns the UpdatedAt field value +func (o *LoadBalancerPool) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value +func (o *LoadBalancerPool) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// GetName returns the Name field value +func (o *LoadBalancerPool) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *LoadBalancerPool) SetName(v string) { + o.Name = v +} + +// GetProtocol returns the Protocol field value +func (o *LoadBalancerPool) GetProtocol() LoadBalancerPoolProtocol { + if o == nil { + var ret LoadBalancerPoolProtocol + return ret + } + + return o.Protocol +} + +// GetProtocolOk returns a tuple with the Protocol field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetProtocolOk() (*LoadBalancerPoolProtocol, bool) { + if o == nil { + return nil, false + } + return &o.Protocol, true +} + +// SetProtocol sets field value +func (o *LoadBalancerPool) SetProtocol(v LoadBalancerPoolProtocol) { + o.Protocol = v +} + +// GetProjectId returns the ProjectId field value +func (o *LoadBalancerPool) GetProjectId() string { + if o == nil { + var ret string + return ret + } + + return o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetProjectIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ProjectId, true +} + +// SetProjectId sets field value +func (o *LoadBalancerPool) SetProjectId(v string) { + o.ProjectId = v +} + +// GetPorts returns the Ports field value if set, zero value otherwise. +func (o *LoadBalancerPool) GetPorts() []LoadBalancerPort { + if o == nil || IsNil(o.Ports) { + var ret []LoadBalancerPort + return ret + } + return o.Ports +} + +// GetPortsOk returns a tuple with the Ports field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetPortsOk() ([]LoadBalancerPort, bool) { + if o == nil || IsNil(o.Ports) { + return nil, false + } + return o.Ports, true +} + +// HasPorts returns a boolean if a field has been set. +func (o *LoadBalancerPool) HasPorts() bool { + if o != nil && !IsNil(o.Ports) { + return true + } + + return false +} + +// SetPorts gets a reference to the given []LoadBalancerPort and assigns it to the Ports field. +func (o *LoadBalancerPool) SetPorts(v []LoadBalancerPort) { + o.Ports = v +} + +// GetOrigins returns the Origins field value if set, zero value otherwise. +func (o *LoadBalancerPool) GetOrigins() []LoadBalancerPoolOrigin { + if o == nil || IsNil(o.Origins) { + var ret []LoadBalancerPoolOrigin + return ret + } + return o.Origins +} + +// GetOriginsOk returns a tuple with the Origins field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetOriginsOk() ([]LoadBalancerPoolOrigin, bool) { + if o == nil || IsNil(o.Origins) { + return nil, false + } + return o.Origins, true +} + +// HasOrigins returns a boolean if a field has been set. +func (o *LoadBalancerPool) HasOrigins() bool { + if o != nil && !IsNil(o.Origins) { + return true + } + + return false +} + +// SetOrigins gets a reference to the given []LoadBalancerPoolOrigin and assigns it to the Origins field. +func (o *LoadBalancerPool) SetOrigins(v []LoadBalancerPoolOrigin) { + o.Origins = v +} + +// GetLoadbalancers returns the Loadbalancers field value if set, zero value otherwise. +func (o *LoadBalancerPool) GetLoadbalancers() []LoadBalancerShort { + if o == nil || IsNil(o.Loadbalancers) { + var ret []LoadBalancerShort + return ret + } + return o.Loadbalancers +} + +// GetLoadbalancersOk returns a tuple with the Loadbalancers field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPool) GetLoadbalancersOk() ([]LoadBalancerShort, bool) { + if o == nil || IsNil(o.Loadbalancers) { + return nil, false + } + return o.Loadbalancers, true +} + +// HasLoadbalancers returns a boolean if a field has been set. +func (o *LoadBalancerPool) HasLoadbalancers() bool { + if o != nil && !IsNil(o.Loadbalancers) { + return true + } + + return false +} + +// SetLoadbalancers gets a reference to the given []LoadBalancerShort and assigns it to the Loadbalancers field. +func (o *LoadBalancerPool) SetLoadbalancers(v []LoadBalancerShort) { + o.Loadbalancers = v +} + +func (o LoadBalancerPool) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPool) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["id"] = o.Id + toSerialize["created_at"] = o.CreatedAt + toSerialize["updated_at"] = o.UpdatedAt + toSerialize["name"] = o.Name + toSerialize["protocol"] = o.Protocol + toSerialize["project_id"] = o.ProjectId + if !IsNil(o.Ports) { + toSerialize["ports"] = o.Ports + } + if !IsNil(o.Origins) { + toSerialize["origins"] = o.Origins + } + if !IsNil(o.Loadbalancers) { + toSerialize["loadbalancers"] = o.Loadbalancers + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPool) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPool := _LoadBalancerPool{} + + err = json.Unmarshal(bytes, &varLoadBalancerPool) + + if err != nil { + return err + } + + *o = LoadBalancerPool(varLoadBalancerPool) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "created_at") + delete(additionalProperties, "updated_at") + delete(additionalProperties, "name") + delete(additionalProperties, "protocol") + delete(additionalProperties, "project_id") + delete(additionalProperties, "ports") + delete(additionalProperties, "origins") + delete(additionalProperties, "loadbalancers") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPool struct { + value *LoadBalancerPool + isSet bool +} + +func (v NullableLoadBalancerPool) Get() *LoadBalancerPool { + return v.value +} + +func (v *NullableLoadBalancerPool) Set(val *LoadBalancerPool) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPool) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPool(val *LoadBalancerPool) *NullableLoadBalancerPool { + return &NullableLoadBalancerPool{value: val, isSet: true} +} + +func (v NullableLoadBalancerPool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_collection.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_collection.go new file mode 100644 index 00000000..5b9eee7e --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_collection.go @@ -0,0 +1,144 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPoolCollection type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPoolCollection{} + +// LoadBalancerPoolCollection struct for LoadBalancerPoolCollection +type LoadBalancerPoolCollection struct { + Pools []LoadBalancerPool `json:"pools"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPoolCollection LoadBalancerPoolCollection + +// NewLoadBalancerPoolCollection instantiates a new LoadBalancerPoolCollection object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPoolCollection(pools []LoadBalancerPool) *LoadBalancerPoolCollection { + this := LoadBalancerPoolCollection{} + this.Pools = pools + return &this +} + +// NewLoadBalancerPoolCollectionWithDefaults instantiates a new LoadBalancerPoolCollection object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolCollectionWithDefaults() *LoadBalancerPoolCollection { + this := LoadBalancerPoolCollection{} + return &this +} + +// GetPools returns the Pools field value +func (o *LoadBalancerPoolCollection) GetPools() []LoadBalancerPool { + if o == nil { + var ret []LoadBalancerPool + return ret + } + + return o.Pools +} + +// GetPoolsOk returns a tuple with the Pools field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolCollection) GetPoolsOk() ([]LoadBalancerPool, bool) { + if o == nil { + return nil, false + } + return o.Pools, true +} + +// SetPools sets field value +func (o *LoadBalancerPoolCollection) SetPools(v []LoadBalancerPool) { + o.Pools = v +} + +func (o LoadBalancerPoolCollection) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPoolCollection) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["pools"] = o.Pools + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPoolCollection) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPoolCollection := _LoadBalancerPoolCollection{} + + err = json.Unmarshal(bytes, &varLoadBalancerPoolCollection) + + if err != nil { + return err + } + + *o = LoadBalancerPoolCollection(varLoadBalancerPoolCollection) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "pools") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPoolCollection struct { + value *LoadBalancerPoolCollection + isSet bool +} + +func (v NullableLoadBalancerPoolCollection) Get() *LoadBalancerPoolCollection { + return v.value +} + +func (v *NullableLoadBalancerPoolCollection) Set(val *LoadBalancerPoolCollection) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolCollection) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolCollection) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolCollection(val *LoadBalancerPoolCollection) *NullableLoadBalancerPoolCollection { + return &NullableLoadBalancerPoolCollection{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolCollection) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolCollection) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_create.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_create.go new file mode 100644 index 00000000..966e95c4 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_create.go @@ -0,0 +1,249 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPoolCreate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPoolCreate{} + +// LoadBalancerPoolCreate struct for LoadBalancerPoolCreate +type LoadBalancerPoolCreate struct { + // Name of the load balancer pool + Name string `json:"name"` + Protocol LoadBalancerPoolCreateProtocol `json:"protocol"` + // Port ids to associate with pool + PortIds []string `json:"port_ids,omitempty"` + // Origin ids to associate with pool + OriginIds []string `json:"origin_ids,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPoolCreate LoadBalancerPoolCreate + +// NewLoadBalancerPoolCreate instantiates a new LoadBalancerPoolCreate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPoolCreate(name string, protocol LoadBalancerPoolCreateProtocol) *LoadBalancerPoolCreate { + this := LoadBalancerPoolCreate{} + this.Name = name + this.Protocol = protocol + return &this +} + +// NewLoadBalancerPoolCreateWithDefaults instantiates a new LoadBalancerPoolCreate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolCreateWithDefaults() *LoadBalancerPoolCreate { + this := LoadBalancerPoolCreate{} + return &this +} + +// GetName returns the Name field value +func (o *LoadBalancerPoolCreate) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolCreate) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *LoadBalancerPoolCreate) SetName(v string) { + o.Name = v +} + +// GetProtocol returns the Protocol field value +func (o *LoadBalancerPoolCreate) GetProtocol() LoadBalancerPoolCreateProtocol { + if o == nil { + var ret LoadBalancerPoolCreateProtocol + return ret + } + + return o.Protocol +} + +// GetProtocolOk returns a tuple with the Protocol field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolCreate) GetProtocolOk() (*LoadBalancerPoolCreateProtocol, bool) { + if o == nil { + return nil, false + } + return &o.Protocol, true +} + +// SetProtocol sets field value +func (o *LoadBalancerPoolCreate) SetProtocol(v LoadBalancerPoolCreateProtocol) { + o.Protocol = v +} + +// GetPortIds returns the PortIds field value if set, zero value otherwise. +func (o *LoadBalancerPoolCreate) GetPortIds() []string { + if o == nil || IsNil(o.PortIds) { + var ret []string + return ret + } + return o.PortIds +} + +// GetPortIdsOk returns a tuple with the PortIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolCreate) GetPortIdsOk() ([]string, bool) { + if o == nil || IsNil(o.PortIds) { + return nil, false + } + return o.PortIds, true +} + +// HasPortIds returns a boolean if a field has been set. +func (o *LoadBalancerPoolCreate) HasPortIds() bool { + if o != nil && !IsNil(o.PortIds) { + return true + } + + return false +} + +// SetPortIds gets a reference to the given []string and assigns it to the PortIds field. +func (o *LoadBalancerPoolCreate) SetPortIds(v []string) { + o.PortIds = v +} + +// GetOriginIds returns the OriginIds field value if set, zero value otherwise. +func (o *LoadBalancerPoolCreate) GetOriginIds() []string { + if o == nil || IsNil(o.OriginIds) { + var ret []string + return ret + } + return o.OriginIds +} + +// GetOriginIdsOk returns a tuple with the OriginIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolCreate) GetOriginIdsOk() ([]string, bool) { + if o == nil || IsNil(o.OriginIds) { + return nil, false + } + return o.OriginIds, true +} + +// HasOriginIds returns a boolean if a field has been set. +func (o *LoadBalancerPoolCreate) HasOriginIds() bool { + if o != nil && !IsNil(o.OriginIds) { + return true + } + + return false +} + +// SetOriginIds gets a reference to the given []string and assigns it to the OriginIds field. +func (o *LoadBalancerPoolCreate) SetOriginIds(v []string) { + o.OriginIds = v +} + +func (o LoadBalancerPoolCreate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPoolCreate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["name"] = o.Name + toSerialize["protocol"] = o.Protocol + if !IsNil(o.PortIds) { + toSerialize["port_ids"] = o.PortIds + } + if !IsNil(o.OriginIds) { + toSerialize["origin_ids"] = o.OriginIds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPoolCreate) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPoolCreate := _LoadBalancerPoolCreate{} + + err = json.Unmarshal(bytes, &varLoadBalancerPoolCreate) + + if err != nil { + return err + } + + *o = LoadBalancerPoolCreate(varLoadBalancerPoolCreate) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "protocol") + delete(additionalProperties, "port_ids") + delete(additionalProperties, "origin_ids") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPoolCreate struct { + value *LoadBalancerPoolCreate + isSet bool +} + +func (v NullableLoadBalancerPoolCreate) Get() *LoadBalancerPoolCreate { + return v.value +} + +func (v *NullableLoadBalancerPoolCreate) Set(val *LoadBalancerPoolCreate) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolCreate(val *LoadBalancerPoolCreate) *NullableLoadBalancerPoolCreate { + return &NullableLoadBalancerPoolCreate{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_create_protocol.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_create_protocol.go new file mode 100644 index 00000000..bf24e1b4 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_create_protocol.go @@ -0,0 +1,115 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "fmt" +) + +// LoadBalancerPoolCreateProtocol - Protocol to use for pool +type LoadBalancerPoolCreateProtocol struct { + LoadBalancerPoolProtocol *LoadBalancerPoolProtocol +} + +// LoadBalancerPoolProtocolAsLoadBalancerPoolCreateProtocol is a convenience function that returns LoadBalancerPoolProtocol wrapped in LoadBalancerPoolCreateProtocol +func LoadBalancerPoolProtocolAsLoadBalancerPoolCreateProtocol(v *LoadBalancerPoolProtocol) LoadBalancerPoolCreateProtocol { + return LoadBalancerPoolCreateProtocol{ + LoadBalancerPoolProtocol: v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *LoadBalancerPoolCreateProtocol) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into LoadBalancerPoolProtocol + err = newStrictDecoder(data).Decode(&dst.LoadBalancerPoolProtocol) + if err == nil { + jsonLoadBalancerPoolProtocol, _ := json.Marshal(dst.LoadBalancerPoolProtocol) + if string(jsonLoadBalancerPoolProtocol) == "{}" { // empty struct + dst.LoadBalancerPoolProtocol = nil + } else { + match++ + } + } else { + dst.LoadBalancerPoolProtocol = nil + } + + if match > 1 { // more than 1 match + // reset to nil + dst.LoadBalancerPoolProtocol = nil + + return fmt.Errorf("data matches more than one schema in oneOf(LoadBalancerPoolCreateProtocol)") + } else if match == 1 { + return nil // exactly one match + } else { // no match + return fmt.Errorf("data failed to match schemas in oneOf(LoadBalancerPoolCreateProtocol)") + } +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src LoadBalancerPoolCreateProtocol) MarshalJSON() ([]byte, error) { + if src.LoadBalancerPoolProtocol != nil { + return json.Marshal(&src.LoadBalancerPoolProtocol) + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance +func (obj *LoadBalancerPoolCreateProtocol) GetActualInstance() interface{} { + if obj == nil { + return nil + } + if obj.LoadBalancerPoolProtocol != nil { + return obj.LoadBalancerPoolProtocol + } + + // all schemas are nil + return nil +} + +type NullableLoadBalancerPoolCreateProtocol struct { + value *LoadBalancerPoolCreateProtocol + isSet bool +} + +func (v NullableLoadBalancerPoolCreateProtocol) Get() *LoadBalancerPoolCreateProtocol { + return v.value +} + +func (v *NullableLoadBalancerPoolCreateProtocol) Set(val *LoadBalancerPoolCreateProtocol) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolCreateProtocol) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolCreateProtocol) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolCreateProtocol(val *LoadBalancerPoolCreateProtocol) *NullableLoadBalancerPoolCreateProtocol { + return &NullableLoadBalancerPoolCreateProtocol{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolCreateProtocol) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolCreateProtocol) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_origin.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin.go new file mode 100644 index 00000000..63e8e535 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin.go @@ -0,0 +1,348 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "time" +) + +// checks if the LoadBalancerPoolOrigin type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPoolOrigin{} + +// LoadBalancerPoolOrigin struct for LoadBalancerPoolOrigin +type LoadBalancerPoolOrigin struct { + // ID of a port + Id string `json:"id"` + // Date and time of creation + CreatedAt time.Time `json:"created_at"` + // Date and time of last update + UpdatedAt time.Time `json:"updated_at"` + // A name for the origin + Name string `json:"name"` + // IP address of the origin + Target string `json:"target"` + PortNumber LoadBalancerPoolOriginPortNumber `json:"port_number"` + // If the origin is enabled + Active bool `json:"active"` + // ID of the pool the origin belongs to + PoolId string `json:"pool_id"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPoolOrigin LoadBalancerPoolOrigin + +// NewLoadBalancerPoolOrigin instantiates a new LoadBalancerPoolOrigin object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPoolOrigin(id string, createdAt time.Time, updatedAt time.Time, name string, target string, portNumber LoadBalancerPoolOriginPortNumber, active bool, poolId string) *LoadBalancerPoolOrigin { + this := LoadBalancerPoolOrigin{} + this.Id = id + this.CreatedAt = createdAt + this.UpdatedAt = updatedAt + this.Name = name + this.Target = target + this.PortNumber = portNumber + this.Active = active + this.PoolId = poolId + return &this +} + +// NewLoadBalancerPoolOriginWithDefaults instantiates a new LoadBalancerPoolOrigin object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolOriginWithDefaults() *LoadBalancerPoolOrigin { + this := LoadBalancerPoolOrigin{} + return &this +} + +// GetId returns the Id field value +func (o *LoadBalancerPoolOrigin) GetId() string { + if o == nil { + var ret string + return ret + } + + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOrigin) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *LoadBalancerPoolOrigin) SetId(v string) { + o.Id = v +} + +// GetCreatedAt returns the CreatedAt field value +func (o *LoadBalancerPoolOrigin) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOrigin) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value +func (o *LoadBalancerPoolOrigin) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetUpdatedAt returns the UpdatedAt field value +func (o *LoadBalancerPoolOrigin) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOrigin) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value +func (o *LoadBalancerPoolOrigin) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// GetName returns the Name field value +func (o *LoadBalancerPoolOrigin) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOrigin) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *LoadBalancerPoolOrigin) SetName(v string) { + o.Name = v +} + +// GetTarget returns the Target field value +func (o *LoadBalancerPoolOrigin) GetTarget() string { + if o == nil { + var ret string + return ret + } + + return o.Target +} + +// GetTargetOk returns a tuple with the Target field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOrigin) GetTargetOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Target, true +} + +// SetTarget sets field value +func (o *LoadBalancerPoolOrigin) SetTarget(v string) { + o.Target = v +} + +// GetPortNumber returns the PortNumber field value +func (o *LoadBalancerPoolOrigin) GetPortNumber() LoadBalancerPoolOriginPortNumber { + if o == nil { + var ret LoadBalancerPoolOriginPortNumber + return ret + } + + return o.PortNumber +} + +// GetPortNumberOk returns a tuple with the PortNumber field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOrigin) GetPortNumberOk() (*LoadBalancerPoolOriginPortNumber, bool) { + if o == nil { + return nil, false + } + return &o.PortNumber, true +} + +// SetPortNumber sets field value +func (o *LoadBalancerPoolOrigin) SetPortNumber(v LoadBalancerPoolOriginPortNumber) { + o.PortNumber = v +} + +// GetActive returns the Active field value +func (o *LoadBalancerPoolOrigin) GetActive() bool { + if o == nil { + var ret bool + return ret + } + + return o.Active +} + +// GetActiveOk returns a tuple with the Active field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOrigin) GetActiveOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Active, true +} + +// SetActive sets field value +func (o *LoadBalancerPoolOrigin) SetActive(v bool) { + o.Active = v +} + +// GetPoolId returns the PoolId field value +func (o *LoadBalancerPoolOrigin) GetPoolId() string { + if o == nil { + var ret string + return ret + } + + return o.PoolId +} + +// GetPoolIdOk returns a tuple with the PoolId field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOrigin) GetPoolIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PoolId, true +} + +// SetPoolId sets field value +func (o *LoadBalancerPoolOrigin) SetPoolId(v string) { + o.PoolId = v +} + +func (o LoadBalancerPoolOrigin) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPoolOrigin) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["id"] = o.Id + toSerialize["created_at"] = o.CreatedAt + toSerialize["updated_at"] = o.UpdatedAt + toSerialize["name"] = o.Name + toSerialize["target"] = o.Target + toSerialize["port_number"] = o.PortNumber + toSerialize["active"] = o.Active + toSerialize["pool_id"] = o.PoolId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPoolOrigin) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPoolOrigin := _LoadBalancerPoolOrigin{} + + err = json.Unmarshal(bytes, &varLoadBalancerPoolOrigin) + + if err != nil { + return err + } + + *o = LoadBalancerPoolOrigin(varLoadBalancerPoolOrigin) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "created_at") + delete(additionalProperties, "updated_at") + delete(additionalProperties, "name") + delete(additionalProperties, "target") + delete(additionalProperties, "port_number") + delete(additionalProperties, "active") + delete(additionalProperties, "pool_id") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPoolOrigin struct { + value *LoadBalancerPoolOrigin + isSet bool +} + +func (v NullableLoadBalancerPoolOrigin) Get() *LoadBalancerPoolOrigin { + return v.value +} + +func (v *NullableLoadBalancerPoolOrigin) Set(val *LoadBalancerPoolOrigin) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolOrigin) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolOrigin) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolOrigin(val *LoadBalancerPoolOrigin) *NullableLoadBalancerPoolOrigin { + return &NullableLoadBalancerPoolOrigin{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolOrigin) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolOrigin) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_collection.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_collection.go new file mode 100644 index 00000000..5bc937fd --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_collection.go @@ -0,0 +1,144 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPoolOriginCollection type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPoolOriginCollection{} + +// LoadBalancerPoolOriginCollection struct for LoadBalancerPoolOriginCollection +type LoadBalancerPoolOriginCollection struct { + Origins []LoadBalancerPoolOrigin `json:"origins"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPoolOriginCollection LoadBalancerPoolOriginCollection + +// NewLoadBalancerPoolOriginCollection instantiates a new LoadBalancerPoolOriginCollection object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPoolOriginCollection(origins []LoadBalancerPoolOrigin) *LoadBalancerPoolOriginCollection { + this := LoadBalancerPoolOriginCollection{} + this.Origins = origins + return &this +} + +// NewLoadBalancerPoolOriginCollectionWithDefaults instantiates a new LoadBalancerPoolOriginCollection object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolOriginCollectionWithDefaults() *LoadBalancerPoolOriginCollection { + this := LoadBalancerPoolOriginCollection{} + return &this +} + +// GetOrigins returns the Origins field value +func (o *LoadBalancerPoolOriginCollection) GetOrigins() []LoadBalancerPoolOrigin { + if o == nil { + var ret []LoadBalancerPoolOrigin + return ret + } + + return o.Origins +} + +// GetOriginsOk returns a tuple with the Origins field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginCollection) GetOriginsOk() ([]LoadBalancerPoolOrigin, bool) { + if o == nil { + return nil, false + } + return o.Origins, true +} + +// SetOrigins sets field value +func (o *LoadBalancerPoolOriginCollection) SetOrigins(v []LoadBalancerPoolOrigin) { + o.Origins = v +} + +func (o LoadBalancerPoolOriginCollection) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPoolOriginCollection) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["origins"] = o.Origins + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPoolOriginCollection) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPoolOriginCollection := _LoadBalancerPoolOriginCollection{} + + err = json.Unmarshal(bytes, &varLoadBalancerPoolOriginCollection) + + if err != nil { + return err + } + + *o = LoadBalancerPoolOriginCollection(varLoadBalancerPoolOriginCollection) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "origins") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPoolOriginCollection struct { + value *LoadBalancerPoolOriginCollection + isSet bool +} + +func (v NullableLoadBalancerPoolOriginCollection) Get() *LoadBalancerPoolOriginCollection { + return v.value +} + +func (v *NullableLoadBalancerPoolOriginCollection) Set(val *LoadBalancerPoolOriginCollection) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolOriginCollection) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolOriginCollection) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolOriginCollection(val *LoadBalancerPoolOriginCollection) *NullableLoadBalancerPoolOriginCollection { + return &NullableLoadBalancerPoolOriginCollection{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolOriginCollection) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolOriginCollection) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_create.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_create.go new file mode 100644 index 00000000..5923b0c1 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_create.go @@ -0,0 +1,260 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPoolOriginCreate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPoolOriginCreate{} + +// LoadBalancerPoolOriginCreate struct for LoadBalancerPoolOriginCreate +type LoadBalancerPoolOriginCreate struct { + // A name for the origin + Name string `json:"name"` + // IP address of the origin + Target string `json:"target"` + PortNumber LoadBalancerPoolOriginPortNumber `json:"port_number"` + // If the origin is activated + Active bool `json:"active"` + // ID of the pool the origin belongs to + PoolId string `json:"pool_id"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPoolOriginCreate LoadBalancerPoolOriginCreate + +// NewLoadBalancerPoolOriginCreate instantiates a new LoadBalancerPoolOriginCreate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPoolOriginCreate(name string, target string, portNumber LoadBalancerPoolOriginPortNumber, active bool, poolId string) *LoadBalancerPoolOriginCreate { + this := LoadBalancerPoolOriginCreate{} + this.Name = name + this.Target = target + this.PortNumber = portNumber + this.Active = active + this.PoolId = poolId + return &this +} + +// NewLoadBalancerPoolOriginCreateWithDefaults instantiates a new LoadBalancerPoolOriginCreate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolOriginCreateWithDefaults() *LoadBalancerPoolOriginCreate { + this := LoadBalancerPoolOriginCreate{} + return &this +} + +// GetName returns the Name field value +func (o *LoadBalancerPoolOriginCreate) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginCreate) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *LoadBalancerPoolOriginCreate) SetName(v string) { + o.Name = v +} + +// GetTarget returns the Target field value +func (o *LoadBalancerPoolOriginCreate) GetTarget() string { + if o == nil { + var ret string + return ret + } + + return o.Target +} + +// GetTargetOk returns a tuple with the Target field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginCreate) GetTargetOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Target, true +} + +// SetTarget sets field value +func (o *LoadBalancerPoolOriginCreate) SetTarget(v string) { + o.Target = v +} + +// GetPortNumber returns the PortNumber field value +func (o *LoadBalancerPoolOriginCreate) GetPortNumber() LoadBalancerPoolOriginPortNumber { + if o == nil { + var ret LoadBalancerPoolOriginPortNumber + return ret + } + + return o.PortNumber +} + +// GetPortNumberOk returns a tuple with the PortNumber field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginCreate) GetPortNumberOk() (*LoadBalancerPoolOriginPortNumber, bool) { + if o == nil { + return nil, false + } + return &o.PortNumber, true +} + +// SetPortNumber sets field value +func (o *LoadBalancerPoolOriginCreate) SetPortNumber(v LoadBalancerPoolOriginPortNumber) { + o.PortNumber = v +} + +// GetActive returns the Active field value +func (o *LoadBalancerPoolOriginCreate) GetActive() bool { + if o == nil { + var ret bool + return ret + } + + return o.Active +} + +// GetActiveOk returns a tuple with the Active field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginCreate) GetActiveOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Active, true +} + +// SetActive sets field value +func (o *LoadBalancerPoolOriginCreate) SetActive(v bool) { + o.Active = v +} + +// GetPoolId returns the PoolId field value +func (o *LoadBalancerPoolOriginCreate) GetPoolId() string { + if o == nil { + var ret string + return ret + } + + return o.PoolId +} + +// GetPoolIdOk returns a tuple with the PoolId field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginCreate) GetPoolIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PoolId, true +} + +// SetPoolId sets field value +func (o *LoadBalancerPoolOriginCreate) SetPoolId(v string) { + o.PoolId = v +} + +func (o LoadBalancerPoolOriginCreate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPoolOriginCreate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["name"] = o.Name + toSerialize["target"] = o.Target + toSerialize["port_number"] = o.PortNumber + toSerialize["active"] = o.Active + toSerialize["pool_id"] = o.PoolId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPoolOriginCreate) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPoolOriginCreate := _LoadBalancerPoolOriginCreate{} + + err = json.Unmarshal(bytes, &varLoadBalancerPoolOriginCreate) + + if err != nil { + return err + } + + *o = LoadBalancerPoolOriginCreate(varLoadBalancerPoolOriginCreate) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "target") + delete(additionalProperties, "port_number") + delete(additionalProperties, "active") + delete(additionalProperties, "pool_id") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPoolOriginCreate struct { + value *LoadBalancerPoolOriginCreate + isSet bool +} + +func (v NullableLoadBalancerPoolOriginCreate) Get() *LoadBalancerPoolOriginCreate { + return v.value +} + +func (v *NullableLoadBalancerPoolOriginCreate) Set(val *LoadBalancerPoolOriginCreate) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolOriginCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolOriginCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolOriginCreate(val *LoadBalancerPoolOriginCreate) *NullableLoadBalancerPoolOriginCreate { + return &NullableLoadBalancerPoolOriginCreate{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolOriginCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolOriginCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_port_number.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_port_number.go new file mode 100644 index 00000000..10acd5c0 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_port_number.go @@ -0,0 +1,115 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "fmt" +) + +// LoadBalancerPoolOriginPortNumber - Listening port of the origin +type LoadBalancerPoolOriginPortNumber struct { + Int32 *int32 +} + +// int32AsLoadBalancerPoolOriginPortNumber is a convenience function that returns int32 wrapped in LoadBalancerPoolOriginPortNumber +func Int32AsLoadBalancerPoolOriginPortNumber(v *int32) LoadBalancerPoolOriginPortNumber { + return LoadBalancerPoolOriginPortNumber{ + Int32: v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *LoadBalancerPoolOriginPortNumber) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into Int32 + err = newStrictDecoder(data).Decode(&dst.Int32) + if err == nil { + jsonInt32, _ := json.Marshal(dst.Int32) + if string(jsonInt32) == "{}" { // empty struct + dst.Int32 = nil + } else { + match++ + } + } else { + dst.Int32 = nil + } + + if match > 1 { // more than 1 match + // reset to nil + dst.Int32 = nil + + return fmt.Errorf("data matches more than one schema in oneOf(LoadBalancerPoolOriginPortNumber)") + } else if match == 1 { + return nil // exactly one match + } else { // no match + return fmt.Errorf("data failed to match schemas in oneOf(LoadBalancerPoolOriginPortNumber)") + } +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src LoadBalancerPoolOriginPortNumber) MarshalJSON() ([]byte, error) { + if src.Int32 != nil { + return json.Marshal(&src.Int32) + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance +func (obj *LoadBalancerPoolOriginPortNumber) GetActualInstance() interface{} { + if obj == nil { + return nil + } + if obj.Int32 != nil { + return obj.Int32 + } + + // all schemas are nil + return nil +} + +type NullableLoadBalancerPoolOriginPortNumber struct { + value *LoadBalancerPoolOriginPortNumber + isSet bool +} + +func (v NullableLoadBalancerPoolOriginPortNumber) Get() *LoadBalancerPoolOriginPortNumber { + return v.value +} + +func (v *NullableLoadBalancerPoolOriginPortNumber) Set(val *LoadBalancerPoolOriginPortNumber) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolOriginPortNumber) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolOriginPortNumber) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolOriginPortNumber(val *LoadBalancerPoolOriginPortNumber) *NullableLoadBalancerPoolOriginPortNumber { + return &NullableLoadBalancerPoolOriginPortNumber{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolOriginPortNumber) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolOriginPortNumber) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_update.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_update.go new file mode 100644 index 00000000..0aa26d89 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_origin_update.go @@ -0,0 +1,267 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPoolOriginUpdate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPoolOriginUpdate{} + +// LoadBalancerPoolOriginUpdate struct for LoadBalancerPoolOriginUpdate +type LoadBalancerPoolOriginUpdate struct { + // A name for the origin + Name *string `json:"name,omitempty"` + // IP address of the origin + Target *string `json:"target,omitempty"` + PortNumber *LoadBalancerPoolOriginPortNumber `json:"port_number,omitempty"` + // If the origin is active + Active *bool `json:"active,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPoolOriginUpdate LoadBalancerPoolOriginUpdate + +// NewLoadBalancerPoolOriginUpdate instantiates a new LoadBalancerPoolOriginUpdate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPoolOriginUpdate() *LoadBalancerPoolOriginUpdate { + this := LoadBalancerPoolOriginUpdate{} + return &this +} + +// NewLoadBalancerPoolOriginUpdateWithDefaults instantiates a new LoadBalancerPoolOriginUpdate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolOriginUpdateWithDefaults() *LoadBalancerPoolOriginUpdate { + this := LoadBalancerPoolOriginUpdate{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *LoadBalancerPoolOriginUpdate) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginUpdate) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *LoadBalancerPoolOriginUpdate) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *LoadBalancerPoolOriginUpdate) SetName(v string) { + o.Name = &v +} + +// GetTarget returns the Target field value if set, zero value otherwise. +func (o *LoadBalancerPoolOriginUpdate) GetTarget() string { + if o == nil || IsNil(o.Target) { + var ret string + return ret + } + return *o.Target +} + +// GetTargetOk returns a tuple with the Target field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginUpdate) GetTargetOk() (*string, bool) { + if o == nil || IsNil(o.Target) { + return nil, false + } + return o.Target, true +} + +// HasTarget returns a boolean if a field has been set. +func (o *LoadBalancerPoolOriginUpdate) HasTarget() bool { + if o != nil && !IsNil(o.Target) { + return true + } + + return false +} + +// SetTarget gets a reference to the given string and assigns it to the Target field. +func (o *LoadBalancerPoolOriginUpdate) SetTarget(v string) { + o.Target = &v +} + +// GetPortNumber returns the PortNumber field value if set, zero value otherwise. +func (o *LoadBalancerPoolOriginUpdate) GetPortNumber() LoadBalancerPoolOriginPortNumber { + if o == nil || IsNil(o.PortNumber) { + var ret LoadBalancerPoolOriginPortNumber + return ret + } + return *o.PortNumber +} + +// GetPortNumberOk returns a tuple with the PortNumber field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginUpdate) GetPortNumberOk() (*LoadBalancerPoolOriginPortNumber, bool) { + if o == nil || IsNil(o.PortNumber) { + return nil, false + } + return o.PortNumber, true +} + +// HasPortNumber returns a boolean if a field has been set. +func (o *LoadBalancerPoolOriginUpdate) HasPortNumber() bool { + if o != nil && !IsNil(o.PortNumber) { + return true + } + + return false +} + +// SetPortNumber gets a reference to the given LoadBalancerPoolOriginPortNumber and assigns it to the PortNumber field. +func (o *LoadBalancerPoolOriginUpdate) SetPortNumber(v LoadBalancerPoolOriginPortNumber) { + o.PortNumber = &v +} + +// GetActive returns the Active field value if set, zero value otherwise. +func (o *LoadBalancerPoolOriginUpdate) GetActive() bool { + if o == nil || IsNil(o.Active) { + var ret bool + return ret + } + return *o.Active +} + +// GetActiveOk returns a tuple with the Active field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolOriginUpdate) GetActiveOk() (*bool, bool) { + if o == nil || IsNil(o.Active) { + return nil, false + } + return o.Active, true +} + +// HasActive returns a boolean if a field has been set. +func (o *LoadBalancerPoolOriginUpdate) HasActive() bool { + if o != nil && !IsNil(o.Active) { + return true + } + + return false +} + +// SetActive gets a reference to the given bool and assigns it to the Active field. +func (o *LoadBalancerPoolOriginUpdate) SetActive(v bool) { + o.Active = &v +} + +func (o LoadBalancerPoolOriginUpdate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPoolOriginUpdate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Target) { + toSerialize["target"] = o.Target + } + if !IsNil(o.PortNumber) { + toSerialize["port_number"] = o.PortNumber + } + if !IsNil(o.Active) { + toSerialize["active"] = o.Active + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPoolOriginUpdate) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPoolOriginUpdate := _LoadBalancerPoolOriginUpdate{} + + err = json.Unmarshal(bytes, &varLoadBalancerPoolOriginUpdate) + + if err != nil { + return err + } + + *o = LoadBalancerPoolOriginUpdate(varLoadBalancerPoolOriginUpdate) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "target") + delete(additionalProperties, "port_number") + delete(additionalProperties, "active") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPoolOriginUpdate struct { + value *LoadBalancerPoolOriginUpdate + isSet bool +} + +func (v NullableLoadBalancerPoolOriginUpdate) Get() *LoadBalancerPoolOriginUpdate { + return v.value +} + +func (v *NullableLoadBalancerPoolOriginUpdate) Set(val *LoadBalancerPoolOriginUpdate) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolOriginUpdate) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolOriginUpdate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolOriginUpdate(val *LoadBalancerPoolOriginUpdate) *NullableLoadBalancerPoolOriginUpdate { + return &NullableLoadBalancerPoolOriginUpdate{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolOriginUpdate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolOriginUpdate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_protocol.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_protocol.go new file mode 100644 index 00000000..b06edb0f --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_protocol.go @@ -0,0 +1,110 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "fmt" +) + +// LoadBalancerPoolProtocol the model 'LoadBalancerPoolProtocol' +type LoadBalancerPoolProtocol string + +// List of LoadBalancerPoolProtocol +const ( + LOADBALANCERPOOLPROTOCOL_TCP LoadBalancerPoolProtocol = "tcp" + LOADBALANCERPOOLPROTOCOL_UDP LoadBalancerPoolProtocol = "udp" +) + +// All allowed values of LoadBalancerPoolProtocol enum +var AllowedLoadBalancerPoolProtocolEnumValues = []LoadBalancerPoolProtocol{ + "tcp", + "udp", +} + +func (v *LoadBalancerPoolProtocol) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := LoadBalancerPoolProtocol(value) + for _, existing := range AllowedLoadBalancerPoolProtocolEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid LoadBalancerPoolProtocol", value) +} + +// NewLoadBalancerPoolProtocolFromValue returns a pointer to a valid LoadBalancerPoolProtocol +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewLoadBalancerPoolProtocolFromValue(v string) (*LoadBalancerPoolProtocol, error) { + ev := LoadBalancerPoolProtocol(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for LoadBalancerPoolProtocol: valid values are %v", v, AllowedLoadBalancerPoolProtocolEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v LoadBalancerPoolProtocol) IsValid() bool { + for _, existing := range AllowedLoadBalancerPoolProtocolEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to LoadBalancerPoolProtocol value +func (v LoadBalancerPoolProtocol) Ptr() *LoadBalancerPoolProtocol { + return &v +} + +type NullableLoadBalancerPoolProtocol struct { + value *LoadBalancerPoolProtocol + isSet bool +} + +func (v NullableLoadBalancerPoolProtocol) Get() *LoadBalancerPoolProtocol { + return v.value +} + +func (v *NullableLoadBalancerPoolProtocol) Set(val *LoadBalancerPoolProtocol) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolProtocol) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolProtocol) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolProtocol(val *LoadBalancerPoolProtocol) *NullableLoadBalancerPoolProtocol { + return &NullableLoadBalancerPoolProtocol{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolProtocol) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolProtocol) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_short.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_short.go new file mode 100644 index 00000000..31593cbd --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_short.go @@ -0,0 +1,270 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "time" +) + +// checks if the LoadBalancerPoolShort type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPoolShort{} + +// LoadBalancerPoolShort struct for LoadBalancerPoolShort +type LoadBalancerPoolShort struct { + // ID of a pool + Id interface{} `json:"id,omitempty"` + // A name for the pool + Name *string `json:"name,omitempty"` + // Date and time of creation + CreatedAt *time.Time `json:"created_at,omitempty"` + // Date and time of last update + UpdatedAt *time.Time `json:"updated_at,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPoolShort LoadBalancerPoolShort + +// NewLoadBalancerPoolShort instantiates a new LoadBalancerPoolShort object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPoolShort() *LoadBalancerPoolShort { + this := LoadBalancerPoolShort{} + return &this +} + +// NewLoadBalancerPoolShortWithDefaults instantiates a new LoadBalancerPoolShort object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolShortWithDefaults() *LoadBalancerPoolShort { + this := LoadBalancerPoolShort{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *LoadBalancerPoolShort) GetId() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *LoadBalancerPoolShort) GetIdOk() (*interface{}, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return &o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *LoadBalancerPoolShort) HasId() bool { + if o != nil && IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given interface{} and assigns it to the Id field. +func (o *LoadBalancerPoolShort) SetId(v interface{}) { + o.Id = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *LoadBalancerPoolShort) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolShort) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *LoadBalancerPoolShort) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *LoadBalancerPoolShort) SetName(v string) { + o.Name = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *LoadBalancerPoolShort) GetCreatedAt() time.Time { + if o == nil || IsNil(o.CreatedAt) { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolShort) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.CreatedAt) { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *LoadBalancerPoolShort) HasCreatedAt() bool { + if o != nil && !IsNil(o.CreatedAt) { + return true + } + + return false +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *LoadBalancerPoolShort) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *LoadBalancerPoolShort) GetUpdatedAt() time.Time { + if o == nil || IsNil(o.UpdatedAt) { + var ret time.Time + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolShort) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.UpdatedAt) { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *LoadBalancerPoolShort) HasUpdatedAt() bool { + if o != nil && !IsNil(o.UpdatedAt) { + return true + } + + return false +} + +// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. +func (o *LoadBalancerPoolShort) SetUpdatedAt(v time.Time) { + o.UpdatedAt = &v +} + +func (o LoadBalancerPoolShort) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPoolShort) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.CreatedAt) { + toSerialize["created_at"] = o.CreatedAt + } + if !IsNil(o.UpdatedAt) { + toSerialize["updated_at"] = o.UpdatedAt + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPoolShort) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPoolShort := _LoadBalancerPoolShort{} + + err = json.Unmarshal(bytes, &varLoadBalancerPoolShort) + + if err != nil { + return err + } + + *o = LoadBalancerPoolShort(varLoadBalancerPoolShort) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "name") + delete(additionalProperties, "created_at") + delete(additionalProperties, "updated_at") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPoolShort struct { + value *LoadBalancerPoolShort + isSet bool +} + +func (v NullableLoadBalancerPoolShort) Get() *LoadBalancerPoolShort { + return v.value +} + +func (v *NullableLoadBalancerPoolShort) Set(val *LoadBalancerPoolShort) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolShort) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolShort) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolShort(val *LoadBalancerPoolShort) *NullableLoadBalancerPoolShort { + return &NullableLoadBalancerPoolShort{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolShort) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolShort) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_pool_update.go b/internal/loadbalancers/api/v1/model_load_balancer_pool_update.go new file mode 100644 index 00000000..eaac0b31 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_pool_update.go @@ -0,0 +1,419 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPoolUpdate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPoolUpdate{} + +// LoadBalancerPoolUpdate struct for LoadBalancerPoolUpdate +type LoadBalancerPoolUpdate struct { + // Name of the load balancer pool + Name *string `json:"name,omitempty"` + Protocol *LoadBalancerPoolCreateProtocol `json:"protocol,omitempty"` + // Add ports to load balancer pool + AddPortIds []string `json:"add_port_ids,omitempty"` + // Removed ports from load balancer pool + RemovePortIds []string `json:"remove_port_ids,omitempty"` + // Clear all ports from load balancer pool + ClearPorts *bool `json:"clear_ports,omitempty"` + // Add origins to load balancer pool + AddOriginIds []string `json:"add_origin_ids,omitempty"` + // Removed origins from load balancer pool + RemoveOriginIds []string `json:"remove_origin_ids,omitempty"` + // Clear all origins from load balancer pool + ClearOrigins *bool `json:"clear_origins,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPoolUpdate LoadBalancerPoolUpdate + +// NewLoadBalancerPoolUpdate instantiates a new LoadBalancerPoolUpdate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPoolUpdate() *LoadBalancerPoolUpdate { + this := LoadBalancerPoolUpdate{} + return &this +} + +// NewLoadBalancerPoolUpdateWithDefaults instantiates a new LoadBalancerPoolUpdate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPoolUpdateWithDefaults() *LoadBalancerPoolUpdate { + this := LoadBalancerPoolUpdate{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *LoadBalancerPoolUpdate) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolUpdate) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *LoadBalancerPoolUpdate) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *LoadBalancerPoolUpdate) SetName(v string) { + o.Name = &v +} + +// GetProtocol returns the Protocol field value if set, zero value otherwise. +func (o *LoadBalancerPoolUpdate) GetProtocol() LoadBalancerPoolCreateProtocol { + if o == nil || IsNil(o.Protocol) { + var ret LoadBalancerPoolCreateProtocol + return ret + } + return *o.Protocol +} + +// GetProtocolOk returns a tuple with the Protocol field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolUpdate) GetProtocolOk() (*LoadBalancerPoolCreateProtocol, bool) { + if o == nil || IsNil(o.Protocol) { + return nil, false + } + return o.Protocol, true +} + +// HasProtocol returns a boolean if a field has been set. +func (o *LoadBalancerPoolUpdate) HasProtocol() bool { + if o != nil && !IsNil(o.Protocol) { + return true + } + + return false +} + +// SetProtocol gets a reference to the given LoadBalancerPoolCreateProtocol and assigns it to the Protocol field. +func (o *LoadBalancerPoolUpdate) SetProtocol(v LoadBalancerPoolCreateProtocol) { + o.Protocol = &v +} + +// GetAddPortIds returns the AddPortIds field value if set, zero value otherwise. +func (o *LoadBalancerPoolUpdate) GetAddPortIds() []string { + if o == nil || IsNil(o.AddPortIds) { + var ret []string + return ret + } + return o.AddPortIds +} + +// GetAddPortIdsOk returns a tuple with the AddPortIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolUpdate) GetAddPortIdsOk() ([]string, bool) { + if o == nil || IsNil(o.AddPortIds) { + return nil, false + } + return o.AddPortIds, true +} + +// HasAddPortIds returns a boolean if a field has been set. +func (o *LoadBalancerPoolUpdate) HasAddPortIds() bool { + if o != nil && !IsNil(o.AddPortIds) { + return true + } + + return false +} + +// SetAddPortIds gets a reference to the given []string and assigns it to the AddPortIds field. +func (o *LoadBalancerPoolUpdate) SetAddPortIds(v []string) { + o.AddPortIds = v +} + +// GetRemovePortIds returns the RemovePortIds field value if set, zero value otherwise. +func (o *LoadBalancerPoolUpdate) GetRemovePortIds() []string { + if o == nil || IsNil(o.RemovePortIds) { + var ret []string + return ret + } + return o.RemovePortIds +} + +// GetRemovePortIdsOk returns a tuple with the RemovePortIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolUpdate) GetRemovePortIdsOk() ([]string, bool) { + if o == nil || IsNil(o.RemovePortIds) { + return nil, false + } + return o.RemovePortIds, true +} + +// HasRemovePortIds returns a boolean if a field has been set. +func (o *LoadBalancerPoolUpdate) HasRemovePortIds() bool { + if o != nil && !IsNil(o.RemovePortIds) { + return true + } + + return false +} + +// SetRemovePortIds gets a reference to the given []string and assigns it to the RemovePortIds field. +func (o *LoadBalancerPoolUpdate) SetRemovePortIds(v []string) { + o.RemovePortIds = v +} + +// GetClearPorts returns the ClearPorts field value if set, zero value otherwise. +func (o *LoadBalancerPoolUpdate) GetClearPorts() bool { + if o == nil || IsNil(o.ClearPorts) { + var ret bool + return ret + } + return *o.ClearPorts +} + +// GetClearPortsOk returns a tuple with the ClearPorts field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolUpdate) GetClearPortsOk() (*bool, bool) { + if o == nil || IsNil(o.ClearPorts) { + return nil, false + } + return o.ClearPorts, true +} + +// HasClearPorts returns a boolean if a field has been set. +func (o *LoadBalancerPoolUpdate) HasClearPorts() bool { + if o != nil && !IsNil(o.ClearPorts) { + return true + } + + return false +} + +// SetClearPorts gets a reference to the given bool and assigns it to the ClearPorts field. +func (o *LoadBalancerPoolUpdate) SetClearPorts(v bool) { + o.ClearPorts = &v +} + +// GetAddOriginIds returns the AddOriginIds field value if set, zero value otherwise. +func (o *LoadBalancerPoolUpdate) GetAddOriginIds() []string { + if o == nil || IsNil(o.AddOriginIds) { + var ret []string + return ret + } + return o.AddOriginIds +} + +// GetAddOriginIdsOk returns a tuple with the AddOriginIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolUpdate) GetAddOriginIdsOk() ([]string, bool) { + if o == nil || IsNil(o.AddOriginIds) { + return nil, false + } + return o.AddOriginIds, true +} + +// HasAddOriginIds returns a boolean if a field has been set. +func (o *LoadBalancerPoolUpdate) HasAddOriginIds() bool { + if o != nil && !IsNil(o.AddOriginIds) { + return true + } + + return false +} + +// SetAddOriginIds gets a reference to the given []string and assigns it to the AddOriginIds field. +func (o *LoadBalancerPoolUpdate) SetAddOriginIds(v []string) { + o.AddOriginIds = v +} + +// GetRemoveOriginIds returns the RemoveOriginIds field value if set, zero value otherwise. +func (o *LoadBalancerPoolUpdate) GetRemoveOriginIds() []string { + if o == nil || IsNil(o.RemoveOriginIds) { + var ret []string + return ret + } + return o.RemoveOriginIds +} + +// GetRemoveOriginIdsOk returns a tuple with the RemoveOriginIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolUpdate) GetRemoveOriginIdsOk() ([]string, bool) { + if o == nil || IsNil(o.RemoveOriginIds) { + return nil, false + } + return o.RemoveOriginIds, true +} + +// HasRemoveOriginIds returns a boolean if a field has been set. +func (o *LoadBalancerPoolUpdate) HasRemoveOriginIds() bool { + if o != nil && !IsNil(o.RemoveOriginIds) { + return true + } + + return false +} + +// SetRemoveOriginIds gets a reference to the given []string and assigns it to the RemoveOriginIds field. +func (o *LoadBalancerPoolUpdate) SetRemoveOriginIds(v []string) { + o.RemoveOriginIds = v +} + +// GetClearOrigins returns the ClearOrigins field value if set, zero value otherwise. +func (o *LoadBalancerPoolUpdate) GetClearOrigins() bool { + if o == nil || IsNil(o.ClearOrigins) { + var ret bool + return ret + } + return *o.ClearOrigins +} + +// GetClearOriginsOk returns a tuple with the ClearOrigins field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPoolUpdate) GetClearOriginsOk() (*bool, bool) { + if o == nil || IsNil(o.ClearOrigins) { + return nil, false + } + return o.ClearOrigins, true +} + +// HasClearOrigins returns a boolean if a field has been set. +func (o *LoadBalancerPoolUpdate) HasClearOrigins() bool { + if o != nil && !IsNil(o.ClearOrigins) { + return true + } + + return false +} + +// SetClearOrigins gets a reference to the given bool and assigns it to the ClearOrigins field. +func (o *LoadBalancerPoolUpdate) SetClearOrigins(v bool) { + o.ClearOrigins = &v +} + +func (o LoadBalancerPoolUpdate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPoolUpdate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Protocol) { + toSerialize["protocol"] = o.Protocol + } + if !IsNil(o.AddPortIds) { + toSerialize["add_port_ids"] = o.AddPortIds + } + if !IsNil(o.RemovePortIds) { + toSerialize["remove_port_ids"] = o.RemovePortIds + } + if !IsNil(o.ClearPorts) { + toSerialize["clear_ports"] = o.ClearPorts + } + if !IsNil(o.AddOriginIds) { + toSerialize["add_origin_ids"] = o.AddOriginIds + } + if !IsNil(o.RemoveOriginIds) { + toSerialize["remove_origin_ids"] = o.RemoveOriginIds + } + if !IsNil(o.ClearOrigins) { + toSerialize["clear_origins"] = o.ClearOrigins + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPoolUpdate) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPoolUpdate := _LoadBalancerPoolUpdate{} + + err = json.Unmarshal(bytes, &varLoadBalancerPoolUpdate) + + if err != nil { + return err + } + + *o = LoadBalancerPoolUpdate(varLoadBalancerPoolUpdate) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "protocol") + delete(additionalProperties, "add_port_ids") + delete(additionalProperties, "remove_port_ids") + delete(additionalProperties, "clear_ports") + delete(additionalProperties, "add_origin_ids") + delete(additionalProperties, "remove_origin_ids") + delete(additionalProperties, "clear_origins") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPoolUpdate struct { + value *LoadBalancerPoolUpdate + isSet bool +} + +func (v NullableLoadBalancerPoolUpdate) Get() *LoadBalancerPoolUpdate { + return v.value +} + +func (v *NullableLoadBalancerPoolUpdate) Set(val *LoadBalancerPoolUpdate) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPoolUpdate) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPoolUpdate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPoolUpdate(val *LoadBalancerPoolUpdate) *NullableLoadBalancerPoolUpdate { + return &NullableLoadBalancerPoolUpdate{value: val, isSet: true} +} + +func (v NullableLoadBalancerPoolUpdate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPoolUpdate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_port.go b/internal/loadbalancers/api/v1/model_load_balancer_port.go new file mode 100644 index 00000000..78336830 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_port.go @@ -0,0 +1,383 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "time" +) + +// checks if the LoadBalancerPort type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPort{} + +// LoadBalancerPort struct for LoadBalancerPort +type LoadBalancerPort struct { + // ID of a port + Id *string `json:"id,omitempty"` + // Date and time of creation + CreatedAt *time.Time `json:"created_at,omitempty"` + // Date and time of last update + UpdatedAt *time.Time `json:"updated_at,omitempty"` + // A name for the port + Name *string `json:"name,omitempty"` + // Port Number + Number *int32 `json:"number,omitempty"` + // ID of the load balancer this port is assigned to + LoadbalancerId *string `json:"loadbalancer_id,omitempty"` + // A list of pool IDs assigned to the port + PoolIds []string `json:"pool_ids,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPort LoadBalancerPort + +// NewLoadBalancerPort instantiates a new LoadBalancerPort object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPort() *LoadBalancerPort { + this := LoadBalancerPort{} + return &this +} + +// NewLoadBalancerPortWithDefaults instantiates a new LoadBalancerPort object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPortWithDefaults() *LoadBalancerPort { + this := LoadBalancerPort{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *LoadBalancerPort) GetId() string { + if o == nil || IsNil(o.Id) { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPort) GetIdOk() (*string, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *LoadBalancerPort) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *LoadBalancerPort) SetId(v string) { + o.Id = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *LoadBalancerPort) GetCreatedAt() time.Time { + if o == nil || IsNil(o.CreatedAt) { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPort) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.CreatedAt) { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *LoadBalancerPort) HasCreatedAt() bool { + if o != nil && !IsNil(o.CreatedAt) { + return true + } + + return false +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *LoadBalancerPort) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *LoadBalancerPort) GetUpdatedAt() time.Time { + if o == nil || IsNil(o.UpdatedAt) { + var ret time.Time + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPort) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.UpdatedAt) { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *LoadBalancerPort) HasUpdatedAt() bool { + if o != nil && !IsNil(o.UpdatedAt) { + return true + } + + return false +} + +// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. +func (o *LoadBalancerPort) SetUpdatedAt(v time.Time) { + o.UpdatedAt = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *LoadBalancerPort) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPort) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *LoadBalancerPort) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *LoadBalancerPort) SetName(v string) { + o.Name = &v +} + +// GetNumber returns the Number field value if set, zero value otherwise. +func (o *LoadBalancerPort) GetNumber() int32 { + if o == nil || IsNil(o.Number) { + var ret int32 + return ret + } + return *o.Number +} + +// GetNumberOk returns a tuple with the Number field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPort) GetNumberOk() (*int32, bool) { + if o == nil || IsNil(o.Number) { + return nil, false + } + return o.Number, true +} + +// HasNumber returns a boolean if a field has been set. +func (o *LoadBalancerPort) HasNumber() bool { + if o != nil && !IsNil(o.Number) { + return true + } + + return false +} + +// SetNumber gets a reference to the given int32 and assigns it to the Number field. +func (o *LoadBalancerPort) SetNumber(v int32) { + o.Number = &v +} + +// GetLoadbalancerId returns the LoadbalancerId field value if set, zero value otherwise. +func (o *LoadBalancerPort) GetLoadbalancerId() string { + if o == nil || IsNil(o.LoadbalancerId) { + var ret string + return ret + } + return *o.LoadbalancerId +} + +// GetLoadbalancerIdOk returns a tuple with the LoadbalancerId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPort) GetLoadbalancerIdOk() (*string, bool) { + if o == nil || IsNil(o.LoadbalancerId) { + return nil, false + } + return o.LoadbalancerId, true +} + +// HasLoadbalancerId returns a boolean if a field has been set. +func (o *LoadBalancerPort) HasLoadbalancerId() bool { + if o != nil && !IsNil(o.LoadbalancerId) { + return true + } + + return false +} + +// SetLoadbalancerId gets a reference to the given string and assigns it to the LoadbalancerId field. +func (o *LoadBalancerPort) SetLoadbalancerId(v string) { + o.LoadbalancerId = &v +} + +// GetPoolIds returns the PoolIds field value if set, zero value otherwise. +func (o *LoadBalancerPort) GetPoolIds() []string { + if o == nil || IsNil(o.PoolIds) { + var ret []string + return ret + } + return o.PoolIds +} + +// GetPoolIdsOk returns a tuple with the PoolIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPort) GetPoolIdsOk() ([]string, bool) { + if o == nil || IsNil(o.PoolIds) { + return nil, false + } + return o.PoolIds, true +} + +// HasPoolIds returns a boolean if a field has been set. +func (o *LoadBalancerPort) HasPoolIds() bool { + if o != nil && !IsNil(o.PoolIds) { + return true + } + + return false +} + +// SetPoolIds gets a reference to the given []string and assigns it to the PoolIds field. +func (o *LoadBalancerPort) SetPoolIds(v []string) { + o.PoolIds = v +} + +func (o LoadBalancerPort) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPort) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } + if !IsNil(o.CreatedAt) { + toSerialize["created_at"] = o.CreatedAt + } + if !IsNil(o.UpdatedAt) { + toSerialize["updated_at"] = o.UpdatedAt + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Number) { + toSerialize["number"] = o.Number + } + if !IsNil(o.LoadbalancerId) { + toSerialize["loadbalancer_id"] = o.LoadbalancerId + } + if !IsNil(o.PoolIds) { + toSerialize["pool_ids"] = o.PoolIds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPort) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPort := _LoadBalancerPort{} + + err = json.Unmarshal(bytes, &varLoadBalancerPort) + + if err != nil { + return err + } + + *o = LoadBalancerPort(varLoadBalancerPort) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "created_at") + delete(additionalProperties, "updated_at") + delete(additionalProperties, "name") + delete(additionalProperties, "number") + delete(additionalProperties, "loadbalancer_id") + delete(additionalProperties, "pool_ids") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPort struct { + value *LoadBalancerPort + isSet bool +} + +func (v NullableLoadBalancerPort) Get() *LoadBalancerPort { + return v.value +} + +func (v *NullableLoadBalancerPort) Set(val *LoadBalancerPort) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPort) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPort) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPort(val *LoadBalancerPort) *NullableLoadBalancerPort { + return &NullableLoadBalancerPort{value: val, isSet: true} +} + +func (v NullableLoadBalancerPort) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPort) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_port_collection.go b/internal/loadbalancers/api/v1/model_load_balancer_port_collection.go new file mode 100644 index 00000000..f47a2247 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_port_collection.go @@ -0,0 +1,144 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPortCollection type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPortCollection{} + +// LoadBalancerPortCollection struct for LoadBalancerPortCollection +type LoadBalancerPortCollection struct { + Ports []LoadBalancerPort `json:"ports"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPortCollection LoadBalancerPortCollection + +// NewLoadBalancerPortCollection instantiates a new LoadBalancerPortCollection object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPortCollection(ports []LoadBalancerPort) *LoadBalancerPortCollection { + this := LoadBalancerPortCollection{} + this.Ports = ports + return &this +} + +// NewLoadBalancerPortCollectionWithDefaults instantiates a new LoadBalancerPortCollection object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPortCollectionWithDefaults() *LoadBalancerPortCollection { + this := LoadBalancerPortCollection{} + return &this +} + +// GetPorts returns the Ports field value +func (o *LoadBalancerPortCollection) GetPorts() []LoadBalancerPort { + if o == nil { + var ret []LoadBalancerPort + return ret + } + + return o.Ports +} + +// GetPortsOk returns a tuple with the Ports field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPortCollection) GetPortsOk() ([]LoadBalancerPort, bool) { + if o == nil { + return nil, false + } + return o.Ports, true +} + +// SetPorts sets field value +func (o *LoadBalancerPortCollection) SetPorts(v []LoadBalancerPort) { + o.Ports = v +} + +func (o LoadBalancerPortCollection) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPortCollection) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["ports"] = o.Ports + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPortCollection) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPortCollection := _LoadBalancerPortCollection{} + + err = json.Unmarshal(bytes, &varLoadBalancerPortCollection) + + if err != nil { + return err + } + + *o = LoadBalancerPortCollection(varLoadBalancerPortCollection) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "ports") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPortCollection struct { + value *LoadBalancerPortCollection + isSet bool +} + +func (v NullableLoadBalancerPortCollection) Get() *LoadBalancerPortCollection { + return v.value +} + +func (v *NullableLoadBalancerPortCollection) Set(val *LoadBalancerPortCollection) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPortCollection) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPortCollection) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPortCollection(val *LoadBalancerPortCollection) *NullableLoadBalancerPortCollection { + return &NullableLoadBalancerPortCollection{value: val, isSet: true} +} + +func (v NullableLoadBalancerPortCollection) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPortCollection) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_port_create.go b/internal/loadbalancers/api/v1/model_load_balancer_port_create.go new file mode 100644 index 00000000..8bc6202b --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_port_create.go @@ -0,0 +1,212 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPortCreate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPortCreate{} + +// LoadBalancerPortCreate struct for LoadBalancerPortCreate +type LoadBalancerPortCreate struct { + // A name for the port + Name string `json:"name"` + // Listing port + Number int32 `json:"number"` + // A list of pool IDs assigned to the port + PoolIds []string `json:"pool_ids,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPortCreate LoadBalancerPortCreate + +// NewLoadBalancerPortCreate instantiates a new LoadBalancerPortCreate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPortCreate(name string, number int32) *LoadBalancerPortCreate { + this := LoadBalancerPortCreate{} + this.Name = name + this.Number = number + return &this +} + +// NewLoadBalancerPortCreateWithDefaults instantiates a new LoadBalancerPortCreate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPortCreateWithDefaults() *LoadBalancerPortCreate { + this := LoadBalancerPortCreate{} + return &this +} + +// GetName returns the Name field value +func (o *LoadBalancerPortCreate) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPortCreate) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *LoadBalancerPortCreate) SetName(v string) { + o.Name = v +} + +// GetNumber returns the Number field value +func (o *LoadBalancerPortCreate) GetNumber() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Number +} + +// GetNumberOk returns a tuple with the Number field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerPortCreate) GetNumberOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Number, true +} + +// SetNumber sets field value +func (o *LoadBalancerPortCreate) SetNumber(v int32) { + o.Number = v +} + +// GetPoolIds returns the PoolIds field value if set, zero value otherwise. +func (o *LoadBalancerPortCreate) GetPoolIds() []string { + if o == nil || IsNil(o.PoolIds) { + var ret []string + return ret + } + return o.PoolIds +} + +// GetPoolIdsOk returns a tuple with the PoolIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPortCreate) GetPoolIdsOk() ([]string, bool) { + if o == nil || IsNil(o.PoolIds) { + return nil, false + } + return o.PoolIds, true +} + +// HasPoolIds returns a boolean if a field has been set. +func (o *LoadBalancerPortCreate) HasPoolIds() bool { + if o != nil && !IsNil(o.PoolIds) { + return true + } + + return false +} + +// SetPoolIds gets a reference to the given []string and assigns it to the PoolIds field. +func (o *LoadBalancerPortCreate) SetPoolIds(v []string) { + o.PoolIds = v +} + +func (o LoadBalancerPortCreate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPortCreate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["name"] = o.Name + toSerialize["number"] = o.Number + if !IsNil(o.PoolIds) { + toSerialize["pool_ids"] = o.PoolIds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPortCreate) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPortCreate := _LoadBalancerPortCreate{} + + err = json.Unmarshal(bytes, &varLoadBalancerPortCreate) + + if err != nil { + return err + } + + *o = LoadBalancerPortCreate(varLoadBalancerPortCreate) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "number") + delete(additionalProperties, "pool_ids") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPortCreate struct { + value *LoadBalancerPortCreate + isSet bool +} + +func (v NullableLoadBalancerPortCreate) Get() *LoadBalancerPortCreate { + return v.value +} + +func (v *NullableLoadBalancerPortCreate) Set(val *LoadBalancerPortCreate) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPortCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPortCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPortCreate(val *LoadBalancerPortCreate) *NullableLoadBalancerPortCreate { + return &NullableLoadBalancerPortCreate{value: val, isSet: true} +} + +func (v NullableLoadBalancerPortCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPortCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_port_update.go b/internal/loadbalancers/api/v1/model_load_balancer_port_update.go new file mode 100644 index 00000000..4df03206 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_port_update.go @@ -0,0 +1,268 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerPortUpdate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerPortUpdate{} + +// LoadBalancerPortUpdate struct for LoadBalancerPortUpdate +type LoadBalancerPortUpdate struct { + // A name for the port + Name *string `json:"name,omitempty"` + // Listing port + Number *int32 `json:"number,omitempty"` + // Add the provided pool ids to the port + AddPoolIds []string `json:"add_pool_ids,omitempty"` + // Remove the provided pool ids to the port + RemovePoolIds []string `json:"remove_pool_ids,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerPortUpdate LoadBalancerPortUpdate + +// NewLoadBalancerPortUpdate instantiates a new LoadBalancerPortUpdate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerPortUpdate() *LoadBalancerPortUpdate { + this := LoadBalancerPortUpdate{} + return &this +} + +// NewLoadBalancerPortUpdateWithDefaults instantiates a new LoadBalancerPortUpdate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerPortUpdateWithDefaults() *LoadBalancerPortUpdate { + this := LoadBalancerPortUpdate{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *LoadBalancerPortUpdate) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPortUpdate) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *LoadBalancerPortUpdate) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *LoadBalancerPortUpdate) SetName(v string) { + o.Name = &v +} + +// GetNumber returns the Number field value if set, zero value otherwise. +func (o *LoadBalancerPortUpdate) GetNumber() int32 { + if o == nil || IsNil(o.Number) { + var ret int32 + return ret + } + return *o.Number +} + +// GetNumberOk returns a tuple with the Number field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPortUpdate) GetNumberOk() (*int32, bool) { + if o == nil || IsNil(o.Number) { + return nil, false + } + return o.Number, true +} + +// HasNumber returns a boolean if a field has been set. +func (o *LoadBalancerPortUpdate) HasNumber() bool { + if o != nil && !IsNil(o.Number) { + return true + } + + return false +} + +// SetNumber gets a reference to the given int32 and assigns it to the Number field. +func (o *LoadBalancerPortUpdate) SetNumber(v int32) { + o.Number = &v +} + +// GetAddPoolIds returns the AddPoolIds field value if set, zero value otherwise. +func (o *LoadBalancerPortUpdate) GetAddPoolIds() []string { + if o == nil || IsNil(o.AddPoolIds) { + var ret []string + return ret + } + return o.AddPoolIds +} + +// GetAddPoolIdsOk returns a tuple with the AddPoolIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPortUpdate) GetAddPoolIdsOk() ([]string, bool) { + if o == nil || IsNil(o.AddPoolIds) { + return nil, false + } + return o.AddPoolIds, true +} + +// HasAddPoolIds returns a boolean if a field has been set. +func (o *LoadBalancerPortUpdate) HasAddPoolIds() bool { + if o != nil && !IsNil(o.AddPoolIds) { + return true + } + + return false +} + +// SetAddPoolIds gets a reference to the given []string and assigns it to the AddPoolIds field. +func (o *LoadBalancerPortUpdate) SetAddPoolIds(v []string) { + o.AddPoolIds = v +} + +// GetRemovePoolIds returns the RemovePoolIds field value if set, zero value otherwise. +func (o *LoadBalancerPortUpdate) GetRemovePoolIds() []string { + if o == nil || IsNil(o.RemovePoolIds) { + var ret []string + return ret + } + return o.RemovePoolIds +} + +// GetRemovePoolIdsOk returns a tuple with the RemovePoolIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerPortUpdate) GetRemovePoolIdsOk() ([]string, bool) { + if o == nil || IsNil(o.RemovePoolIds) { + return nil, false + } + return o.RemovePoolIds, true +} + +// HasRemovePoolIds returns a boolean if a field has been set. +func (o *LoadBalancerPortUpdate) HasRemovePoolIds() bool { + if o != nil && !IsNil(o.RemovePoolIds) { + return true + } + + return false +} + +// SetRemovePoolIds gets a reference to the given []string and assigns it to the RemovePoolIds field. +func (o *LoadBalancerPortUpdate) SetRemovePoolIds(v []string) { + o.RemovePoolIds = v +} + +func (o LoadBalancerPortUpdate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerPortUpdate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Number) { + toSerialize["number"] = o.Number + } + if !IsNil(o.AddPoolIds) { + toSerialize["add_pool_ids"] = o.AddPoolIds + } + if !IsNil(o.RemovePoolIds) { + toSerialize["remove_pool_ids"] = o.RemovePoolIds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerPortUpdate) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerPortUpdate := _LoadBalancerPortUpdate{} + + err = json.Unmarshal(bytes, &varLoadBalancerPortUpdate) + + if err != nil { + return err + } + + *o = LoadBalancerPortUpdate(varLoadBalancerPortUpdate) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "number") + delete(additionalProperties, "add_pool_ids") + delete(additionalProperties, "remove_pool_ids") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerPortUpdate struct { + value *LoadBalancerPortUpdate + isSet bool +} + +func (v NullableLoadBalancerPortUpdate) Get() *LoadBalancerPortUpdate { + return v.value +} + +func (v *NullableLoadBalancerPortUpdate) Set(val *LoadBalancerPortUpdate) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerPortUpdate) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerPortUpdate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerPortUpdate(val *LoadBalancerPortUpdate) *NullableLoadBalancerPortUpdate { + return &NullableLoadBalancerPortUpdate{value: val, isSet: true} +} + +func (v NullableLoadBalancerPortUpdate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerPortUpdate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_short.go b/internal/loadbalancers/api/v1/model_load_balancer_short.go new file mode 100644 index 00000000..26d9fb05 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_short.go @@ -0,0 +1,237 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "time" +) + +// checks if the LoadBalancerShort type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerShort{} + +// LoadBalancerShort struct for LoadBalancerShort +type LoadBalancerShort struct { + // ID of a load balancer + Id interface{} `json:"id"` + // A name for the load balancer + Name string `json:"name"` + // Date and time of creation + CreatedAt time.Time `json:"created_at"` + // Date and time of last update + UpdatedAt time.Time `json:"updated_at"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerShort LoadBalancerShort + +// NewLoadBalancerShort instantiates a new LoadBalancerShort object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerShort(id interface{}, name string, createdAt time.Time, updatedAt time.Time) *LoadBalancerShort { + this := LoadBalancerShort{} + this.Id = id + this.Name = name + this.CreatedAt = createdAt + this.UpdatedAt = updatedAt + return &this +} + +// NewLoadBalancerShortWithDefaults instantiates a new LoadBalancerShort object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerShortWithDefaults() *LoadBalancerShort { + this := LoadBalancerShort{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for interface{} will be returned +func (o *LoadBalancerShort) GetId() interface{} { + if o == nil { + var ret interface{} + return ret + } + + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *LoadBalancerShort) GetIdOk() (*interface{}, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *LoadBalancerShort) SetId(v interface{}) { + o.Id = v +} + +// GetName returns the Name field value +func (o *LoadBalancerShort) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerShort) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *LoadBalancerShort) SetName(v string) { + o.Name = v +} + +// GetCreatedAt returns the CreatedAt field value +func (o *LoadBalancerShort) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerShort) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value +func (o *LoadBalancerShort) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetUpdatedAt returns the UpdatedAt field value +func (o *LoadBalancerShort) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *LoadBalancerShort) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value +func (o *LoadBalancerShort) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +func (o LoadBalancerShort) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerShort) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["name"] = o.Name + toSerialize["created_at"] = o.CreatedAt + toSerialize["updated_at"] = o.UpdatedAt + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerShort) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerShort := _LoadBalancerShort{} + + err = json.Unmarshal(bytes, &varLoadBalancerShort) + + if err != nil { + return err + } + + *o = LoadBalancerShort(varLoadBalancerShort) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "name") + delete(additionalProperties, "created_at") + delete(additionalProperties, "updated_at") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerShort struct { + value *LoadBalancerShort + isSet bool +} + +func (v NullableLoadBalancerShort) Get() *LoadBalancerShort { + return v.value +} + +func (v *NullableLoadBalancerShort) Set(val *LoadBalancerShort) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerShort) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerShort) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerShort(val *LoadBalancerShort) *NullableLoadBalancerShort { + return &NullableLoadBalancerShort{value: val, isSet: true} +} + +func (v NullableLoadBalancerShort) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerShort) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_load_balancer_update.go b/internal/loadbalancers/api/v1/model_load_balancer_update.go new file mode 100644 index 00000000..22a42d52 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_load_balancer_update.go @@ -0,0 +1,268 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the LoadBalancerUpdate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &LoadBalancerUpdate{} + +// LoadBalancerUpdate struct for LoadBalancerUpdate +type LoadBalancerUpdate struct { + // Name of the load balancer + Name *string `json:"name,omitempty"` + // Add ports to load balancer + AddPortIds []string `json:"add_port_ids,omitempty"` + // Removed ports from load balancer + RemovePortIds []string `json:"remove_port_ids,omitempty"` + // Clear all ports from load balancer + ClearPorts *bool `json:"clear_ports,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _LoadBalancerUpdate LoadBalancerUpdate + +// NewLoadBalancerUpdate instantiates a new LoadBalancerUpdate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewLoadBalancerUpdate() *LoadBalancerUpdate { + this := LoadBalancerUpdate{} + return &this +} + +// NewLoadBalancerUpdateWithDefaults instantiates a new LoadBalancerUpdate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewLoadBalancerUpdateWithDefaults() *LoadBalancerUpdate { + this := LoadBalancerUpdate{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *LoadBalancerUpdate) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerUpdate) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *LoadBalancerUpdate) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *LoadBalancerUpdate) SetName(v string) { + o.Name = &v +} + +// GetAddPortIds returns the AddPortIds field value if set, zero value otherwise. +func (o *LoadBalancerUpdate) GetAddPortIds() []string { + if o == nil || IsNil(o.AddPortIds) { + var ret []string + return ret + } + return o.AddPortIds +} + +// GetAddPortIdsOk returns a tuple with the AddPortIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerUpdate) GetAddPortIdsOk() ([]string, bool) { + if o == nil || IsNil(o.AddPortIds) { + return nil, false + } + return o.AddPortIds, true +} + +// HasAddPortIds returns a boolean if a field has been set. +func (o *LoadBalancerUpdate) HasAddPortIds() bool { + if o != nil && !IsNil(o.AddPortIds) { + return true + } + + return false +} + +// SetAddPortIds gets a reference to the given []string and assigns it to the AddPortIds field. +func (o *LoadBalancerUpdate) SetAddPortIds(v []string) { + o.AddPortIds = v +} + +// GetRemovePortIds returns the RemovePortIds field value if set, zero value otherwise. +func (o *LoadBalancerUpdate) GetRemovePortIds() []string { + if o == nil || IsNil(o.RemovePortIds) { + var ret []string + return ret + } + return o.RemovePortIds +} + +// GetRemovePortIdsOk returns a tuple with the RemovePortIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerUpdate) GetRemovePortIdsOk() ([]string, bool) { + if o == nil || IsNil(o.RemovePortIds) { + return nil, false + } + return o.RemovePortIds, true +} + +// HasRemovePortIds returns a boolean if a field has been set. +func (o *LoadBalancerUpdate) HasRemovePortIds() bool { + if o != nil && !IsNil(o.RemovePortIds) { + return true + } + + return false +} + +// SetRemovePortIds gets a reference to the given []string and assigns it to the RemovePortIds field. +func (o *LoadBalancerUpdate) SetRemovePortIds(v []string) { + o.RemovePortIds = v +} + +// GetClearPorts returns the ClearPorts field value if set, zero value otherwise. +func (o *LoadBalancerUpdate) GetClearPorts() bool { + if o == nil || IsNil(o.ClearPorts) { + var ret bool + return ret + } + return *o.ClearPorts +} + +// GetClearPortsOk returns a tuple with the ClearPorts field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LoadBalancerUpdate) GetClearPortsOk() (*bool, bool) { + if o == nil || IsNil(o.ClearPorts) { + return nil, false + } + return o.ClearPorts, true +} + +// HasClearPorts returns a boolean if a field has been set. +func (o *LoadBalancerUpdate) HasClearPorts() bool { + if o != nil && !IsNil(o.ClearPorts) { + return true + } + + return false +} + +// SetClearPorts gets a reference to the given bool and assigns it to the ClearPorts field. +func (o *LoadBalancerUpdate) SetClearPorts(v bool) { + o.ClearPorts = &v +} + +func (o LoadBalancerUpdate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o LoadBalancerUpdate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.AddPortIds) { + toSerialize["add_port_ids"] = o.AddPortIds + } + if !IsNil(o.RemovePortIds) { + toSerialize["remove_port_ids"] = o.RemovePortIds + } + if !IsNil(o.ClearPorts) { + toSerialize["clear_ports"] = o.ClearPorts + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *LoadBalancerUpdate) UnmarshalJSON(bytes []byte) (err error) { + varLoadBalancerUpdate := _LoadBalancerUpdate{} + + err = json.Unmarshal(bytes, &varLoadBalancerUpdate) + + if err != nil { + return err + } + + *o = LoadBalancerUpdate(varLoadBalancerUpdate) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "add_port_ids") + delete(additionalProperties, "remove_port_ids") + delete(additionalProperties, "clear_ports") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableLoadBalancerUpdate struct { + value *LoadBalancerUpdate + isSet bool +} + +func (v NullableLoadBalancerUpdate) Get() *LoadBalancerUpdate { + return v.value +} + +func (v *NullableLoadBalancerUpdate) Set(val *LoadBalancerUpdate) { + v.value = val + v.isSet = true +} + +func (v NullableLoadBalancerUpdate) IsSet() bool { + return v.isSet +} + +func (v *NullableLoadBalancerUpdate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLoadBalancerUpdate(val *LoadBalancerUpdate) *NullableLoadBalancerUpdate { + return &NullableLoadBalancerUpdate{value: val, isSet: true} +} + +func (v NullableLoadBalancerUpdate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLoadBalancerUpdate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_provider.go b/internal/loadbalancers/api/v1/model_provider.go new file mode 100644 index 00000000..4b7915b1 --- /dev/null +++ b/internal/loadbalancers/api/v1/model_provider.go @@ -0,0 +1,183 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the Provider type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Provider{} + +// Provider struct for Provider +type Provider struct { + // ID of the provider + Id *string `json:"id,omitempty"` + // A name for the provider + Name string `json:"name"` + AdditionalProperties map[string]interface{} +} + +type _Provider Provider + +// NewProvider instantiates a new Provider object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewProvider(name string) *Provider { + this := Provider{} + this.Name = name + return &this +} + +// NewProviderWithDefaults instantiates a new Provider object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewProviderWithDefaults() *Provider { + this := Provider{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *Provider) GetId() string { + if o == nil || IsNil(o.Id) { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Provider) GetIdOk() (*string, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *Provider) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *Provider) SetId(v string) { + o.Id = &v +} + +// GetName returns the Name field value +func (o *Provider) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *Provider) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *Provider) SetName(v string) { + o.Name = v +} + +func (o Provider) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Provider) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *Provider) UnmarshalJSON(bytes []byte) (err error) { + varProvider := _Provider{} + + err = json.Unmarshal(bytes, &varProvider) + + if err != nil { + return err + } + + *o = Provider(varProvider) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "name") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableProvider struct { + value *Provider + isSet bool +} + +func (v NullableProvider) Get() *Provider { + return v.value +} + +func (v *NullableProvider) Set(val *Provider) { + v.value = val + v.isSet = true +} + +func (v NullableProvider) IsSet() bool { + return v.isSet +} + +func (v *NullableProvider) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProvider(val *Provider) *NullableProvider { + return &NullableProvider{value: val, isSet: true} +} + +func (v NullableProvider) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProvider) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/model_resource_created_response.go b/internal/loadbalancers/api/v1/model_resource_created_response.go new file mode 100644 index 00000000..30c3c89e --- /dev/null +++ b/internal/loadbalancers/api/v1/model_resource_created_response.go @@ -0,0 +1,268 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" +) + +// checks if the ResourceCreatedResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ResourceCreatedResponse{} + +// ResourceCreatedResponse struct for ResourceCreatedResponse +type ResourceCreatedResponse struct { + // API Version + Version *string `json:"version,omitempty"` + // Response message + Message *string `json:"message,omitempty"` + // ID of resource + Id *string `json:"id,omitempty"` + // Status of response + Status *int32 `json:"status,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _ResourceCreatedResponse ResourceCreatedResponse + +// NewResourceCreatedResponse instantiates a new ResourceCreatedResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewResourceCreatedResponse() *ResourceCreatedResponse { + this := ResourceCreatedResponse{} + return &this +} + +// NewResourceCreatedResponseWithDefaults instantiates a new ResourceCreatedResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewResourceCreatedResponseWithDefaults() *ResourceCreatedResponse { + this := ResourceCreatedResponse{} + return &this +} + +// GetVersion returns the Version field value if set, zero value otherwise. +func (o *ResourceCreatedResponse) GetVersion() string { + if o == nil || IsNil(o.Version) { + var ret string + return ret + } + return *o.Version +} + +// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ResourceCreatedResponse) GetVersionOk() (*string, bool) { + if o == nil || IsNil(o.Version) { + return nil, false + } + return o.Version, true +} + +// HasVersion returns a boolean if a field has been set. +func (o *ResourceCreatedResponse) HasVersion() bool { + if o != nil && !IsNil(o.Version) { + return true + } + + return false +} + +// SetVersion gets a reference to the given string and assigns it to the Version field. +func (o *ResourceCreatedResponse) SetVersion(v string) { + o.Version = &v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *ResourceCreatedResponse) GetMessage() string { + if o == nil || IsNil(o.Message) { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ResourceCreatedResponse) GetMessageOk() (*string, bool) { + if o == nil || IsNil(o.Message) { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *ResourceCreatedResponse) HasMessage() bool { + if o != nil && !IsNil(o.Message) { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *ResourceCreatedResponse) SetMessage(v string) { + o.Message = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ResourceCreatedResponse) GetId() string { + if o == nil || IsNil(o.Id) { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ResourceCreatedResponse) GetIdOk() (*string, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *ResourceCreatedResponse) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *ResourceCreatedResponse) SetId(v string) { + o.Id = &v +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *ResourceCreatedResponse) GetStatus() int32 { + if o == nil || IsNil(o.Status) { + var ret int32 + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ResourceCreatedResponse) GetStatusOk() (*int32, bool) { + if o == nil || IsNil(o.Status) { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *ResourceCreatedResponse) HasStatus() bool { + if o != nil && !IsNil(o.Status) { + return true + } + + return false +} + +// SetStatus gets a reference to the given int32 and assigns it to the Status field. +func (o *ResourceCreatedResponse) SetStatus(v int32) { + o.Status = &v +} + +func (o ResourceCreatedResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ResourceCreatedResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Version) { + toSerialize["version"] = o.Version + } + if !IsNil(o.Message) { + toSerialize["message"] = o.Message + } + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } + if !IsNil(o.Status) { + toSerialize["status"] = o.Status + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ResourceCreatedResponse) UnmarshalJSON(bytes []byte) (err error) { + varResourceCreatedResponse := _ResourceCreatedResponse{} + + err = json.Unmarshal(bytes, &varResourceCreatedResponse) + + if err != nil { + return err + } + + *o = ResourceCreatedResponse(varResourceCreatedResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "version") + delete(additionalProperties, "message") + delete(additionalProperties, "id") + delete(additionalProperties, "status") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableResourceCreatedResponse struct { + value *ResourceCreatedResponse + isSet bool +} + +func (v NullableResourceCreatedResponse) Get() *ResourceCreatedResponse { + return v.value +} + +func (v *NullableResourceCreatedResponse) Set(val *ResourceCreatedResponse) { + v.value = val + v.isSet = true +} + +func (v NullableResourceCreatedResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableResourceCreatedResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableResourceCreatedResponse(val *ResourceCreatedResponse) *NullableResourceCreatedResponse { + return &NullableResourceCreatedResponse{value: val, isSet: true} +} + +func (v NullableResourceCreatedResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableResourceCreatedResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/loadbalancers/api/v1/response.go b/internal/loadbalancers/api/v1/response.go new file mode 100644 index 00000000..50a63f7c --- /dev/null +++ b/internal/loadbalancers/api/v1/response.go @@ -0,0 +1,47 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "net/http" +) + +// APIResponse stores the API response returned by the server. +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the OpenAPI operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +// NewAPIResponse returns a new APIResponse object. +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +// NewAPIResponseWithError returns a new APIResponse object with the provided error message. +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/internal/loadbalancers/api/v1/utils.go b/internal/loadbalancers/api/v1/utils.go new file mode 100644 index 00000000..81346189 --- /dev/null +++ b/internal/loadbalancers/api/v1/utils.go @@ -0,0 +1,347 @@ +/* +Load Balancer Management API + +Load Balancer Management API is an API for managing load balancers. + +API version: 0.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1 + +import ( + "encoding/json" + "reflect" + "time" +) + +// PtrBool is a helper routine that returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt is a helper routine that returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 is a helper routine that returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 is a helper routine that returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 is a helper routine that returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 is a helper routine that returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString is a helper routine that returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime is helper routine that returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +type NullableBool struct { + value *bool + isSet bool +} + +func (v NullableBool) Get() *bool { + return v.value +} + +func (v *NullableBool) Set(val *bool) { + v.value = val + v.isSet = true +} + +func (v NullableBool) IsSet() bool { + return v.isSet +} + +func (v *NullableBool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBool(val *bool) *NullableBool { + return &NullableBool{value: val, isSet: true} +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt struct { + value *int + isSet bool +} + +func (v NullableInt) Get() *int { + return v.value +} + +func (v *NullableInt) Set(val *int) { + v.value = val + v.isSet = true +} + +func (v NullableInt) IsSet() bool { + return v.isSet +} + +func (v *NullableInt) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt(val *int) *NullableInt { + return &NullableInt{value: val, isSet: true} +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt32 struct { + value *int32 + isSet bool +} + +func (v NullableInt32) Get() *int32 { + return v.value +} + +func (v *NullableInt32) Set(val *int32) { + v.value = val + v.isSet = true +} + +func (v NullableInt32) IsSet() bool { + return v.isSet +} + +func (v *NullableInt32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt32(val *int32) *NullableInt32 { + return &NullableInt32{value: val, isSet: true} +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt64 struct { + value *int64 + isSet bool +} + +func (v NullableInt64) Get() *int64 { + return v.value +} + +func (v *NullableInt64) Set(val *int64) { + v.value = val + v.isSet = true +} + +func (v NullableInt64) IsSet() bool { + return v.isSet +} + +func (v *NullableInt64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt64(val *int64) *NullableInt64 { + return &NullableInt64{value: val, isSet: true} +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat32 struct { + value *float32 + isSet bool +} + +func (v NullableFloat32) Get() *float32 { + return v.value +} + +func (v *NullableFloat32) Set(val *float32) { + v.value = val + v.isSet = true +} + +func (v NullableFloat32) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat32(val *float32) *NullableFloat32 { + return &NullableFloat32{value: val, isSet: true} +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat64 struct { + value *float64 + isSet bool +} + +func (v NullableFloat64) Get() *float64 { + return v.value +} + +func (v *NullableFloat64) Set(val *float64) { + v.value = val + v.isSet = true +} + +func (v NullableFloat64) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat64(val *float64) *NullableFloat64 { + return &NullableFloat64{value: val, isSet: true} +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableString struct { + value *string + isSet bool +} + +func (v NullableString) Get() *string { + return v.value +} + +func (v *NullableString) Set(val *string) { + v.value = val + v.isSet = true +} + +func (v NullableString) IsSet() bool { + return v.isSet +} + +func (v *NullableString) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableString(val *string) *NullableString { + return &NullableString{value: val, isSet: true} +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableTime struct { + value *time.Time + isSet bool +} + +func (v NullableTime) Get() *time.Time { + return v.value +} + +func (v *NullableTime) Set(val *time.Time) { + v.value = val + v.isSet = true +} + +func (v NullableTime) IsSet() bool { + return v.isSet +} + +func (v *NullableTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTime(val *time.Time) *NullableTime { + return &NullableTime{value: val, isSet: true} +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + return v.value.MarshalJSON() +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +// IsNil checks if an input is nil +func IsNil(i interface{}) bool { + if i == nil { + return true + } + switch reflect.TypeOf(i).Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: + return reflect.ValueOf(i).IsNil() + case reflect.Array: + return reflect.ValueOf(i).IsZero() + } + return false +} + +type MappedNullable interface { + ToMap() (map[string]interface{}, error) +} diff --git a/internal/loadbalancers/create.go b/internal/loadbalancers/create.go new file mode 100644 index 00000000..d5082f78 --- /dev/null +++ b/internal/loadbalancers/create.go @@ -0,0 +1,93 @@ +// Copyright © 2022 Equinix Metal Developers +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package loadbalancers + +import ( + "context" + "fmt" + "strconv" + + lbaas "github.com/equinix/metal-cli/internal/loadbalancers/api/v1" + "github.com/spf13/cobra" +) + +func (c *Client) Create() *cobra.Command { + var ( + name string + locationId string + portIds []string + providerId string + projectID string + ) + + // loadbalancerCreateCmd represents the loadbalancerCreate command + createLoadBalancerCmd := &cobra.Command{ + Use: `create -n -l [-p ] [--provider ] [--port ]`, + Short: "Creates a loadbalancer.", + Long: "Creates a loadbalancer with the specified name.", + Example: ` # Creates a new loadbalancer named dev-loadbal in the Dallas metro: + metal loadbalancer create --name dev-loadbal -l da + + # Creates a new loadbalancer named prod-loadbal in the DC metro: + metal loadbalancer create -n prod-loadbal -l dc`, + + RunE: func(cmd *cobra.Command, args []string) error { + cmd.SilenceUsage = true + + // handle metro aliases for locations + if LBMetros[locationId] != "" { + locationId = LBMetros[locationId] + } + + req := c.projectService.CreateLoadBalancer(context.Background(), projectID) + // opts := lbaas.NewLoadBalancerCreate(name, locationId, portIds, providerId) + opts := &lbaas.LoadBalancerCreate{ + Name: name, + LocationId: locationId, + PortIds: portIds, + ProviderId: providerId, + } + req = req.LoadBalancerCreate(*opts) + lb, _, err := req.Execute() + if err != nil { + return fmt.Errorf("Could not create LoadBalancer: %w", err) + } + + data := make([][]string, 1) + + data[0] = []string{lb.GetId(), lb.GetMessage(), lb.GetVersion(), strconv.Itoa(int(lb.GetStatus()))} + header := []string{"ID", "Message", "Version", "Status"} + return c.Out.Output(lb, header, &data) + }, + } + + createLoadBalancerCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the loadbalancer") + createLoadBalancerCmd.Flags().StringVarP(&projectID, "project-id", "p", "", "The project's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.") + createLoadBalancerCmd.Flags().StringVarP(&locationId, "location", "l", "", "The location's ID. This flag is required.") + createLoadBalancerCmd.Flags().StringVarP(&providerId, "provider", "r", ProviderID, "The provider ID.") + createLoadBalancerCmd.Flags().StringSliceVar(&portIds, "port", []string{}, "The port(s) UUID") + + // TODO(displague) Not sure if this is needed + _ = createLoadBalancerCmd.MarkFlagRequired("location") + _ = createLoadBalancerCmd.MarkFlagRequired("project-id") + _ = createLoadBalancerCmd.MarkFlagRequired("name") + return createLoadBalancerCmd +} diff --git a/internal/loadbalancers/delete.go b/internal/loadbalancers/delete.go new file mode 100644 index 00000000..08dc07e0 --- /dev/null +++ b/internal/loadbalancers/delete.go @@ -0,0 +1,85 @@ +// Copyright © 2022 Equinix Metal Developers +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package loadbalancers + +import ( + "context" + "fmt" + "strings" + + "github.com/spf13/cobra" +) + +func (c *Client) Delete() *cobra.Command { + var ( + force bool + loadbalancerID string + confirmation string + ) + deleteLoadBalancer := func(id string) error { + _, err := c.loadBalancerService.DeleteLoadBalancer(context.Background(), id).Execute() + if err != nil { + return err + } + fmt.Println("LoadBalancer", loadbalancerID, "successfully deleted.") + return nil + } + // deleteLoadBalancerCmd represents the deleteLoadBalancer command + deleteLoadBalancerCmd := &cobra.Command{ + Use: `delete --id [--force]`, + Short: "Deletes a loadbalancer.", + Long: "Deletes the specified loadbalancer with a confirmation prompt. To skip the confirmation use --force.", + Example: ` # Deletes loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375: + metal loadbalancer delete -i 50693ba9-e4e4-4d8a-9eb2-4840b11e9375 + > + ✔ Are you sure you want to delete loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375: y + + # Deletes loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375, skipping confirmation: + metal loadbalancer delete -i 50693ba9-e4e4-4d8a-9eb2-4840b11e9375 -f`, + + RunE: func(cmd *cobra.Command, args []string) error { + cmd.SilenceUsage = true + if !force { + fmt.Printf("Are you sure you want to delete Metal Loadbalancer %s [Y/N]: ", loadbalancerID) + _, err := fmt.Scanln(&confirmation) + if err != nil { + return nil + } + } + confirmation = strings.TrimSpace(strings.ToLower(confirmation)) + if confirmation != "yes" && confirmation != "y" { + fmt.Println("Metal Loadbalancer deletion cancelled.") + return nil + } + + if err := deleteLoadBalancer(loadbalancerID); err != nil { + return fmt.Errorf("Could not delete LoadBalancer: %w", err) + } + return nil + }, + } + + deleteLoadBalancerCmd.Flags().StringVarP(&loadbalancerID, "id", "i", "", "The loadbalancer's ID. This flag is required.") + _ = deleteLoadBalancerCmd.MarkFlagRequired("id") + + deleteLoadBalancerCmd.Flags().BoolVarP(&force, "force", "f", false, "Force removal of the loadbalancer") + return deleteLoadBalancerCmd +} diff --git a/internal/loadbalancers/infrastructure/token_exchanger.go b/internal/loadbalancers/infrastructure/token_exchanger.go new file mode 100644 index 00000000..43a47473 --- /dev/null +++ b/internal/loadbalancers/infrastructure/token_exchanger.go @@ -0,0 +1,67 @@ +package infrastructure + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "time" + + "golang.org/x/oauth2" +) + +type TokenExchanger struct { + metalAPIKey string + client *http.Client +} + +var _ oauth2.TokenSource = (*TokenExchanger)(nil) + +func NewTokenExchanger(metalAPIKey string, client *http.Client) *TokenExchanger { + if client == nil { + client = http.DefaultClient + } + return &TokenExchanger{ + metalAPIKey: metalAPIKey, + client: client, + } +} + +func (m TokenExchanger) Token() (*oauth2.Token, error) { + tokenExchangeURL := "https://iam.metalctrl.io/api-keys/exchange" + tokenExchangeRequest, err := http.NewRequest("POST", tokenExchangeURL, nil) + if err != nil { + return nil, err + } + tokenExchangeRequest.Header.Add("Authorization", fmt.Sprintf("Bearer %v", m.metalAPIKey)) + + resp, err := m.client.Do(tokenExchangeRequest) + if err != nil { + return nil, err + } + + body, err := io.ReadAll(resp.Body) + resp.Body.Close() + if err != nil { + return nil, err + } + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("token exchange request failed with status %v, body %v", resp.StatusCode, string(body[:])) + } + + token := oauth2.Token{} + err = json.Unmarshal(body, &token) + if err != nil { + return nil, err + } + + // TODO: expires_in does not appear to be returned. Only access_token + expiresIn := token.Extra("expires_in") + if expiresIn != nil { + expiresInSeconds := expiresIn.(int) + token.Expiry = time.Now().Add(time.Second * time.Duration(expiresInSeconds)) + } + + return &token, nil +} diff --git a/internal/loadbalancers/loadbalancer.go b/internal/loadbalancers/loadbalancer.go new file mode 100644 index 00000000..e1f947e8 --- /dev/null +++ b/internal/loadbalancers/loadbalancer.go @@ -0,0 +1,92 @@ +// Copyright © 2022 Equinix Metal Developers +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package loadbalancers + +import ( + lbaas "github.com/equinix/metal-cli/internal/loadbalancers/api/v1" + v1 "github.com/equinix/metal-cli/internal/loadbalancers/api/v1" + "github.com/equinix/metal-cli/internal/outputs" + "github.com/spf13/cobra" +) + +type Client struct { + Servicer Servicer + loadBalancerService lbaas.LoadBalancersApiService + projectService lbaas.ProjectsApiService + portsService lbaas.PortsApiService + poolsService lbaas.PoolsApiService + originsService lbaas.OriginsApiService + + Out outputs.Outputer +} + +const ProviderID = "loadpvd-gOB_-byp5ebFo7A3LHv2B" + +// LBMetros is a map of metro codes to loadbalancer location IDs +// TODO: this should be removed once the API supports accessing loadbalancers by metro short codes +var LBMetros = map[string]string{ + "da": "lctnloc--uxs0GLeAELHKV8GxO_AI", + "ny": "lctnloc-Vy-1Qpw31mPi6RJQwVf9A", + "sv": "lctnloc-H5rl2M2VL5dcFmdxhbEKx", + "dc": "lctnloc--uxs0GLeAELHKV8GxO_AI", +} + +func (c *Client) NewCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: `loadbalancer-beta`, + Aliases: []string{"loadbalancers-beta", "loadbalancers", "loadbalancer", "lb", "lbs"}, + Short: "LoadBalancer BETA operations: create, get, update, and delete.", + Long: "Information and management for LoadBalancers is on https://deploy.equinix.com/developers/docs/metal/networking/load-balancers/.", + + PersistentPreRun: func(cmd *cobra.Command, args []string) { + if root := cmd.Root(); root != nil { + if root.PersistentPreRun != nil { + root.PersistentPreRun(cmd, args) + } + } + c.loadBalancerService = *c.Servicer.LoadbalancerAPI(cmd).LoadBalancersApi + c.originsService = *c.Servicer.LoadbalancerAPI(cmd).OriginsApi + c.portsService = *c.Servicer.LoadbalancerAPI(cmd).PortsApi + c.poolsService = *c.Servicer.LoadbalancerAPI(cmd).PoolsApi + c.projectService = *c.Servicer.LoadbalancerAPI(cmd).ProjectsApi + }, + } + + cmd.AddCommand( + c.Retrieve(), + c.Create(), + c.Delete(), + // c.Update(), + ) + return cmd +} + +type Servicer interface { + LoadbalancerAPI(cmd *cobra.Command) *v1.APIClient + Format() outputs.Format +} + +func NewClient(s Servicer, out outputs.Outputer) *Client { + return &Client{ + Servicer: s, + Out: out, + } +} diff --git a/internal/loadbalancers/retrieve.go b/internal/loadbalancers/retrieve.go new file mode 100644 index 00000000..66b8b202 --- /dev/null +++ b/internal/loadbalancers/retrieve.go @@ -0,0 +1,99 @@ +// Copyright © 2022 Equinix Metal Developers +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package loadbalancers + +import ( + "context" + "fmt" + + v1 "github.com/equinix/metal-cli/internal/loadbalancers/api/v1" + "github.com/spf13/cobra" +) + +func (c *Client) Retrieve() *cobra.Command { + var loadbalancerID, loadbalancerName, projectID string + // retrieveLoadBalancerCmd represents the retriveLoadBalancer command + retrieveLoadBalancerCmd := &cobra.Command{ + Use: `get [-i | -n ]`, + Aliases: []string{"list"}, + Short: "Retrieves all the project loadbalancers or the details of a specified loadbalancer.", + Long: "Retrieves all the project loadbalancers or the details of a specified loadbalancer. You can specify which loadbalancer by UUID or name.", + Example: ` # Retrieve all loadbalancers: + metal loadbalancer get + + # Retrieve a specific loadbalancer by UUID: + metal loadbalancer get -i 2008f885-1aac-406b-8d99-e6963fd21333 + + # Retrieve a specific loadbalancer by name: + metal loadbalancer get -n dev-cluster03`, + + RunE: func(cmd *cobra.Command, args []string) error { + cmd.SilenceUsage = true + if loadbalancerID != "" && loadbalancerName != "" { + return fmt.Errorf("Must specify only one of loadbalancer-id and loadbalancer name") + } + + lbs := []v1.LoadBalancer{} + if loadbalancerID == "" { + req := c.projectService.ListLoadBalancers(context.Background(), projectID) + + ret, _, err := req.Execute() + if err != nil { + return fmt.Errorf("Could not list LoadBalancers: %w", err) + } + lbs = append(lbs, ret.Loadbalancers...) + } else { + req := c.loadBalancerService.GetLoadBalancer(context.Background(), loadbalancerID) + ret, _, err := req.Execute() + if err != nil { + return fmt.Errorf("Could not find LoadBalancer: %w", err) + } + lbs = append(lbs, *ret) + } + + var data [][]string + for _, p := range lbs { + row := []string{p.GetId(), p.GetName(), p.GetCreatedAt().String()} + + if loadbalancerName > "" { + if p.GetName() == loadbalancerName { + data = append(data, row) + break + } + continue + } + data = append(data, row) + } + if loadbalancerName > "" && len(data) == 0 { + return fmt.Errorf("Could not find loadbalancer with name %q", loadbalancerName) + } + + header := []string{"ID", "Name", "Created"} + return c.Out.Output(lbs, header, &data) + }, + } + + retrieveLoadBalancerCmd.Flags().StringVarP(&projectID, "project-id", "p", "", "The project's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.") + + retrieveLoadBalancerCmd.Flags().StringVarP(&loadbalancerName, "loadbalancer", "n", "", "The name of the loadbalancer.") + retrieveLoadBalancerCmd.Flags().StringVarP(&loadbalancerID, "id", "i", "", "The loadbalancer's UUID, which can be specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.") + return retrieveLoadBalancerCmd +}