diff --git a/commands/cdn/distribution/get.go b/commands/cdn/distribution/get.go index 38530416f..009346a2e 100644 --- a/commands/cdn/distribution/get.go +++ b/commands/cdn/distribution/get.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/ionos-cloud/ionosctl/v6/commands/cdn/completer" + "github.com/ionos-cloud/ionosctl/v6/internal/client" "github.com/ionos-cloud/ionosctl/v6/internal/constants" "github.com/ionos-cloud/ionosctl/v6/internal/core" diff --git a/commands/cloudapi-v6/completer/ids.go b/commands/cloudapi-v6/completer/ids.go index 8e10c3f49..5dd7c8664 100644 --- a/commands/cloudapi-v6/completer/ids.go +++ b/commands/cloudapi-v6/completer/ids.go @@ -52,6 +52,37 @@ func AttachedCdromsIds(datacenterId, serverId string) []string { return attachedCdromsIds } +func DatacenterIdsFilterLocation(loc string) []string { + req := client.Must().CloudClient.DataCentersApi.DatacentersGet(context.Background()) + if loc != "" { + req = req.Filter("location", loc) + } + dcs, _, err := req.Execute() + if err != nil { + return nil + } + + var dcIds []string + for _, item := range *dcs.Items { + var completion string + if item.Id == nil { + continue + } + completion = *item.Id + if props, ok := item.GetPropertiesOk(); ok { + if name, ok := props.GetNameOk(); ok { + completion = fmt.Sprintf("%s\t%s", completion, *name) + } + if location, ok := props.GetLocationOk(); ok { + completion = fmt.Sprintf("%s - %s", completion, *location) + } + } + + dcIds = append(dcIds, completion) + } + return dcIds +} + func DataCentersIds(filters ...func(datacenter ionoscloud.Datacenter) bool) []string { datacenterSvc := resources.NewDataCenterService(client.Must(), context.Background()) datacenters, _, err := datacenterSvc.List(resources.ListQueryParams{}) diff --git a/commands/dbaas/completer/completer.go b/commands/dbaas/completer/completer.go index 775926394..13f0155c1 100644 --- a/commands/dbaas/completer/completer.go +++ b/commands/dbaas/completer/completer.go @@ -14,49 +14,55 @@ import ( ) func GetCidrCompletionFunc(cmd *core.Command) func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - getNicIp := func() (string, error) { - ls, _, err := client.Must().CloudClient.ServersApi.DatacentersServersGet(context.Background(), - viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))).Execute() - if err != nil || ls.Items == nil || len(*ls.Items) == 0 { - return "", fmt.Errorf("failed getting servers %w", err) + return func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + databaseIp := "192.168.1.128" // fallback in case of no servers / errs + ip, err := getNicIp(cmd) + if err != nil || ip == "" { + ip = databaseIp } + cidrs := generateCidrs(cmd, ip) + return []string{strings.Join(cidrs, ",")}, cobra.ShellCompDirectiveNoFileComp + } +} - for _, server := range *ls.Items { - if server.Id == nil { - return "", fmt.Errorf("failed getting ID") - } +func getNicIp(cmd *core.Command) (string, error) { + ls, _, err := client.Must().CloudClient.ServersApi.DatacentersServersGet(context.Background(), + viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))).Execute() + if err != nil || ls.Items == nil || len(*ls.Items) == 0 { + return "", fmt.Errorf("failed getting servers %w", err) + } - nics, _, err := client.Must().CloudClient.NetworkInterfacesApi.DatacentersServersNicsGet(context.Background(), - viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId)), *server.Id).Execute() - if err != nil || nics.Items == nil || len(*nics.Items) == 0 { - return "", fmt.Errorf("failed getting nics %w", err) - } - // Find the first nic with IPs not empty and return it - for _, nic := range *nics.Items { - if nic.Properties != nil && nic.Properties.Ips != nil && len(*nic.Properties.Ips) > 0 { - return (*nic.Properties.Ips)[0], nil - } + for _, server := range *ls.Items { + if server.Id == nil { + return "", fmt.Errorf("failed getting ID") + } + + nics, _, err := client.Must().CloudClient.NetworkInterfacesApi.DatacentersServersNicsGet(context.Background(), + viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId)), *server.Id).Execute() + if err != nil || nics.Items == nil || len(*nics.Items) == 0 { + return "", fmt.Errorf("failed getting nics %w", err) + } + // Find the first nic with IPs not empty and return it + for _, nic := range *nics.Items { + if nic.Properties != nil && nic.Properties.Ips != nil && len(*nic.Properties.Ips) > 0 { + return (*nic.Properties.Ips)[0], nil } } - return "", fmt.Errorf("no NIC with IP") } + return "", fmt.Errorf("no NIC with IP") +} - generateCidrs := func(ip string, instances int) []string { - var cidrs []string - for i := 0; i < instances; i++ { - cidrs = append(cidrs, fake.IP(fake.WithIPv4(), fake.WithIPCIDR(ip+"/24"))+"/24") - } - return cidrs +func generateCidrs(cmd *core.Command, ip string) []string { + var cidrs []string + + instances := viper.GetInt(core.GetFlagName(cmd.NS, constants.FlagInstances)) + if instances == 0 { + instances = 1 // flag might not be set } - return func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - databaseIp := "192.168.1.128" // fallback in case of no servers / errs - ip, err := getNicIp() - if err != nil || ip == "" { - ip = databaseIp - } - instances := viper.GetInt(core.GetFlagName(cmd.NS, constants.FlagInstances)) - cidrs := generateCidrs(ip, instances) - return []string{strings.Join(cidrs, ",")}, cobra.ShellCompDirectiveNoFileComp + for i := 0; i < instances; i++ { + cidrs = append(cidrs, fake.IP(fake.WithIPv4(), fake.WithIPCIDR(ip+"/24"))+"/24") } + + return cidrs } diff --git a/commands/root.go b/commands/root.go index eb3eb1e1f..568ed5035 100644 --- a/commands/root.go +++ b/commands/root.go @@ -18,6 +18,7 @@ import ( logging_service "github.com/ionos-cloud/ionosctl/v6/commands/logging-service" "github.com/ionos-cloud/ionosctl/v6/commands/token" vm_autoscaling "github.com/ionos-cloud/ionosctl/v6/commands/vm-autoscaling" + "github.com/ionos-cloud/ionosctl/v6/commands/vpn" "github.com/ionos-cloud/ionosctl/v6/internal/config" "github.com/ionos-cloud/ionosctl/v6/internal/constants" "github.com/ionos-cloud/ionosctl/v6/internal/core" @@ -225,10 +226,10 @@ func addCommands() { rootCmd.AddCommand(dns.Root()) rootCmd.AddCommand(logging_service.Root()) - // CDN rootCmd.AddCommand(cdn.Command()) - // Kafka + rootCmd.AddCommand(vpn.Root()) + rootCmd.AddCommand(kafka.Command()) } diff --git a/commands/vpn/ipsec/completer/completer.go b/commands/vpn/ipsec/completer/completer.go new file mode 100644 index 000000000..d5bdfccec --- /dev/null +++ b/commands/vpn/ipsec/completer/completer.go @@ -0,0 +1,81 @@ +package completer + +import ( + "context" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/pkg/functional" + vpn "github.com/ionos-cloud/sdk-go-vpn" +) + +// -- GATEWAYS + +// GatewaysProperty returns a list of properties of all gateways matching the given filters +func GatewaysProperty[V any](f func(gateway vpn.IPSecGatewayRead) V, fs ...GatewayFilter) []V { + recs, err := Gateways(fs...) + if err != nil { + return nil + } + return functional.Map(*recs.Items, f) +} + +// Gateways returns all distributions matching the given filters +func Gateways(fs ...GatewayFilter) (vpn.IPSecGatewayReadList, error) { + req := client.Must().VPNClient.IPSecGatewaysApi.IpsecgatewaysGet(context.Background()) + for _, f := range fs { + var err error + req, err = f(req) + if err != nil { + return vpn.IPSecGatewayReadList{}, err + } + } + + ls, _, err := req.Execute() + if err != nil { + return vpn.IPSecGatewayReadList{}, err + } + return ls, nil +} + +type GatewayFilter func(request vpn.ApiIpsecgatewaysGetRequest) (vpn.ApiIpsecgatewaysGetRequest, error) + +// TunnelsProperty returns a list of properties of all tunnels matching the given filters +func TunnelsProperty[V any](gatewayID string, f func(tunnel vpn.IPSecTunnelRead) V, fs ...TunnelFilter) []V { + recs, err := Tunnels(gatewayID, fs...) + if err != nil { + return nil + } + return functional.Map(*recs.Items, f) +} + +// Tunnels returns all distributions matching the given filters +func Tunnels(gatewayID string, fs ...TunnelFilter) (vpn.IPSecTunnelReadList, error) { + req := client.Must().VPNClient.IPSecTunnelsApi.IpsecgatewaysTunnelsGet(context.Background(), gatewayID) + for _, f := range fs { + var err error + req, err = f(req) + if err != nil { + return vpn.IPSecTunnelReadList{}, err + } + } + + ls, _, err := req.Execute() + if err != nil { + return vpn.IPSecTunnelReadList{}, err + } + return ls, nil +} + +type TunnelFilter func(request vpn.ApiIpsecgatewaysTunnelsGetRequest) (vpn.ApiIpsecgatewaysTunnelsGetRequest, error) + +func GatewayIDs() []string { + return GatewaysProperty(func(gateway vpn.IPSecGatewayRead) string { + return *gateway.Id + "\t" + *gateway.Properties.Name + "(" + *gateway.Properties.GatewayIP + ")" + }) +} + +func TunnelIDs(gatewayID string) []string { + return TunnelsProperty(gatewayID, func(p vpn.IPSecTunnelRead) string { + return *p.Id + "\t" + *p.Properties.Name + "(" + *p.Properties.RemoteHost + ")" + }) +} diff --git a/commands/vpn/ipsec/gateway/create.go b/commands/vpn/ipsec/gateway/create.go new file mode 100644 index 000000000..c920b3146 --- /dev/null +++ b/commands/vpn/ipsec/gateway/create.go @@ -0,0 +1,157 @@ +package gateway + +import ( + "context" + "fmt" + "net" + + cloudapiv6completer "github.com/ionos-cloud/ionosctl/v6/commands/cloudapi-v6/completer" + "github.com/ionos-cloud/ionosctl/v6/commands/dbaas/completer" + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/resource2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/ionos-cloud/ionosctl/v6/pkg/pointer" + + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "github.com/ionos-cloud/ionosctl/v6/internal/core" +) + +func Create() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec gateway", + Verb: "create", + Aliases: []string{"c", "post"}, + ShortDesc: "Create a IPSec Gateway", + Example: "ionosctl vpn ipsec gateway create " + core.FlagsUsage(constants.FlagName, constants.FlagDatacenterId, constants.FlagLanId, constants.FlagConnectionIP, constants.FlagGatewayIP, constants.FlagInterfaceIP), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, + constants.FlagName, + constants.FlagDatacenterId, + constants.FlagLanId, + constants.FlagConnectionIP, + constants.FlagGatewayIP, + ) + }, + CmdRun: func(c *core.CommandConfig) error { + input := &vpn.IPSecGateway{} + + if fn := core.GetFlagName(c.NS, constants.FlagName); viper.IsSet(fn) { + input.Name = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagDescription); viper.IsSet(fn) { + input.Description = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIp); viper.IsSet(fn) { + input.GatewayIP = pointer.From(viper.GetString(fn)) + } + + input.Connections = pointer.From(make([]vpn.Connection, 1)) + if fn := core.GetFlagName(c.NS, constants.FlagDatacenterId); viper.IsSet(fn) { + (*input.Connections)[0].DatacenterId = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagLanId); viper.IsSet(fn) { + (*input.Connections)[0].LanId = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagGatewayIP); viper.IsSet(fn) { + input.GatewayIP = pointer.From(viper.GetString(fn)) + } + + // Note: VPN Gateway handles IPv4 and IPv6 addresses separately for both InterfaceIP and Connections.IP + // We will use the same flag for both ipv4 and ipv6 for both of them, work out what type (v4 or v6) it is, + // and pass it to the API as the correct field (ipv4 or ipv6) + isIPv4 := func(ip string) bool { + if ipAddr, _, err := net.ParseCIDR(ip); err == nil { + return ipAddr.To4() != nil + } + return net.ParseIP(ip).To4() != nil + } + + if fn := core.GetFlagName(c.NS, constants.FlagConnectionIP); viper.IsSet(fn) { + ip := viper.GetString(fn) + if isIPv4(ip) { + (*input.Connections)[0].Ipv4CIDR = pointer.From(ip) + } else { + (*input.Connections)[0].Ipv6CIDR = pointer.From(ip) + } + } + + if fn := core.GetFlagName(c.NS, constants.FlagVersion); viper.IsSet(fn) { + input.Version = pointer.From(viper.GetString(fn)) + } + + createdGateway, _, err := client.Must().VPNClient.IPSecGatewaysApi. + IpsecgatewaysPost(context.Background()). + IPSecGatewayCreate(vpn.IPSecGatewayCreate{Properties: input}).Execute() + if err != nil { + return err + } + + table, err := resource2table.ConvertVPNIPSecGatewayToTable(createdGateway) + if err != nil { + return fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutputPreconverted(createdGateway, table, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagName, constants.FlagNameShort, "", "Name of the IPSec Gateway", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagDescription, "", "", "Description of the IPSec Gateway") + cmd.AddStringFlag(constants.FlagGatewayIP, "", "", "The IP of an IPBlock in the same location as the provided datacenter", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagGatewayIP, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + dc, _, _ := client.Must().CloudClient.DataCentersApi. + DatacentersFindById(context.Background(), viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))). + Execute() + + ipblocks, _, err := client.Must().CloudClient.IPBlocksApi. + IpblocksGet(context.Background()). + Filter("location", *dc.Properties.Location). + Execute() + if err != nil || ipblocks.Items == nil || len(*ipblocks.Items) == 0 { + return nil, cobra.ShellCompDirectiveError + } + var ips []string + for _, ipblock := range *ipblocks.Items { + if ipblock.Properties.Ips != nil { + ips = append(ips, *ipblock.Properties.Ips...) + } + } + return ips, cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagDatacenterId, "", "", "The datacenter to connect your VPN Gateway to", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagDatacenterId, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + loc, _ := c.Flags().GetString(constants.FlagLocation) + return cloudapiv6completer.DatacenterIdsFilterLocation(loc), cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagLanId, "", "", "The numeric LAN ID to connect your VPN Gateway to", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagLanId, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return cloudapiv6completer.LansIds(viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))), + cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagConnectionIP, "", "", "A LAN IPv4 or IPv6 address in CIDR notation that will be assigned to the VPN Gateway", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagConnectionIP, completer.GetCidrCompletionFunc(cmd)) + cmd.AddStringFlag(constants.FlagVersion, "", "IKEv2", "The IKE version that is permitted for the VPN tunnels") + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagVersion, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return []string{"IKEv2"}, cobra.ShellCompDirectiveNoFileComp + }) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/ipsec/gateway/delete.go b/commands/vpn/ipsec/gateway/delete.go new file mode 100644 index 000000000..c413f1730 --- /dev/null +++ b/commands/vpn/ipsec/gateway/delete.go @@ -0,0 +1,87 @@ +package gateway + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/pkg/confirm" + "github.com/ionos-cloud/ionosctl/v6/pkg/functional" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func Delete() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec gateway", + Verb: "delete", + Aliases: []string{"del", "d"}, + ShortDesc: "Delete a gateway", + Example: "ionosctl vpn ipsec gateway " + core.FlagsUsage(constants.FlagGatewayID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlagsSets(c.Command, c.NS, []string{constants.ArgAll}, []string{constants.FlagGatewayID}) + }, + CmdRun: func(c *core.CommandConfig) error { + if all := viper.GetBool(core.GetFlagName(c.NS, constants.ArgAll)); all { + return deleteAll(c) + } + + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + + g, _, err := client.Must().VPNClient.IPSecGatewaysApi.IpsecgatewaysFindById(context.Background(), id).Execute() + if err != nil { + return fmt.Errorf("failed getting gateway by id %s: %w", id, err) + } + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete gateway %s (desc: '%s')", *g.Properties.Name, *g.Properties.Description), + viper.GetBool(constants.ArgForce)) + if !yes { + return fmt.Errorf(confirm.UserDenied) + } + + _, err = client.Must().VPNClient.IPSecGatewaysApi.IpsecgatewaysDelete(context.Background(), id).Execute() + + return err + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the IPSec Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.AddBoolFlag(constants.ArgAll, constants.ArgAllShort, false, fmt.Sprintf("Delete all gateways. Required or --%s", constants.FlagGatewayID)) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} + +func deleteAll(c *core.CommandConfig) error { + fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateVerboseOutput("Deleting all gateways!")) + xs, _, err := client.Must().VPNClient.IPSecGatewaysApi.IpsecgatewaysGet(context.Background()).Execute() + if err != nil { + return err + } + + err = functional.ApplyAndAggregateErrors(*xs.GetItems(), func(g vpn.IPSecGatewayRead) error { + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete gateway %s at %s", *g.Properties.Name, *g.Properties.GatewayIP), + viper.GetBool(constants.ArgForce)) + if yes { + _, delErr := client.Must().VPNClient.IPSecGatewaysApi.IpsecgatewaysDelete(context.Background(), *g.Id).Execute() + if delErr != nil { + return fmt.Errorf("failed deleting %s (name: %s): %w", *g.Id, *g.Properties.Name, delErr) + } + } + return nil + }) + + return err +} diff --git a/commands/vpn/ipsec/gateway/gateway.go b/commands/vpn/ipsec/gateway/gateway.go new file mode 100644 index 000000000..c7c6a636d --- /dev/null +++ b/commands/vpn/ipsec/gateway/gateway.go @@ -0,0 +1,38 @@ +package gateway + +import ( + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/spf13/cobra" +) + +var ( + allCols = []string{"ID", "Name", "Description", "GatewayIP", "DatacenterId", "LanId", "ConnectionIPv4", "ConnectionIPv6", "Version", "Status"} + // we can safely include both InterfaceIPv4 and InterfaceIPv6 cols because if the respective column empty, it won't be shown + defaultCols = []string{"ID", "Name", "Description", "GatewayIP", "Version", "DatacenterId", "Status"} +) + +func Root() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "gateway", + Short: "Manage IPSec VPN Gateways", + Aliases: []string{"g", "gw"}, + TraverseChildren: true, + }, + } + + cmd.Command.PersistentFlags().StringSlice(constants.ArgCols, nil, tabheaders.ColsMessage(allCols)) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.ArgCols, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return allCols, cobra.ShellCompDirectiveNoFileComp + }) + + cmd.AddCommand(Create()) + cmd.AddCommand(List()) + cmd.AddCommand(Delete()) + cmd.AddCommand(Get()) + cmd.AddCommand(Update()) + + return cmd +} diff --git a/commands/vpn/ipsec/gateway/get.go b/commands/vpn/ipsec/gateway/get.go new file mode 100644 index 000000000..f58622c31 --- /dev/null +++ b/commands/vpn/ipsec/gateway/get.go @@ -0,0 +1,64 @@ +package gateway + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/resource2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/spf13/viper" +) + +func Get() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec gateway", + Verb: "get", + Aliases: []string{"g"}, + ShortDesc: "Find a gateway by ID", + Example: "ionosctl vpn ipsec gateway get " + core.FlagsUsage(constants.FlagGatewayID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, constants.FlagGatewayID) + }, + CmdRun: func(c *core.CommandConfig) error { + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + + g, _, err := client.Must().VPNClient.IPSecGatewaysApi.IpsecgatewaysFindById(context.Background(), id).Execute() + if err != nil { + return fmt.Errorf("failed getting gateway by id %s: %w", id, err) + } + + table, err := resource2table.ConvertVPNIPSecGatewayToTable(g) + if err != nil { + return fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutputPreconverted(g, table, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + + return err + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the IPSec Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/ipsec/gateway/list.go b/commands/vpn/ipsec/gateway/list.go new file mode 100644 index 000000000..639c3f2a3 --- /dev/null +++ b/commands/vpn/ipsec/gateway/list.go @@ -0,0 +1,65 @@ +package gateway + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/resource2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func List() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec gateway", + Verb: "list", + Aliases: []string{"l", "ls"}, + ShortDesc: "List IPSec Gateways", + Example: "ionosctl vpn ipsec gateway list", + PreCmdRun: func(c *core.PreCommandConfig) error { + return nil + }, + CmdRun: func(c *core.CommandConfig) error { + ls, err := completer.Gateways( + func(req vpn.ApiIpsecgatewaysGetRequest) (vpn.ApiIpsecgatewaysGetRequest, error) { + if fn := core.GetFlagName(c.NS, constants.FlagOffset); viper.IsSet(fn) { + req = req.Offset(viper.GetInt32(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagMaxResults); viper.IsSet(fn) { + req = req.Limit(viper.GetInt32(fn)) + } + return req, nil + }, + ) + if err != nil { + return fmt.Errorf("failed listing gateways: %w", err) + } + + table, err := resource2table.ConvertVPNIPSecGatewaysToTable(ls) + if err != nil { + return fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutputPreconverted(ls, table, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + }) + + cmd.AddInt32Flag(constants.FlagMaxResults, constants.FlagMaxResultsShort, 0, constants.DescMaxResults) + cmd.AddInt32Flag(constants.FlagOffset, "", 0, "Skip a certain number of results") + + return cmd +} diff --git a/commands/vpn/ipsec/gateway/update.go b/commands/vpn/ipsec/gateway/update.go new file mode 100644 index 000000000..dc723f17b --- /dev/null +++ b/commands/vpn/ipsec/gateway/update.go @@ -0,0 +1,167 @@ +package gateway + +import ( + "context" + "fmt" + "net" + + cloudapiv6completer "github.com/ionos-cloud/ionosctl/v6/commands/cloudapi-v6/completer" + dbcompleter "github.com/ionos-cloud/ionosctl/v6/commands/dbaas/completer" + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/resource2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/ionos-cloud/ionosctl/v6/pkg/pointer" + + // "github.com/ionos-cloud/ionosctl/v6/pkg/uuidgen" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "github.com/ionos-cloud/ionosctl/v6/internal/core" +) + +func Update() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec gateway", + Verb: "update", + Aliases: []string{"u", "put", "patch"}, + ShortDesc: "Update a IPSec Gateway", + Example: "ionosctl vpn ipsec gateway update " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagName, constants.FlagDatacenterId, constants.FlagLanId, constants.FlagConnectionIP, constants.FlagGatewayIP, constants.FlagInterfaceIP), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, constants.FlagGatewayID) + }, + CmdRun: func(c *core.CommandConfig) error { + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + original, _, err := client.Must().VPNClient.IPSecGatewaysApi.IpsecgatewaysFindById(context.Background(), + viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID))). + Execute() + input := original.Properties + + if fn := core.GetFlagName(c.NS, constants.FlagName); viper.IsSet(fn) { + input.Name = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagDescription); viper.IsSet(fn) { + input.Description = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIp); viper.IsSet(fn) { + input.GatewayIP = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagDatacenterId); viper.IsSet(fn) { + // initialize connections if not already set + if input.Connections == nil { + input.Connections = pointer.From(make([]vpn.Connection, 1)) + } + (*input.Connections)[0].DatacenterId = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagLanId); viper.IsSet(fn) { + if input.Connections == nil { + input.Connections = pointer.From(make([]vpn.Connection, 1)) + } + (*input.Connections)[0].LanId = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagGatewayIP); viper.IsSet(fn) { + input.GatewayIP = pointer.From(viper.GetString(fn)) + } + + // Note: VPN Gateway handles IPv4 and IPv6 addresses separately for both InterfaceIP and Connections.IP + // We will use the same flag for both ipv4 and ipv6 for both of them, work out what type (v4 or v6) it is, + // and pass it to the API as the correct field (ipv4 or ipv6) + isIPv4 := func(ip string) bool { + if ipAddr, _, err := net.ParseCIDR(ip); err == nil { + return ipAddr.To4() != nil + } + return net.ParseIP(ip).To4() != nil + } + + if fn := core.GetFlagName(c.NS, constants.FlagConnectionIP); viper.IsSet(fn) { + if input.Connections == nil { + input.Connections = pointer.From(make([]vpn.Connection, 1)) + } + ip := viper.GetString(fn) + if isIPv4(ip) { + (*input.Connections)[0].Ipv4CIDR = pointer.From(ip) + } else { + (*input.Connections)[0].Ipv6CIDR = pointer.From(ip) + } + } + + createdGateway, _, err := client.Must().VPNClient.IPSecGatewaysApi. + IpsecgatewaysPut(context.Background(), id). + IPSecGatewayEnsure(vpn.IPSecGatewayEnsure{Id: &id, Properties: input}).Execute() + if err != nil { + return fmt.Errorf("failed updating gateway: %w", err) + } + + table, err := resource2table.ConvertVPNIPSecGatewayToTable(createdGateway) + if err != nil { + return fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutputPreconverted(createdGateway, table, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the IPSec Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.AddStringFlag(constants.FlagName, constants.FlagNameShort, "", "Name of the IPSec Gateway", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagDescription, "", "", "Description of the IPSec Gateway") + cmd.AddStringFlag(constants.FlagGatewayIP, "", "", "The IP of an IPBlock in the same location as the provided datacenter", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagGatewayIP, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + dc, _, _ := client.Must().CloudClient.DataCentersApi. + DatacentersFindById(context.Background(), viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))). + Execute() + + ipblocks, _, err := client.Must().CloudClient.IPBlocksApi. + IpblocksGet(context.Background()). + Filter("location", *dc.Properties.Location). + Execute() + if err != nil || ipblocks.Items == nil || len(*ipblocks.Items) == 0 { + return nil, cobra.ShellCompDirectiveError + } + var ips []string + for _, ipblock := range *ipblocks.Items { + if ipblock.Properties.Ips != nil { + ips = append(ips, *ipblock.Properties.Ips...) + } + } + return ips, cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagDatacenterId, "", "", "The datacenter to connect your VPN Gateway to", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagDatacenterId, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + loc, _ := c.Flags().GetString(constants.FlagLocation) + return cloudapiv6completer.DatacenterIdsFilterLocation(loc), cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagLanId, "", "", "The numeric LAN ID to connect your VPN Gateway to", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagLanId, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return cloudapiv6completer.LansIds(viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))), + cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagConnectionIP, "", "", "A LAN IPv4 or IPv6 address in CIDR notation that will be assigned to the VPN Gateway", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagConnectionIP, dbcompleter.GetCidrCompletionFunc(cmd)) + cmd.AddStringFlag(constants.FlagVersion, "", "IKEv2", "The IKE version that is permitted for the VPN tunnels") + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagVersion, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return []string{"IKEv2"}, cobra.ShellCompDirectiveNoFileComp + }) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/ipsec/ipsec.go b/commands/vpn/ipsec/ipsec.go new file mode 100644 index 000000000..56d5b596c --- /dev/null +++ b/commands/vpn/ipsec/ipsec.go @@ -0,0 +1,22 @@ +package ipsec + +import ( + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/gateway" + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/tunnel" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/spf13/cobra" +) + +func Root() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "ipsec", + Short: "Manage ipsec VPN Resources", + TraverseChildren: true, + }, + } + cmd.AddCommand(gateway.Root()) + cmd.AddCommand(tunnel.Root()) + + return cmd +} diff --git a/commands/vpn/ipsec/tunnel/create.go b/commands/vpn/ipsec/tunnel/create.go new file mode 100644 index 000000000..d599fcdc1 --- /dev/null +++ b/commands/vpn/ipsec/tunnel/create.go @@ -0,0 +1,187 @@ +package tunnel + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/ionos-cloud/ionosctl/v6/pkg/pointer" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func Create() *core.Command { + jsonPropertiesExample := "{\n \"properties\": {\n \"name\": \"My Company Gateway Tunnel\",\n \"description\": \"Allows local subnet X to connect to virtual network Y.\",\n \"remoteHost\": \"vpn.mycompany.com\",\n \"auth\": {\n \"method\": \"PSK\",\n \"psk\": {\n \"key\": \"X2wosbaw74M8hQGbK3jCCaEusR6CCFRa\"\n }\n },\n \"ike\": {\n \"diffieHellmanGroup\": \"16-MODP4096\",\n \"encryptionAlgorithm\": \"AES256\",\n \"integrityAlgorithm\": \"SHA256\",\n \"lifetime\": 86400\n },\n \"esp\": {\n \"diffieHellmanGroup\": \"16-MODP4096\",\n \"encryptionAlgorithm\": \"AES256\",\n \"integrityAlgorithm\": \"SHA256\",\n \"lifetime\": 3600\n },\n \"cloudNetworkCIDRs\": [\n \"192.168.1.100/24\"\n ],\n \"peerNetworkCIDRs\": [\n \"1.2.3.4/32\"\n ]\n }\n}" + tunnelViaJson := vpn.IPSecTunnelCreate{} + cmd := core.NewCommandWithJsonProperties(context.Background(), nil, jsonPropertiesExample, &tunnelViaJson, + core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec tunnel", + Verb: "create", + Aliases: []string{"c", "post"}, + ShortDesc: "Create a IPSec tunnel", + LongDesc: "Create IPSec tunnels", + Example: "ionosctl vpn ipsec tunnel create " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagName, constants.FlagHost, constants.FlagAuthMethod, constants.FlagPSKKey, constants.FlagIKEDiffieHellmanGroup, constants.FlagIKEEncryptionAlgorithm, constants.FlagIKEIntegrityAlgorithm, constants.FlagIKELifetime, constants.FlagESPDiffieHellmanGroup, constants.FlagESPEncryptionAlgorithm, constants.FlagESPIntegrityAlgorithm, constants.FlagESPLifetime, constants.FlagCloudNetworkCIDRs, constants.FlagPeerNetworkCIDRs) + "\n" + "ionosctl vpn ipsec tunnel create " + core.FlagsUsage(constants.FlagJsonProperties) + "\n" + "ionosctl vpn ipsec tunnel create " + core.FlagsUsage(constants.FlagJsonProperties) + " " + constants.FlagJsonPropertiesExample, + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlagsSets(c.Command, c.NS, + []string{constants.FlagJsonProperties, constants.FlagGatewayID}, + []string{constants.FlagJsonPropertiesExample}, + []string{ + constants.FlagGatewayID, + constants.FlagName, + constants.FlagHost, + constants.FlagAuthMethod, + constants.FlagPSKKey, + constants.FlagIKEDiffieHellmanGroup, + constants.FlagIKEEncryptionAlgorithm, + constants.FlagIKEIntegrityAlgorithm, + constants.FlagIKELifetime, + constants.FlagESPDiffieHellmanGroup, + constants.FlagESPEncryptionAlgorithm, + constants.FlagESPIntegrityAlgorithm, + constants.FlagESPLifetime, + constants.FlagCloudNetworkCIDRs, + constants.FlagPeerNetworkCIDRs, + }, + ) + }, + CmdRun: func(c *core.CommandConfig) error { + if c.Command.Command.Flags().Changed(constants.FlagJsonProperties) { + j, _ := json.MarshalIndent(tunnelViaJson, "", " ") + fmt.Println(string(j)) + + return createFromJSON(c, tunnelViaJson) + } + return createFromProperties(c) + }, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the IPSec Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.AddStringFlag(constants.FlagName, "", "", "Name of the IPSec Tunnel", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagDescription, "", "", "Description of the IPSec Tunnel") + cmd.AddStringFlag(constants.FlagHost, "", "", "The remote peer host fully qualified domain name or IPV4 IP to connect to. * __Note__: This should be the public IP of the remote peer. * Tunnels only support IPV4 or hostname (fully qualified DNS name).", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagAuthMethod, "", "", "The authentication method for the IPSec tunnel. Valid values are PSK or RSA", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagPSKKey, "", "", "The pre-shared key for the IPSec tunnel", core.RequiredFlagOption()) + + cmd.AddSetFlag(constants.FlagIKEDiffieHellmanGroup, "", "", []string{"15-MODP3072", "16-MODP4096", "19-ECP256", "20-ECP384", "21-ECP521", "28-ECP256BP", "29-ECP384BP", "30-ECP512BP"}, "The Diffie-Hellman Group to use for IPSec Encryption.") + cmd.AddSetFlag(constants.FlagIKEEncryptionAlgorithm, "", "", []string{"AES128", "AES256"}, "The encryption algorithm to use for IPSec Encryption.") + cmd.AddSetFlag(constants.FlagIKEIntegrityAlgorithm, "", "", []string{"SHA256", "SHA384", "SHA512", "AES-XCBC"}, "The integrity algorithm to use for IPSec Encryption.") + cmd.AddInt32Flag(constants.FlagIKELifetime, "", 0, "The phase lifetime in seconds") + + cmd.AddSetFlag(constants.FlagESPDiffieHellmanGroup, "", "", []string{"15-MODP3072", "16-MODP4096", "19-ECP256", "20-ECP384", "21-ECP521", "28-ECP256BP", "29-ECP384BP", "30-ECP512BP"}, "The Diffie-Hellman Group to use for IPSec Encryption.") + cmd.AddSetFlag(constants.FlagESPEncryptionAlgorithm, "", "", []string{"AES128-CTR", "AES256-CTR", "AES128-GCM-16", "AES256-GCM-16", "AES128-GCM-12", "AES256-GCM-12", "AES128-CCM-12", "AES256-CCM-12", "AES128", "AES256"}, "The encryption algorithm to use for IPSec Encryption.") + cmd.AddSetFlag(constants.FlagESPIntegrityAlgorithm, "", "", []string{"SHA256", "SHA384", "SHA512", "AES-XCBC"}, "The integrity algorithm to use for IPSec Encryption.") + cmd.AddInt32Flag(constants.FlagESPLifetime, "", 0, "The phase lifetime in seconds") + + cmd.AddStringSliceFlag(constants.FlagCloudNetworkCIDRs, "", []string{}, "The network CIDRs on the \"Left\" side that are allowed to connect to the IPSec tunnel, i.e the CIDRs within your IONOS Cloud LAN. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses.") + cmd.AddStringSliceFlag(constants.FlagPeerNetworkCIDRs, "", []string{}, "The network CIDRs on the \"Right\" side that are allowed to connect to the IPSec tunnel. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses.") + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} + +func createFromJSON(c *core.CommandConfig, propertiesFromJson vpn.IPSecTunnelCreate) error { + tunnel, _, err := client.Must().VPNClient.IPSecTunnelsApi. + IpsecgatewaysTunnelsPost(context.Background(), viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID))). + IPSecTunnelCreate(propertiesFromJson).Execute() + if err != nil { + return err + } + + return handleOutput(c, tunnel) +} + +func createFromProperties(c *core.CommandConfig) error { + input := &vpn.IPSecTunnel{} + + if fn := core.GetFlagName(c.NS, constants.FlagName); viper.IsSet(fn) { + input.Name = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagDescription); viper.IsSet(fn) { + input.Description = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagHost); viper.IsSet(fn) { + input.RemoteHost = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagAuthMethod); viper.IsSet(fn) { + input.Auth = &vpn.IPSecTunnelAuth{} + input.Auth.Method = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPSKKey); viper.IsSet(fn) { + input.Auth.Psk = &vpn.IPSecPSK{} + input.Auth.Psk.Key = pointer.From(viper.GetString(fn)) + } + + input.Ike = &vpn.IKEEncryption{} + if fn := core.GetFlagName(c.NS, constants.FlagIKEDiffieHellmanGroup); viper.IsSet(fn) { + input.Ike.DiffieHellmanGroup = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIKEEncryptionAlgorithm); viper.IsSet(fn) { + input.Ike.EncryptionAlgorithm = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIKEIntegrityAlgorithm); viper.IsSet(fn) { + input.Ike.IntegrityAlgorithm = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIKELifetime); viper.IsSet(fn) { + input.Ike.Lifetime = pointer.From(int32(viper.GetInt(fn))) + } + + input.Esp = &vpn.ESPEncryption{} + if fn := core.GetFlagName(c.NS, constants.FlagESPDiffieHellmanGroup); viper.IsSet(fn) { + input.Esp.DiffieHellmanGroup = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagESPEncryptionAlgorithm); viper.IsSet(fn) { + input.Esp.EncryptionAlgorithm = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagESPIntegrityAlgorithm); viper.IsSet(fn) { + input.Esp.IntegrityAlgorithm = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagESPLifetime); viper.IsSet(fn) { + input.Esp.Lifetime = pointer.From(int32(viper.GetInt(fn))) + } + + if fn := core.GetFlagName(c.NS, constants.FlagCloudNetworkCIDRs); viper.IsSet(fn) { + input.CloudNetworkCIDRs = pointer.From(viper.GetStringSlice(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagPeerNetworkCIDRs); viper.IsSet(fn) { + input.PeerNetworkCIDRs = pointer.From(viper.GetStringSlice(fn)) + } + tunnel, _, err := client.Must().VPNClient.IPSecTunnelsApi. + IpsecgatewaysTunnelsPost(context.Background(), viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID))). + IPSecTunnelCreate(vpn.IPSecTunnelCreate{Properties: input}).Execute() + if err != nil { + return err + } + + return handleOutput(c, tunnel) +} + +func handleOutput(c *core.CommandConfig, tunnel vpn.IPSecTunnelRead) error { + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + + out, err := jsontabwriter.GenerateOutput("", jsonpaths.VPNIPSecTunnel, tunnel, tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + + return nil +} diff --git a/commands/vpn/ipsec/tunnel/delete.go b/commands/vpn/ipsec/tunnel/delete.go new file mode 100644 index 000000000..b24df4f77 --- /dev/null +++ b/commands/vpn/ipsec/tunnel/delete.go @@ -0,0 +1,99 @@ +package tunnel + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/pkg/confirm" + "github.com/ionos-cloud/ionosctl/v6/pkg/functional" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func Delete() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec tunnel", + Verb: "delete", + Aliases: []string{"d", "del", "rm"}, + ShortDesc: "Remove a IPSec Tunnel", + Example: "ionosctl vpn ipsec tunnel delete " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagTunnelID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlagsSets(c.Command, c.NS, + []string{constants.FlagGatewayID, constants.FlagTunnelID}, + []string{constants.FlagGatewayID, constants.ArgAll}, + ) + }, + CmdRun: func(c *core.CommandConfig) error { + if all := viper.GetBool(core.GetFlagName(c.NS, constants.ArgAll)); all { + return deleteAll(c) + } + + gatewayId := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagTunnelID)) + p, _, err := client.Must().VPNClient.IPSecTunnelsApi.IpsecgatewaysTunnelsFindById(context.Background(), gatewayId, id).Execute() + if err != nil { + return fmt.Errorf("failed getting tunnel by id %s: %w", id, err) + } + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete tunnel %s"+ + " (host: '%s')", *p.Properties.Name, *p.Properties.RemoteHost), + viper.GetBool(constants.ArgForce)) + if !yes { + return fmt.Errorf(confirm.UserDenied) + } + + _, err = client.Must().VPNClient.IPSecTunnelsApi.IpsecgatewaysTunnelsDelete(context.Background(), gatewayId, id).Execute() + + return nil + }, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, "", "", "The ID of the IPSec Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + cmd.AddStringFlag(constants.FlagTunnelID, constants.FlagIdShort, "", "The ID of the IPSec Tunnel you want to delete", + core.RequiredFlagOption(), + core.WithCompletion(func() []string { + gatewayID := viper.GetString(core.GetFlagName(cmd.NS, constants.FlagGatewayID)) + return completer.TunnelIDs(gatewayID) + }, constants.VPNApiRegionalURL), + ) + + cmd.AddBoolFlag(constants.ArgAll, constants.ArgAllShort, false, fmt.Sprintf("Delete all tunnels. Required or --%s", constants.FlagTunnelID)) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} + +func deleteAll(c *core.CommandConfig) error { + gatewayId := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateVerboseOutput("Deleting all tunnels from gateway %s!", gatewayId)) + + xs, _, err := client.Must().VPNClient.IPSecTunnelsApi.IpsecgatewaysTunnelsGet(context.Background(), gatewayId).Execute() + if err != nil { + return err + } + + err = functional.ApplyAndAggregateErrors(*xs.GetItems(), func(p vpn.IPSecTunnelRead) error { + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete tunnel %s at %s", *p.Properties.Name, *p.Properties.RemoteHost), + viper.GetBool(constants.ArgForce)) + if yes { + _, delErr := client.Must().VPNClient.IPSecGatewaysApi.IpsecgatewaysDelete(context.Background(), *p.Id).Execute() + if delErr != nil { + return fmt.Errorf("failed deleting %s (name: %s): %w", *p.Id, *p.Properties.Name, delErr) + } + } + return nil + }) + + return err +} diff --git a/commands/vpn/ipsec/tunnel/get.go b/commands/vpn/ipsec/tunnel/get.go new file mode 100644 index 000000000..d0702f875 --- /dev/null +++ b/commands/vpn/ipsec/tunnel/get.go @@ -0,0 +1,68 @@ +package tunnel + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/spf13/viper" +) + +func Get() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec tunnel", + Verb: "get", + Aliases: []string{"g"}, + ShortDesc: "Find a tunnel by ID", + Example: "ionosctl vpn ipsec tunnel get " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagTunnelID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, constants.FlagGatewayID, constants.FlagTunnelID) + }, + CmdRun: func(c *core.CommandConfig) error { + gatewayId := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagTunnelID)) + + p, _, err := client.Must().VPNClient.IPSecTunnelsApi.IpsecgatewaysTunnelsFindById(context.Background(), gatewayId, id).Execute() + if err != nil { + return fmt.Errorf("failed getting tunnel by id %s: %w", id, err) + } + + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutput("", jsonpaths.VPNIPSecTunnel, p, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + + return err + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, "", "", "The ID of the IPSec Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + cmd.AddStringFlag(constants.FlagTunnelID, constants.FlagIdShort, "", "The ID of the IPSec Tunnel", + core.RequiredFlagOption(), + core.WithCompletion(func() []string { + gatewayID := viper.GetString(core.GetFlagName(cmd.NS, constants.FlagGatewayID)) + return completer.TunnelIDs(gatewayID) + }, constants.VPNApiRegionalURL), + ) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/ipsec/tunnel/list.go b/commands/vpn/ipsec/tunnel/list.go new file mode 100644 index 000000000..3e8c17748 --- /dev/null +++ b/commands/vpn/ipsec/tunnel/list.go @@ -0,0 +1,67 @@ +package tunnel + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func List() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec tunnel", + Verb: "list", + Aliases: []string{"l", "ls"}, + ShortDesc: "List IPSec Tunnels", + Example: "ionosctl vpn ipsec tunnel list " + core.FlagsUsage(constants.FlagGatewayID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, constants.FlagGatewayID) + }, + CmdRun: func(c *core.CommandConfig) error { + ls, err := completer.Tunnels( + viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)), + func(req vpn.ApiIpsecgatewaysTunnelsGetRequest) (vpn.ApiIpsecgatewaysTunnelsGetRequest, error) { + if fn := core.GetFlagName(c.NS, constants.FlagOffset); viper.IsSet(fn) { + req = req.Offset(viper.GetInt32(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagMaxResults); viper.IsSet(fn) { + req = req.Limit(viper.GetInt32(fn)) + } + return req, nil + }, + ) + if err != nil { + return fmt.Errorf("failed listing tunnels: %w", err) + } + + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutput("items", jsonpaths.VPNIPSecTunnel, ls, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the IPSec Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.AddInt32Flag(constants.FlagMaxResults, constants.FlagMaxResultsShort, 0, constants.DescMaxResults) + cmd.AddInt32Flag(constants.FlagOffset, "", 0, "Skip a certain number of results") + + return cmd +} diff --git a/commands/vpn/ipsec/tunnel/tunnel.go b/commands/vpn/ipsec/tunnel/tunnel.go new file mode 100644 index 000000000..054295929 --- /dev/null +++ b/commands/vpn/ipsec/tunnel/tunnel.go @@ -0,0 +1,67 @@ +package tunnel + +import ( + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/spf13/cobra" +) + +/* +A IPSec Tunnel is any device (client, server, or another gateway) that participates in a IPSec VPN. Tunnels are identified by public/private key pairs. +IPSec does not need complex negotiation (like IPsec IKE phases). Once two Tunnels know each other’s public keys and IP addresses, they can connect instantly. +IPSec is stateless: no persistent state is stored between connections, and packets are exchanged only when needed. +There is no session or tunnel establishment process like in IPsec. Instead, IPSec Tunnels exchange packets as needed without keeping an active session. +*/ + +/* + var VPNIPSecTunnel = map[string]string{ + "ID": "id", + "Name": "properties.name", + "Description": "properties.description", + "RemoteHost": "properties.remoteHost", + "AuthMethod": "properties.auth.method", + "PSKKey": "properties.auth.psk.key", + "IKEDiffieHellmanGroup": "properties.ike.diffieHellmanGroup", + "IKEEncryptionAlgorithm": "properties.ike.encryptionAlgorithm", + "IKEIntegrityAlgorithm": "properties.ike.integrityAlgorithm", + "IKELifetime": "properties.ike.lifetime", + "ESPDiffieHellmanGroup": "properties.esp.diffieHellmanGroup", + "ESPEncryptionAlgorithm": "properties.esp.encryptionAlgorithm", + "ESPIntegrityAlgorithm": "properties.esp.integrityAlgorithm", + "ESPLifetime": "properties.esp.lifetime", + "CloudNetworkCIDRs": "properties.cloudNetworkCIDRs", + "PeerNetworkCIDRs": "properties.peerNetworkCIDRs", + } +*/ +var ( + allCols = []string{"ID", "Name", "Description", "RemoteHost", "AuthMethod", "PSKKey", + "IKEDiffieHellmanGroup", "IKEEncryptionAlgorithm", "IKEIntegrityAlgorithm", "IKELifetime", + "ESPDiffieHellmanGroup", "ESPEncryptionAlgorithm", "ESPIntegrityAlgorithm", "ESPLifetime", + "CloudNetworkCIDRs", "PeerNetworkCIDRs", "Status", "StatusMessage"} + defaultCols = []string{"ID", "Name", "Description", "RemoteHost", "AuthMethod", "PSKKey", "Status"} +) + +func Root() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "tunnel", + Short: "Manage IPSec VPN Tunnels", + Aliases: []string{"p"}, + TraverseChildren: true, + }, + } + + cmd.Command.PersistentFlags().StringSlice(constants.ArgCols, nil, tabheaders.ColsMessage(allCols)) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.ArgCols, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return allCols, cobra.ShellCompDirectiveNoFileComp + }) + + cmd.AddCommand(Create()) + cmd.AddCommand(List()) + cmd.AddCommand(Get()) + cmd.AddCommand(Delete()) + cmd.AddCommand(Update()) + + return cmd +} diff --git a/commands/vpn/ipsec/tunnel/update.go b/commands/vpn/ipsec/tunnel/update.go new file mode 100644 index 000000000..1a8aa9a8c --- /dev/null +++ b/commands/vpn/ipsec/tunnel/update.go @@ -0,0 +1,190 @@ +package tunnel + +import ( + "context" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec/completer" + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/pkg/pointer" + + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func Update() *core.Command { + jsonPropertiesExample := "{\n \"metadata\": {},\n \"properties\": {\n \"name\": \"My Company Gateway Tunnel\",\n \"description\": \"Allows local subnet X to connect to virtual network Y.\",\n \"remoteHost\": \"vpn.mycompany.com\",\n \"auth\": {\n \"method\": \"PSK\",\n \"psk\": {\n \"key\": \"X2wosbaw74M8hQGbK3jCCaEusR6CCFRa\"\n }\n },\n \"ike\": {\n \"diffieHellmanGroup\": \"16-MODP4096\",\n \"encryptionAlgorithm\": \"AES256\",\n \"integrityAlgorithm\": \"SHA256\",\n \"lifetime\": 86400\n },\n \"esp\": {\n \"diffieHellmanGroup\": \"16-MODP4096\",\n \"encryptionAlgorithm\": \"AES256\",\n \"integrityAlgorithm\": \"SHA256\",\n \"lifetime\": 3600\n },\n \"cloudNetworkCIDRs\": [\n \"192.168.1.100/24\"\n ],\n \"peerNetworkCIDRs\": [\n \"1.2.3.4/32\"\n ]\n }\n}" + tunnelViaJson := vpn.IPSecTunnel{} + cmd := core.NewCommandWithJsonProperties(context.Background(), nil, jsonPropertiesExample, tunnelViaJson, core.CommandBuilder{ + Namespace: "vpn", + Resource: "ipsec tunnel", + Verb: "update", + Aliases: []string{"u", "patch", "put"}, + ShortDesc: "Update a IPSec Tunnel", + Example: "ionosctl vpn ipsec tunnel update " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagTunnelID, constants.FlagName), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlagsSets(c.Command, c.NS, + []string{constants.FlagGatewayID, constants.FlagTunnelID}, + []string{constants.FlagJsonProperties, constants.FlagGatewayID, constants.FlagTunnelID}, + []string{constants.FlagJsonPropertiesExample}, + ) + }, + CmdRun: func(c *core.CommandConfig) error { + if viper.IsSet(constants.FlagJsonProperties) { + return putFromJSON(c, tunnelViaJson) + } + + return putFromProperties(c) + }, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, "", "", "The ID of the IPSec Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + cmd.AddStringFlag(constants.FlagTunnelID, constants.FlagIdShort, "", "The ID of the IPSec Tunnel", + core.RequiredFlagOption(), + core.WithCompletion(func() []string { + gatewayID := viper.GetString(core.GetFlagName(cmd.NS, constants.FlagGatewayID)) + return completer.TunnelIDs(gatewayID) + }, constants.VPNApiRegionalURL), + ) + + cmd.AddStringFlag(constants.FlagName, "", "", "Name of the IPSec Tunnel", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagDescription, "", "", "Description of the IPSec Tunnel") + cmd.AddStringFlag(constants.FlagHost, "", "", "The remote peer host fully qualified domain name or IPV4 IP to connect to. * __Note__: This should be the public IP of the remote peer. * Tunnels only support IPV4 or hostname (fully qualified DNS name).", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagAuthMethod, "", "", "The authentication method for the IPSec tunnel. Valid values are PSK or RSA", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagPSKKey, "", "", "The pre-shared key for the IPSec tunnel", core.RequiredFlagOption()) + + cmd.AddSetFlag(constants.FlagIKEDiffieHellmanGroup, "", "", []string{"15-MODP3072", "16-MODP4096", "19-ECP256", "20-ECP384", "21-ECP521", "28-ECP256BP", "29-ECP384BP", "30-ECP512BP"}, "The Diffie-Hellman Group to use for IPSec Encryption.") + cmd.AddSetFlag(constants.FlagIKEEncryptionAlgorithm, "", "", []string{"AES128", "AES256"}, "The encryption algorithm to use for IPSec Encryption.") + cmd.AddSetFlag(constants.FlagIKEIntegrityAlgorithm, "", "", []string{"SHA256", "SHA384", "SHA512", "AES-XCBC"}, "The integrity algorithm to use for IPSec Encryption.") + cmd.AddInt32Flag(constants.FlagIKELifetime, "", 0, "The phase lifetime in seconds") + + cmd.AddSetFlag(constants.FlagESPDiffieHellmanGroup, "", "", []string{"15-MODP3072", "16-MODP4096", "19-ECP256", "20-ECP384", "21-ECP521", "28-ECP256BP", "29-ECP384BP", "30-ECP512BP"}, "The Diffie-Hellman Group to use for IPSec Encryption.") + cmd.AddSetFlag(constants.FlagESPEncryptionAlgorithm, "", "", []string{"AES128-CTR", "AES256-CTR", "AES128-GCM-16", "AES256-GCM-16", "AES128-GCM-12", "AES256-GCM-12", "AES128-CCM-12", "AES256-CCM-12", "AES128", "AES256"}, "The encryption algorithm to use for IPSec Encryption.") + cmd.AddSetFlag(constants.FlagESPIntegrityAlgorithm, "", "", []string{"SHA256", "SHA384", "SHA512", "AES-XCBC"}, "The integrity algorithm to use for IPSec Encryption.") + cmd.AddInt32Flag(constants.FlagESPLifetime, "", 0, "The phase lifetime in seconds") + + cmd.AddStringSliceFlag(constants.FlagCloudNetworkCIDRs, "", []string{}, "The network CIDRs on the \"Left\" side that are allowed to connect to the IPSec tunnel, i.e the CIDRs within your IONOS Cloud LAN. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses.") + cmd.AddStringSliceFlag(constants.FlagPeerNetworkCIDRs, "", []string{}, "The network CIDRs on the \"Right\" side that are allowed to connect to the IPSec tunnel. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses.") + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} + +func putFromJSON(c *core.CommandConfig, propertiesFromJson vpn.IPSecTunnel) error { + tunnel, _, err := client.Must().VPNClient.IPSecTunnelsApi. + IpsecgatewaysTunnelsPut(context.Background(), + viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)), viper.GetString(core.GetFlagName(c.NS, constants.FlagTunnelID))). + IPSecTunnelEnsure(vpn.IPSecTunnelEnsure{Properties: &propertiesFromJson}).Execute() + if err != nil { + return err + } + + return handleOutput(c, tunnel) +} + +func putFromProperties(c *core.CommandConfig) error { + original, _, err := client.Must().VPNClient.IPSecTunnelsApi.IpsecgatewaysTunnelsFindById(context.Background(), + viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)), viper.GetString(core.GetFlagName(c.NS, constants.FlagTunnelID))). + Execute() + if err != nil { + return err + } + input := original.Properties + + if fn := core.GetFlagName(c.NS, constants.FlagName); viper.IsSet(fn) { + input.Name = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagDescription); viper.IsSet(fn) { + input.Description = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagHost); viper.IsSet(fn) { + input.RemoteHost = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagAuthMethod); viper.IsSet(fn) { + input.Auth = &vpn.IPSecTunnelAuth{} + input.Auth.Method = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPSKKey); viper.IsSet(fn) { + input.Auth.Psk = &vpn.IPSecPSK{} + input.Auth.Psk.Key = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagIKEDiffieHellmanGroup); viper.IsSet(fn) { + if input.Ike == nil { + input.Ike = &vpn.IKEEncryption{} + } + input.Ike.DiffieHellmanGroup = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIKEEncryptionAlgorithm); viper.IsSet(fn) { + if input.Ike == nil { + input.Ike = &vpn.IKEEncryption{} + } + input.Ike.EncryptionAlgorithm = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIKEIntegrityAlgorithm); viper.IsSet(fn) { + if input.Ike == nil { + input.Ike = &vpn.IKEEncryption{} + } + input.Ike.IntegrityAlgorithm = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIKELifetime); viper.IsSet(fn) { + if input.Ike == nil { + input.Ike = &vpn.IKEEncryption{} + } + input.Ike.Lifetime = pointer.From(int32(viper.GetInt(fn))) + } + + if fn := core.GetFlagName(c.NS, constants.FlagESPDiffieHellmanGroup); viper.IsSet(fn) { + if input.Esp == nil { + input.Esp = &vpn.ESPEncryption{} + } + input.Esp.DiffieHellmanGroup = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagESPEncryptionAlgorithm); viper.IsSet(fn) { + if input.Esp == nil { + input.Esp = &vpn.ESPEncryption{} + } + input.Esp.EncryptionAlgorithm = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagESPIntegrityAlgorithm); viper.IsSet(fn) { + if input.Esp == nil { + input.Esp = &vpn.ESPEncryption{} + } + input.Esp.IntegrityAlgorithm = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagESPLifetime); viper.IsSet(fn) { + if input.Esp == nil { + input.Esp = &vpn.ESPEncryption{} + } + input.Esp.Lifetime = pointer.From(int32(viper.GetInt(fn))) + } + + if fn := core.GetFlagName(c.NS, constants.FlagCloudNetworkCIDRs); viper.IsSet(fn) { + input.CloudNetworkCIDRs = pointer.From(viper.GetStringSlice(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagPeerNetworkCIDRs); viper.IsSet(fn) { + input.PeerNetworkCIDRs = pointer.From(viper.GetStringSlice(fn)) + } + tunnel, _, err := client.Must().VPNClient.IPSecTunnelsApi. + IpsecgatewaysTunnelsPut(context.Background(), + viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)), viper.GetString(core.GetFlagName(c.NS, constants.FlagTunnelID))). + IPSecTunnelEnsure(vpn.IPSecTunnelEnsure{ + Id: pointer.From(viper.GetString(core.GetFlagName(c.NS, constants.FlagTunnelID))), + Properties: input, + }).Execute() + if err != nil { + return err + } + + return handleOutput(c, tunnel) +} diff --git a/commands/vpn/vpn.go b/commands/vpn/vpn.go new file mode 100644 index 000000000..c74b45e09 --- /dev/null +++ b/commands/vpn/vpn.go @@ -0,0 +1,25 @@ +package vpn + +import ( + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/ipsec" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/spf13/cobra" +) + +func Root() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "vpn", + Short: "VPN Operations", + TraverseChildren: true, + }, + } + + cmd.AddCommand(wireguard.Root()) + cmd.AddCommand(ipsec.Root()) + + return core.WithRegionalFlags(cmd, constants.VPNApiRegionalURL, constants.VPNLocations) +} diff --git a/commands/vpn/wireguard/completer/completer.go b/commands/vpn/wireguard/completer/completer.go new file mode 100644 index 000000000..09c279dd1 --- /dev/null +++ b/commands/vpn/wireguard/completer/completer.go @@ -0,0 +1,83 @@ +package completer + +import ( + "context" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/pkg/functional" + vpn "github.com/ionos-cloud/sdk-go-vpn" +) + +// -- GATEWAYS + +// GatewaysProperty returns a list of properties of all gateways matching the given filters +func GatewaysProperty[V any](f func(gateway vpn.WireguardGatewayRead) V, fs ...GatewayFilter) []V { + recs, err := Gateways(fs...) + if err != nil { + return nil + } + return functional.Map(*recs.Items, f) +} + +// Gateways returns all distributions matching the given filters +func Gateways(fs ...GatewayFilter) (vpn.WireguardGatewayReadList, error) { + req := client.Must().VPNClient.WireguardGatewaysApi.WireguardgatewaysGet(context.Background()) + for _, f := range fs { + var err error + req, err = f(req) + if err != nil { + return vpn.WireguardGatewayReadList{}, err + } + } + + ls, _, err := req.Execute() + if err != nil { + return vpn.WireguardGatewayReadList{}, err + } + return ls, nil +} + +type GatewayFilter func(request vpn.ApiWireguardgatewaysGetRequest) (vpn.ApiWireguardgatewaysGetRequest, error) + +// -- PEERS + +// PeersProperty returns a list of properties of all peers matching the given filters +func PeersProperty[V any](gatewayID string, f func(peer vpn.WireguardPeerRead) V, fs ...PeerFilter) []V { + recs, err := Peers(gatewayID, fs...) + if err != nil { + return nil + } + return functional.Map(*recs.Items, f) +} + +// Peers returns all distributions matching the given filters +func Peers(gatewayID string, fs ...PeerFilter) (vpn.WireguardPeerReadList, error) { + req := client.Must().VPNClient.WireguardPeersApi.WireguardgatewaysPeersGet(context.Background(), gatewayID) + for _, f := range fs { + var err error + req, err = f(req) + if err != nil { + return vpn.WireguardPeerReadList{}, err + } + } + + ls, _, err := req.Execute() + if err != nil { + return vpn.WireguardPeerReadList{}, err + } + return ls, nil +} + +type PeerFilter func(request vpn.ApiWireguardgatewaysPeersGetRequest) (vpn.ApiWireguardgatewaysPeersGetRequest, error) + +func GatewayIDs() []string { + return GatewaysProperty(func(gateway vpn.WireguardGatewayRead) string { + return *gateway.Id + "\t" + *gateway.Properties.Name + "(" + *gateway.Properties.GatewayIP + ")" + }) +} + +func PeerIDs(gatewayID string) []string { + return PeersProperty(gatewayID, func(p vpn.WireguardPeerRead) string { + return *p.Id + "\t" + *p.Properties.Name + "(" + *p.Properties.Endpoint.Host + ")" + }) +} diff --git a/commands/vpn/wireguard/gateway/create.go b/commands/vpn/wireguard/gateway/create.go new file mode 100644 index 000000000..6b4a8de64 --- /dev/null +++ b/commands/vpn/wireguard/gateway/create.go @@ -0,0 +1,190 @@ +package gateway + +import ( + "context" + "fmt" + "net" + "os" + + cloudapiv6completer "github.com/ionos-cloud/ionosctl/v6/commands/cloudapi-v6/completer" + "github.com/ionos-cloud/ionosctl/v6/commands/dbaas/completer" + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/resource2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/ionos-cloud/ionosctl/v6/pkg/pointer" + + // "github.com/ionos-cloud/ionosctl/v6/pkg/uuidgen" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "github.com/ionos-cloud/ionosctl/v6/internal/core" +) + +func Create() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard gateway", + Verb: "create", + Aliases: []string{"c", "post"}, + ShortDesc: "Create a WireGuard Gateway", + Example: "ionosctl vpn wireguard gateway create " + core.FlagsUsage(constants.FlagName, constants.FlagDatacenterId, constants.FlagLanId, constants.FlagConnectionIP, constants.FlagGatewayIP, constants.FlagInterfaceIP, constants.FlagPrivateKey), + PreCmdRun: func(c *core.PreCommandConfig) error { + baseReq := []string{ + constants.FlagName, + constants.FlagDatacenterId, + constants.FlagLanId, + constants.FlagConnectionIP, + constants.FlagGatewayIP, + constants.FlagInterfaceIP, + } + return core.CheckRequiredFlagsSets(c.Command, c.NS, + // either privateKey or privateKeyPath are required + append(baseReq, constants.FlagPrivateKey), + append(baseReq, constants.FlagPrivateKeyPath), + ) + }, + CmdRun: func(c *core.CommandConfig) error { + input := &vpn.WireguardGateway{} + + if fn := core.GetFlagName(c.NS, constants.FlagName); viper.IsSet(fn) { + input.Name = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagDescription); viper.IsSet(fn) { + input.Description = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIp); viper.IsSet(fn) { + input.GatewayIP = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPrivateKey); viper.IsSet(fn) { + input.PrivateKey = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPrivateKeyPath); viper.IsSet(fn) { + // read the file + keyBytes, err := os.ReadFile(viper.GetString(fn)) + if err != nil { + return fmt.Errorf("failed to read private key file: %w", err) + } + input.PrivateKey = pointer.From(string(keyBytes)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPort); viper.IsSet(fn) { + input.ListenPort = pointer.From(viper.GetInt32(fn)) + } + + input.Connections = pointer.From(make([]vpn.Connection, 1)) + if fn := core.GetFlagName(c.NS, constants.FlagDatacenterId); viper.IsSet(fn) { + (*input.Connections)[0].DatacenterId = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagLanId); viper.IsSet(fn) { + (*input.Connections)[0].LanId = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagGatewayIP); viper.IsSet(fn) { + input.GatewayIP = pointer.From(viper.GetString(fn)) + } + + // Note: VPN Gateway handles IPv4 and IPv6 addresses separately for both InterfaceIP and Connections.IP + // We will use the same flag for both ipv4 and ipv6 for both of them, work out what type (v4 or v6) it is, + // and pass it to the API as the correct field (ipv4 or ipv6) + isIPv4 := func(ip string) bool { + if ipAddr, _, err := net.ParseCIDR(ip); err == nil { + return ipAddr.To4() != nil + } + return net.ParseIP(ip).To4() != nil + } + + if fn := core.GetFlagName(c.NS, constants.FlagInterfaceIP); viper.IsSet(fn) { + ip := viper.GetString(fn) + if isIPv4(ip) { + input.InterfaceIPv4CIDR = pointer.From(ip) + } else { + input.InterfaceIPv6CIDR = pointer.From(ip) + } + } + + if fn := core.GetFlagName(c.NS, constants.FlagConnectionIP); viper.IsSet(fn) { + ip := viper.GetString(fn) + if isIPv4(ip) { + (*input.Connections)[0].Ipv4CIDR = pointer.From(ip) + } else { + (*input.Connections)[0].Ipv6CIDR = pointer.From(ip) + } + } + + createdGateway, _, err := client.Must().VPNClient.WireguardGatewaysApi. + WireguardgatewaysPost(context.Background()). + WireguardGatewayCreate(vpn.WireguardGatewayCreate{Properties: input}).Execute() + if err != nil { + return err + } + + table, err := resource2table.ConvertVPNWireguardGatewayToTable(createdGateway) + if err != nil { + return fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutputPreconverted(createdGateway, table, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagName, constants.FlagNameShort, "", "Name of the WireGuard Gateway", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagDescription, "", "", "Description of the WireGuard Gateway") + cmd.AddStringFlag(constants.FlagGatewayIP, "", "", "The IP of an IPBlock in the same location as the provided datacenter", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagGatewayIP, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + dc, _, _ := client.Must().CloudClient.DataCentersApi. + DatacentersFindById(context.Background(), viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))). + Execute() + + ipblocks, _, err := client.Must().CloudClient.IPBlocksApi. + IpblocksGet(context.Background()). + Filter("location", *dc.Properties.Location). + Execute() + if err != nil || ipblocks.Items == nil || len(*ipblocks.Items) == 0 { + return nil, cobra.ShellCompDirectiveError + } + var ips []string + for _, ipblock := range *ipblocks.Items { + if ipblock.Properties.Ips != nil { + ips = append(ips, *ipblock.Properties.Ips...) + } + } + return ips, cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagInterfaceIP, "", "", "The IPv4 or IPv6 address (with CIDR mask) to be assigned to the WireGuard interface", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagInterfaceIP, completer.GetCidrCompletionFunc(cmd)) + cmd.AddStringFlag(constants.FlagDatacenterId, "", "", "The datacenter to connect your VPN Gateway to", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagDatacenterId, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + loc, _ := c.Flags().GetString(constants.FlagLocation) + return cloudapiv6completer.DatacenterIdsFilterLocation(loc), cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagLanId, "", "", "The numeric LAN ID to connect your VPN Gateway to", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagLanId, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return cloudapiv6completer.LansIds(viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))), + cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagConnectionIP, "", "", "A LAN IPv4 or IPv6 address in CIDR notation that will be assigned to the VPN Gateway", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagConnectionIP, completer.GetCidrCompletionFunc(cmd)) + + cmd.AddStringFlag(constants.FlagPrivateKey, "K", "", fmt.Sprintf("Specify the private key (required or --%s)", constants.FlagPrivateKeyPath)) + cmd.AddStringFlag(constants.FlagPrivateKeyPath, "k", "", fmt.Sprintf("Specify the private key from a file (required or --%s)", constants.FlagPrivateKey)) + + cmd.AddIntFlag(constants.FlagPort, "", 51820, "Port that WireGuard Server will listen on") + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/wireguard/gateway/delete.go b/commands/vpn/wireguard/gateway/delete.go new file mode 100644 index 000000000..ee705bd70 --- /dev/null +++ b/commands/vpn/wireguard/gateway/delete.go @@ -0,0 +1,87 @@ +package gateway + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/pkg/confirm" + "github.com/ionos-cloud/ionosctl/v6/pkg/functional" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func Delete() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard gateway", + Verb: "delete", + Aliases: []string{"del", "d"}, + ShortDesc: "Delete a gateway", + Example: "ionosctl vpn wg gateway delete " + core.FlagsUsage(constants.FlagGatewayID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlagsSets(c.Command, c.NS, []string{constants.ArgAll}, []string{constants.FlagGatewayID}) + }, + CmdRun: func(c *core.CommandConfig) error { + if all := viper.GetBool(core.GetFlagName(c.NS, constants.ArgAll)); all { + return deleteAll(c) + } + + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + + g, _, err := client.Must().VPNClient.WireguardGatewaysApi.WireguardgatewaysFindById(context.Background(), id).Execute() + if err != nil { + return fmt.Errorf("failed getting gateway by id %s: %w", id, err) + } + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete gateway %s at %s", *g.Properties.Name, *g.Properties.GatewayIP), + viper.GetBool(constants.ArgForce)) + if !yes { + return fmt.Errorf(confirm.UserDenied) + } + + _, err = client.Must().VPNClient.WireguardGatewaysApi.WireguardgatewaysDelete(context.Background(), id).Execute() + + return err + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the WireGuard Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.AddBoolFlag(constants.ArgAll, constants.ArgAllShort, false, fmt.Sprintf("Delete all gateways. Required or --%s", constants.FlagGatewayID)) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} + +func deleteAll(c *core.CommandConfig) error { + fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateVerboseOutput("Deleting all gateways!")) + xs, _, err := client.Must().VPNClient.WireguardGatewaysApi.WireguardgatewaysGet(context.Background()).Execute() + if err != nil { + return err + } + + err = functional.ApplyAndAggregateErrors(*xs.GetItems(), func(g vpn.WireguardGatewayRead) error { + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete gateway %s at %s", *g.Properties.Name, *g.Properties.GatewayIP), + viper.GetBool(constants.ArgForce)) + if yes { + _, delErr := client.Must().VPNClient.WireguardGatewaysApi.WireguardgatewaysDelete(context.Background(), *g.Id).Execute() + if delErr != nil { + return fmt.Errorf("failed deleting %s (name: %s): %w", *g.Id, *g.Properties.Name, delErr) + } + } + return nil + }) + + return err +} diff --git a/commands/vpn/wireguard/gateway/gateway.go b/commands/vpn/wireguard/gateway/gateway.go new file mode 100644 index 000000000..967d9bd56 --- /dev/null +++ b/commands/vpn/wireguard/gateway/gateway.go @@ -0,0 +1,38 @@ +package gateway + +import ( + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/spf13/cobra" +) + +var ( + allCols = []string{"ID", "Name", "PublicKey", "Description", "GatewayIP", "InterfaceIPv4", "InterfaceIPv6", "DatacenterId", "LanId", "ConnectionIPv4", "ConnectionIPv6", "InterfaceIP", "ListenPort", "Status"} + // we can safely include both InterfaceIPv4 and InterfaceIPv6 cols because if the respective column empty, it won't be shown + defaultCols = []string{"ID", "Name", "PublicKey", "Description", "GatewayIP", "InterfaceIPv4", "InterfaceIPv6", "DatacenterId", "ListenPort", "Status"} +) + +func Root() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "gateway", + Short: "Manage Wireguard VPN Gateways", + Aliases: []string{"g", "gw"}, + TraverseChildren: true, + }, + } + + cmd.Command.PersistentFlags().StringSlice(constants.ArgCols, nil, tabheaders.ColsMessage(allCols)) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.ArgCols, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return allCols, cobra.ShellCompDirectiveNoFileComp + }) + + cmd.AddCommand(Create()) + cmd.AddCommand(List()) + cmd.AddCommand(Delete()) + cmd.AddCommand(Get()) + cmd.AddCommand(Update()) + + return cmd +} diff --git a/commands/vpn/wireguard/gateway/get.go b/commands/vpn/wireguard/gateway/get.go new file mode 100644 index 000000000..b487e2eff --- /dev/null +++ b/commands/vpn/wireguard/gateway/get.go @@ -0,0 +1,64 @@ +package gateway + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/resource2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/spf13/viper" +) + +func Get() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard gateway", + Verb: "get", + Aliases: []string{"g"}, + ShortDesc: "Find a gateway by ID", + Example: "ionosctl vpn wireguard gateway get " + core.FlagsUsage(constants.FlagGatewayID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, constants.FlagGatewayID) + }, + CmdRun: func(c *core.CommandConfig) error { + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + + g, _, err := client.Must().VPNClient.WireguardGatewaysApi.WireguardgatewaysFindById(context.Background(), id).Execute() + if err != nil { + return fmt.Errorf("failed getting gateway by id %s: %w", id, err) + } + + table, err := resource2table.ConvertVPNWireguardGatewayToTable(g) + if err != nil { + return fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutputPreconverted(g, table, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + + return err + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the WireGuard Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/wireguard/gateway/list.go b/commands/vpn/wireguard/gateway/list.go new file mode 100644 index 000000000..3ee06636b --- /dev/null +++ b/commands/vpn/wireguard/gateway/list.go @@ -0,0 +1,65 @@ +package gateway + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/resource2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func List() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard gateway", + Verb: "list", + Aliases: []string{"l", "ls"}, + ShortDesc: "List WireGuard Gateways", + Example: "ionosctl vpn wireguard gateway list", + PreCmdRun: func(c *core.PreCommandConfig) error { + return nil + }, + CmdRun: func(c *core.CommandConfig) error { + ls, err := completer.Gateways( + func(req vpn.ApiWireguardgatewaysGetRequest) (vpn.ApiWireguardgatewaysGetRequest, error) { + if fn := core.GetFlagName(c.NS, constants.FlagOffset); viper.IsSet(fn) { + req = req.Offset(viper.GetInt32(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagMaxResults); viper.IsSet(fn) { + req = req.Limit(viper.GetInt32(fn)) + } + return req, nil + }, + ) + if err != nil { + return fmt.Errorf("failed listing gateways: %w", err) + } + + table, err := resource2table.ConvertVPNWireguardGatewaysToTable(ls) + if err != nil { + return fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutputPreconverted(ls, table, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + }) + + cmd.AddInt32Flag(constants.FlagMaxResults, constants.FlagMaxResultsShort, 0, constants.DescMaxResults) + cmd.AddInt32Flag(constants.FlagOffset, "", 0, "Skip a certain number of results") + + return cmd +} diff --git a/commands/vpn/wireguard/gateway/update.go b/commands/vpn/wireguard/gateway/update.go new file mode 100644 index 000000000..02aae4c04 --- /dev/null +++ b/commands/vpn/wireguard/gateway/update.go @@ -0,0 +1,201 @@ +package gateway + +import ( + "context" + "fmt" + "net" + "os" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + cloudapiv6completer "github.com/ionos-cloud/ionosctl/v6/commands/cloudapi-v6/completer" + dbaascompleter "github.com/ionos-cloud/ionosctl/v6/commands/dbaas/completer" + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/resource2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/ionos-cloud/ionosctl/v6/pkg/pointer" + + // "github.com/ionos-cloud/ionosctl/v6/pkg/uuidgen" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "github.com/ionos-cloud/ionosctl/v6/internal/core" +) + +func Update() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard gateway", + Verb: "update", + Aliases: []string{"u", "put", "patch"}, + ShortDesc: "Update a WireGuard Gateway", + LongDesc: "Update a WireGuard Gateway. Note: The private key MUST be provided again (or changed) on updates.", + Example: "ionosctl vpn wireguard gateway update " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagName, constants.FlagDatacenterId, constants.FlagLanId, constants.FlagConnectionIP, constants.FlagGatewayIP, constants.FlagInterfaceIP), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlagsSets(c.Command, c.NS, + []string{constants.FlagGatewayID, constants.FlagPrivateKey}, + []string{constants.FlagGatewayID, constants.FlagPrivateKeyPath}, + ) + }, + CmdRun: func(c *core.CommandConfig) error { + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + + g, _, err := client.Must().VPNClient.WireguardGatewaysApi.WireguardgatewaysFindById(context.Background(), id).Execute() + if err != nil { + return err + } + + if fn := core.GetFlagName(c.NS, constants.FlagName); viper.IsSet(fn) { + g.Properties.Name = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagDescription); viper.IsSet(fn) { + g.Properties.Description = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagIp); viper.IsSet(fn) { + g.Properties.GatewayIP = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPrivateKey); viper.IsSet(fn) { + g.Properties.PrivateKey = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPrivateKeyPath); viper.IsSet(fn) { + // read the file + keyBytes, err := os.ReadFile(viper.GetString(fn)) + if err != nil { + return fmt.Errorf("failed to read private key file: %w", err) + } + g.Properties.PrivateKey = pointer.From(string(keyBytes)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPort); viper.IsSet(fn) { + g.Properties.ListenPort = pointer.From(viper.GetInt32(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagDatacenterId); viper.IsSet(fn) { + if g.Properties.Connections == nil { + g.Properties.Connections = pointer.From(make([]vpn.Connection, 1)) + } + (*g.Properties.Connections)[0].DatacenterId = pointer.From(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagLanId); viper.IsSet(fn) { + if g.Properties.Connections == nil { + g.Properties.Connections = pointer.From(make([]vpn.Connection, 1)) + } + (*g.Properties.Connections)[0].LanId = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagGatewayIP); viper.IsSet(fn) { + g.Properties.GatewayIP = pointer.From(viper.GetString(fn)) + } + + // Note: VPN Gateway handles IPv4 and IPv6 addresses separately for both InterfaceIP and Connections.IP + // We will use the same flag for both ipv4 and ipv6 for both of them, work out what type (v4 or v6) it is, + // and pass it to the API as the correct field (ipv4 or ipv6) + isIPv4 := func(ip string) bool { + if ipAddr, _, err := net.ParseCIDR(ip); err == nil { + return ipAddr.To4() != nil + } + return net.ParseIP(ip).To4() != nil + } + + if fn := core.GetFlagName(c.NS, constants.FlagInterfaceIP); viper.IsSet(fn) { + ip := viper.GetString(fn) + if isIPv4(ip) { + g.Properties.InterfaceIPv4CIDR = pointer.From(ip) + } else { + g.Properties.InterfaceIPv6CIDR = pointer.From(ip) + } + } + + if fn := core.GetFlagName(c.NS, constants.FlagConnectionIP); viper.IsSet(fn) { + if g.Properties.Connections == nil { + g.Properties.Connections = pointer.From(make([]vpn.Connection, 1)) + } + ip := viper.GetString(fn) + if isIPv4(ip) { + (*g.Properties.Connections)[0].Ipv4CIDR = pointer.From(ip) + } else { + (*g.Properties.Connections)[0].Ipv6CIDR = pointer.From(ip) + } + } + + createdGateway, _, err := client.Must().VPNClient.WireguardGatewaysApi. + WireguardgatewaysPut(context.Background(), id). + WireguardGatewayEnsure(vpn.WireguardGatewayEnsure{Id: &id, Properties: g.Properties}).Execute() + if err != nil { + return fmt.Errorf("failed updating gateway: %w", err) + } + + table, err := resource2table.ConvertVPNWireguardGatewayToTable(createdGateway) + if err != nil { + return fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutputPreconverted(createdGateway, table, + tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the WireGuard Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.AddStringFlag(constants.FlagName, constants.FlagNameShort, "", "Name of the WireGuard Gateway", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagDescription, "", "", "Description of the WireGuard Gateway") + cmd.AddStringFlag(constants.FlagGatewayIP, "", "", "The IP of an IPBlock in the same location as the provided datacenter", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagGatewayIP, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + dc, _, _ := client.Must().CloudClient.DataCentersApi. + DatacentersFindById(context.Background(), viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))). + Execute() + + ipblocks, _, err := client.Must().CloudClient.IPBlocksApi. + IpblocksGet(context.Background()). + Filter("location", *dc.Properties.Location). + Execute() + if err != nil || ipblocks.Items == nil || len(*ipblocks.Items) == 0 { + return nil, cobra.ShellCompDirectiveError + } + var ips []string + for _, ipblock := range *ipblocks.Items { + if ipblock.Properties.Ips != nil { + ips = append(ips, *ipblock.Properties.Ips...) + } + } + return ips, cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagInterfaceIP, "", "", "The IPv4 or IPv6 address (with CIDR mask) to be assigned to the WireGuard interface", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagInterfaceIP, dbaascompleter.GetCidrCompletionFunc(cmd)) + cmd.AddStringFlag(constants.FlagDatacenterId, "", "", "The datacenter to connect your VPN Gateway to", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagDatacenterId, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return cloudapiv6completer.DataCentersIds(), cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagLanId, "", "", "The numeric LAN ID to connect your VPN Gateway to", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagLanId, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return cloudapiv6completer.LansIds(viper.GetString(core.GetFlagName(cmd.NS, constants.FlagDatacenterId))), + cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagConnectionIP, "", "", "A LAN IPv4 or IPv6 address in CIDR notation that will be assigned to the VPN Gateway", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagConnectionIP, dbaascompleter.GetCidrCompletionFunc(cmd)) + + cmd.AddStringFlag(constants.FlagPrivateKey, "K", "", fmt.Sprintf("Specify the private key (required or --%s)", constants.FlagPrivateKeyPath)) + cmd.AddStringFlag(constants.FlagPrivateKeyPath, "k", "", fmt.Sprintf("Specify the private key from a file (required or --%s)", constants.FlagPrivateKey)) + + cmd.AddIntFlag(constants.FlagPort, "", 51820, "Port that WireGuard Server will listen on") + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/wireguard/peer/create.go b/commands/vpn/wireguard/peer/create.go new file mode 100644 index 000000000..e610fcabf --- /dev/null +++ b/commands/vpn/wireguard/peer/create.go @@ -0,0 +1,102 @@ +package peer + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/ionos-cloud/ionosctl/v6/pkg/pointer" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +func Create() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard peer", + Verb: "create", + Aliases: []string{"c", "post"}, + ShortDesc: "Create a WireGuard Peer", + LongDesc: "Create WireGuard Peers. There is a limit to the total number of peers. Please refer to product documentation", + Example: "ionosctl vpn wireguard peer create " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagName, constants.FlagIps, constants.FlagPublicKey, constants.FlagHost), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, + constants.FlagGatewayID, constants.FlagName, constants.FlagIps, constants.FlagPublicKey, constants.FlagHost, + ) + }, + CmdRun: func(c *core.CommandConfig) error { + input := &vpn.WireguardPeer{} + + if fn := core.GetFlagName(c.NS, constants.FlagName); viper.IsSet(fn) { + input.Name = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagDescription); viper.IsSet(fn) { + input.Description = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagIps); viper.IsSet(fn) { + input.AllowedIPs = pointer.From(viper.GetStringSlice(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPublicKey); viper.IsSet(fn) { + input.PublicKey = pointer.From(viper.GetString(fn)) + } + + input.Endpoint = &vpn.WireguardEndpoint{} + if fn := core.GetFlagName(c.NS, constants.FlagHost); viper.IsSet(fn) { + input.Endpoint.Host = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPort); viper.IsSet(fn) { + input.Endpoint.Port = pointer.From(viper.GetInt32(fn)) + } + + peer, _, err := client.Must().VPNClient.WireguardPeersApi. + WireguardgatewaysPeersPost(context.Background(), viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID))). + WireguardPeerCreate(vpn.WireguardPeerCreate{Properties: input}).Execute() + if err != nil { + return err + } + + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + + out, err := jsontabwriter.GenerateOutput("", jsonpaths.VPNWireguardPeer, peer, tabheaders.GetHeadersAllDefault(allCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + + return nil + }, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the WireGuard Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + + cmd.AddStringFlag(constants.FlagName, "", "", "Name of the WireGuard Peer", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagDescription, "", "", "Description of the WireGuard Peer") + cmd.AddStringSliceFlag(constants.FlagIps, "", []string{}, "Comma separated subnets of CIDRs that are allowed to connect to the WireGuard Gateway. Specify \"a.b.c.d/32\" for an individual IP address. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses", core.RequiredFlagOption()) + cmd.Command.RegisterFlagCompletionFunc(constants.FlagIps, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return []string{"::/0"}, cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagPublicKey, "", "", "Public key of the connecting peer", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagHost, "", "", "Hostname or IPV4 address that the WireGuard Server will connect to", core.RequiredFlagOption()) + cmd.AddIntFlag(constants.FlagPort, "", 51820, "Port that the WireGuard Server will connect to") + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/wireguard/peer/delete.go b/commands/vpn/wireguard/peer/delete.go new file mode 100644 index 000000000..b10752e71 --- /dev/null +++ b/commands/vpn/wireguard/peer/delete.go @@ -0,0 +1,98 @@ +package peer + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/pkg/confirm" + "github.com/ionos-cloud/ionosctl/v6/pkg/functional" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func Delete() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard peer", + Verb: "delete", + Aliases: []string{"d", "del", "rm"}, + ShortDesc: "Remove a WireGuard Peer", + Example: "ionosctl vpn wireguard peer delete " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagPeerID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlagsSets(c.Command, c.NS, + []string{constants.FlagGatewayID, constants.FlagPeerID}, + []string{constants.FlagGatewayID, constants.ArgAll}, + ) + }, + CmdRun: func(c *core.CommandConfig) error { + if all := viper.GetBool(core.GetFlagName(c.NS, constants.ArgAll)); all { + return deleteAll(c) + } + + gatewayId := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagPeerID)) + p, _, err := client.Must().VPNClient.WireguardPeersApi.WireguardgatewaysPeersFindById(context.Background(), gatewayId, id).Execute() + if err != nil { + return fmt.Errorf("failed getting peer by id %s: %w", id, err) + } + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete peer %s"+ + " (host: '%s')", *p.Properties.Name, *p.Properties.Endpoint.Host), + viper.GetBool(constants.ArgForce)) + if !yes { + return fmt.Errorf(confirm.UserDenied) + } + + _, err = client.Must().VPNClient.WireguardPeersApi.WireguardgatewaysPeersDelete(context.Background(), gatewayId, id).Execute() + + return nil + }, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, "", "", "The ID of the WireGuard Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + cmd.AddStringFlag(constants.FlagPeerID, constants.FlagIdShort, "", "The ID of the WireGuard Peer you want to delete", + core.RequiredFlagOption(), + core.WithCompletion(func() []string { + return completer.PeerIDs(viper.GetString(core.GetFlagName(cmd.NS, constants.FlagGatewayID))) + }, constants.VPNApiRegionalURL), + ) + + cmd.AddBoolFlag(constants.ArgAll, constants.ArgAllShort, false, fmt.Sprintf("Delete all peers. Required or --%s", constants.FlagPeerID)) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} + +func deleteAll(c *core.CommandConfig) error { + gatewayId := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateVerboseOutput("Deleting all peers from gateway %s!", gatewayId)) + + xs, _, err := client.Must().VPNClient.WireguardPeersApi.WireguardgatewaysPeersGet(context.Background(), gatewayId).Execute() + if err != nil { + return err + } + + err = functional.ApplyAndAggregateErrors(*xs.GetItems(), func(p vpn.WireguardPeerRead) error { + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete peer %s at %s", *p.Properties.Name, *p.Properties.Endpoint.Host), + viper.GetBool(constants.ArgForce)) + if yes { + _, delErr := client.Must().VPNClient.WireguardGatewaysApi.WireguardgatewaysDelete(context.Background(), *p.Id).Execute() + if delErr != nil { + return fmt.Errorf("failed deleting %s (name: %s): %w", *p.Id, *p.Properties.Name, delErr) + } + } + return nil + }) + + return err +} diff --git a/commands/vpn/wireguard/peer/get.go b/commands/vpn/wireguard/peer/get.go new file mode 100644 index 000000000..767884892 --- /dev/null +++ b/commands/vpn/wireguard/peer/get.go @@ -0,0 +1,67 @@ +package peer + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/spf13/viper" +) + +func Get() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard peer", + Verb: "get", + Aliases: []string{"g"}, + ShortDesc: "Find a peer by ID", + Example: "ionosctl vpn wg peer get " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagPeerID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, constants.FlagGatewayID, constants.FlagPeerID) + }, + CmdRun: func(c *core.CommandConfig) error { + gatewayId := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagPeerID)) + + p, _, err := client.Must().VPNClient.WireguardPeersApi.WireguardgatewaysPeersFindById(context.Background(), gatewayId, id).Execute() + if err != nil { + return fmt.Errorf("failed getting peer by id %s: %w", id, err) + } + + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutput("", jsonpaths.VPNWireguardPeer, p, + tabheaders.GetHeadersAllDefault(allCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + + return err + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, "", "", "The ID of the WireGuard Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + cmd.AddStringFlag(constants.FlagPeerID, constants.FlagIdShort, "", "The ID of the WireGuard Peer", + core.RequiredFlagOption(), + core.WithCompletion(func() []string { + return completer.PeerIDs(viper.GetString(core.GetFlagName(cmd.NS, constants.FlagGatewayID))) + }, constants.VPNApiRegionalURL), + ) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/wireguard/peer/list.go b/commands/vpn/wireguard/peer/list.go new file mode 100644 index 000000000..65209e7b8 --- /dev/null +++ b/commands/vpn/wireguard/peer/list.go @@ -0,0 +1,66 @@ +package peer + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/viper" +) + +func List() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard peer", + Verb: "list", + Aliases: []string{"l", "ls"}, + ShortDesc: "List WireGuard Peers", + Example: "ionosctl vpn wireguard peer list " + core.FlagsUsage(constants.FlagGatewayID), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, constants.FlagGatewayID) + }, + CmdRun: func(c *core.CommandConfig) error { + ls, err := completer.Peers( + viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)), + func(req vpn.ApiWireguardgatewaysPeersGetRequest) (vpn.ApiWireguardgatewaysPeersGetRequest, error) { + if fn := core.GetFlagName(c.NS, constants.FlagOffset); viper.IsSet(fn) { + req = req.Offset(viper.GetInt32(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagMaxResults); viper.IsSet(fn) { + req = req.Limit(viper.GetInt32(fn)) + } + return req, nil + }, + ) + if err != nil { + return fmt.Errorf("failed listing peers: %w", err) + } + + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutput("items", jsonpaths.VPNWireguardPeer, ls, + tabheaders.GetHeadersAllDefault(allCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, constants.FlagIdShort, "", "The ID of the Wireguard Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + cmd.AddInt32Flag(constants.FlagMaxResults, constants.FlagMaxResultsShort, 0, constants.DescMaxResults) + cmd.AddInt32Flag(constants.FlagOffset, "", 0, "Skip a certain number of results") + + return cmd +} diff --git a/commands/vpn/wireguard/peer/peer.go b/commands/vpn/wireguard/peer/peer.go new file mode 100644 index 000000000..98274cebe --- /dev/null +++ b/commands/vpn/wireguard/peer/peer.go @@ -0,0 +1,43 @@ +package peer + +import ( + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/spf13/cobra" +) + +/* +A WireGuard peer is any device (client, server, or another gateway) that participates in a WireGuard VPN. Peers are identified by public/private key pairs. +WireGuard does not need complex negotiation (like IPsec IKE phases). Once two peers know each other’s public keys and IP addresses, they can connect instantly. +WireGuard is stateless: no persistent state is stored between connections, and packets are exchanged only when needed. +There is no session or tunnel establishment process like in IPsec. Instead, WireGuard peers exchange packets as needed without keeping an active session. +*/ + +var ( + allCols = []string{"ID", "Name", "Description", "Host", "Port", "WhitelistIPs", "PublicKey", "Status"} +) + +func Root() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "peer", + Short: "Manage Wireguard VPN Peers", + Aliases: []string{"p"}, + TraverseChildren: true, + }, + } + + cmd.Command.PersistentFlags().StringSlice(constants.ArgCols, nil, tabheaders.ColsMessage(allCols)) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.ArgCols, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return allCols, cobra.ShellCompDirectiveNoFileComp + }) + + cmd.AddCommand(Create()) + cmd.AddCommand(List()) + cmd.AddCommand(Get()) + cmd.AddCommand(Delete()) + cmd.AddCommand(Update()) + + return cmd +} diff --git a/commands/vpn/wireguard/peer/update.go b/commands/vpn/wireguard/peer/update.go new file mode 100644 index 000000000..7bd118ae6 --- /dev/null +++ b/commands/vpn/wireguard/peer/update.go @@ -0,0 +1,112 @@ +package peer + +import ( + "context" + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/completer" + + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/internal/constants" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + "github.com/ionos-cloud/ionosctl/v6/pkg/pointer" + vpn "github.com/ionos-cloud/sdk-go-vpn" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +func Update() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "vpn", + Resource: "wireguard peer", + Verb: "update", + Aliases: []string{"u", "patch", "put"}, + ShortDesc: "Update a WireGuard Peer", + Example: "ionosctl vpn wireguard peer update " + core.FlagsUsage(constants.FlagGatewayID, constants.FlagPeerID, constants.FlagName, constants.FlagDescription, constants.FlagIps, constants.FlagPublicKey, constants.FlagHost, constants.FlagPort), + PreCmdRun: func(c *core.PreCommandConfig) error { + return core.CheckRequiredFlags(c.Command, c.NS, constants.FlagGatewayID, constants.FlagPeerID) + }, + CmdRun: func(c *core.CommandConfig) error { + gatewayId := viper.GetString(core.GetFlagName(c.NS, constants.FlagGatewayID)) + id := viper.GetString(core.GetFlagName(c.NS, constants.FlagPeerID)) + p, _, err := client.Must().VPNClient.WireguardPeersApi.WireguardgatewaysPeersFindById(context.Background(), gatewayId, id).Execute() + + if fn := core.GetFlagName(c.NS, constants.FlagName); viper.IsSet(fn) { + p.Properties.Name = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagDescription); viper.IsSet(fn) { + p.Properties.Description = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagIps); viper.IsSet(fn) { + p.Properties.AllowedIPs = pointer.From(viper.GetStringSlice(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPublicKey); viper.IsSet(fn) { + p.Properties.PublicKey = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagHost); viper.IsSet(fn) { + if p.Properties.Endpoint == nil { + p.Properties.Endpoint = &vpn.WireguardEndpoint{} + } + p.Properties.Endpoint.Host = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagPort); viper.IsSet(fn) { + if p.Properties.Endpoint == nil { + p.Properties.Endpoint = &vpn.WireguardEndpoint{} + } + p.Properties.Endpoint.Port = pointer.From(viper.GetInt32(fn)) + } + + peer, _, err := client.Must().VPNClient.WireguardPeersApi. + WireguardgatewaysPeersPut(context.Background(), gatewayId, id). + WireguardPeerEnsure(vpn.WireguardPeerEnsure{Id: &id, Properties: p.Properties}).Execute() + if err != nil { + return err + } + + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + + out, err := jsontabwriter.GenerateOutput("", jsonpaths.VPNWireguardPeer, peer, tabheaders.GetHeadersAllDefault(allCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + + return nil + }, + }) + + cmd.AddStringFlag(constants.FlagGatewayID, "", "", "The ID of the WireGuard Gateway", + core.RequiredFlagOption(), + core.WithCompletion(completer.GatewayIDs, constants.VPNApiRegionalURL), + ) + cmd.AddStringFlag(constants.FlagPeerID, constants.FlagIdShort, "", "The ID of the WireGuard Peer", + core.RequiredFlagOption(), + core.WithCompletion(func() []string { + return completer.PeerIDs(viper.GetString(core.GetFlagName(cmd.NS, constants.FlagGatewayID))) + }, constants.VPNApiRegionalURL), + ) + + cmd.AddStringFlag(constants.FlagName, "", "", "Name of the WireGuard Peer", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagDescription, "", "", "Description of the WireGuard Peer") + cmd.AddStringSliceFlag(constants.FlagIps, "", []string{}, "Comma separated subnets of CIDRs that are allowed to connect to the WireGuard Gateway. Specify \"a.b.c.d/32\" for an individual IP address. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses", core.RequiredFlagOption()) + cmd.Command.RegisterFlagCompletionFunc(constants.FlagIps, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return []string{"::/0"}, cobra.ShellCompDirectiveNoFileComp + }) + cmd.AddStringFlag(constants.FlagPublicKey, "", "", "Public key of the connecting peer", core.RequiredFlagOption()) + cmd.AddStringFlag(constants.FlagHost, "", "", "Hostname or IPV4 address that the WireGuard Server will connect to", core.RequiredFlagOption()) + cmd.AddIntFlag(constants.FlagPort, "", 51820, "Port that the WireGuard Server will connect to") + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/vpn/wireguard/wireguard.go b/commands/vpn/wireguard/wireguard.go new file mode 100644 index 000000000..19f491951 --- /dev/null +++ b/commands/vpn/wireguard/wireguard.go @@ -0,0 +1,23 @@ +package wireguard + +import ( + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/gateway" + "github.com/ionos-cloud/ionosctl/v6/commands/vpn/wireguard/peer" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/spf13/cobra" +) + +func Root() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "wireguard", + Short: "Manage Wireguard VPN Resources", + Aliases: []string{"wg"}, + TraverseChildren: true, + }, + } + cmd.AddCommand(gateway.Root()) + cmd.AddCommand(peer.Root()) + + return cmd +} diff --git a/docs/subcommands/VPN Gateway/ipsec/gateway/create.md b/docs/subcommands/VPN Gateway/ipsec/gateway/create.md new file mode 100644 index 000000000..5f8cbbe13 --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/gateway/create.md @@ -0,0 +1,59 @@ +--- +description: "Create a IPSec Gateway" +--- + +# VpnIpsecGatewayCreate + +## Usage + +```text +ionosctl vpn ipsec gateway create [flags] +``` + +## Aliases + +For `gateway` command: + +```text +[g gw] +``` + +For `create` command: + +```text +[c post] +``` + +## Description + +Create a IPSec Gateway + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description GatewayIP DatacenterId LanId ConnectionIPv4 ConnectionIPv6 Version Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --connection-ip string A LAN IPv4 or IPv6 address in CIDR notation that will be assigned to the VPN Gateway (required) + --datacenter-id string The datacenter to connect your VPN Gateway to (required) + --description string Description of the IPSec Gateway + -f, --force Force command to execute without user input + --gateway-ip string The IP of an IPBlock in the same location as the provided datacenter (required) + -h, --help Print usage + --lan-id string The numeric LAN ID to connect your VPN Gateway to (required) + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + -n, --name string Name of the IPSec Gateway (required) + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command + --version string The IKE version that is permitted for the VPN tunnels (default "IKEv2") +``` + +## Examples + +```text +ionosctl vpn ipsec gateway create --name NAME --datacenter-id DATACENTER_ID --lan-id LAN_ID --connection-ip CONNECTION_IP --gateway-ip GATEWAY_IP --interface-ip INTERFACE_IP +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/gateway/delete.md b/docs/subcommands/VPN Gateway/ipsec/gateway/delete.md new file mode 100644 index 000000000..e1d87bd5a --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/gateway/delete.md @@ -0,0 +1,54 @@ +--- +description: "Delete a gateway" +--- + +# VpnIpsecGatewayDelete + +## Usage + +```text +ionosctl vpn ipsec gateway delete [flags] +``` + +## Aliases + +For `gateway` command: + +```text +[g gw] +``` + +For `delete` command: + +```text +[del d] +``` + +## Description + +Delete a gateway + +## Options + +```text + -a, --all Delete all gateways. Required or --gateway-id + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description GatewayIP DatacenterId LanId ConnectionIPv4 ConnectionIPv6 Version Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the IPSec Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn ipsec gateway --gateway-id GATEWAY_ID +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/gateway/get.md b/docs/subcommands/VPN Gateway/ipsec/gateway/get.md new file mode 100644 index 000000000..b004d6a6e --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/gateway/get.md @@ -0,0 +1,53 @@ +--- +description: "Find a gateway by ID" +--- + +# VpnIpsecGatewayGet + +## Usage + +```text +ionosctl vpn ipsec gateway get [flags] +``` + +## Aliases + +For `gateway` command: + +```text +[g gw] +``` + +For `get` command: + +```text +[g] +``` + +## Description + +Find a gateway by ID + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description GatewayIP DatacenterId LanId ConnectionIPv4 ConnectionIPv6 Version Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the IPSec Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn ipsec gateway get --gateway-id GATEWAY_ID +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/gateway/list.md b/docs/subcommands/VPN Gateway/ipsec/gateway/list.md new file mode 100644 index 000000000..ed84262c0 --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/gateway/list.md @@ -0,0 +1,54 @@ +--- +description: "List IPSec Gateways" +--- + +# VpnIpsecGatewayList + +## Usage + +```text +ionosctl vpn ipsec gateway list [flags] +``` + +## Aliases + +For `gateway` command: + +```text +[g gw] +``` + +For `list` command: + +```text +[l ls] +``` + +## Description + +List IPSec Gateways + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description GatewayIP DatacenterId LanId ConnectionIPv4 ConnectionIPv6 Version Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + -M, --max-results int32 The maximum number of elements to return + --no-headers Don't print table headers when table output is used + --offset int32 Skip a certain number of results + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn ipsec gateway list +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/gateway/update.md b/docs/subcommands/VPN Gateway/ipsec/gateway/update.md new file mode 100644 index 000000000..39b429137 --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/gateway/update.md @@ -0,0 +1,60 @@ +--- +description: "Update a IPSec Gateway" +--- + +# VpnIpsecGatewayUpdate + +## Usage + +```text +ionosctl vpn ipsec gateway update [flags] +``` + +## Aliases + +For `gateway` command: + +```text +[g gw] +``` + +For `update` command: + +```text +[u put patch] +``` + +## Description + +Update a IPSec Gateway + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description GatewayIP DatacenterId LanId ConnectionIPv4 ConnectionIPv6 Version Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --connection-ip string A LAN IPv4 or IPv6 address in CIDR notation that will be assigned to the VPN Gateway (required) + --datacenter-id string The datacenter to connect your VPN Gateway to (required) + --description string Description of the IPSec Gateway + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the IPSec Gateway (required) + --gateway-ip string The IP of an IPBlock in the same location as the provided datacenter (required) + -h, --help Print usage + --lan-id string The numeric LAN ID to connect your VPN Gateway to (required) + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + -n, --name string Name of the IPSec Gateway (required) + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command + --version string The IKE version that is permitted for the VPN tunnels (default "IKEv2") +``` + +## Examples + +```text +ionosctl vpn ipsec gateway update --gateway-id GATEWAY_ID --name NAME --datacenter-id DATACENTER_ID --lan-id LAN_ID --connection-ip CONNECTION_IP --gateway-ip GATEWAY_IP --interface-ip INTERFACE_IP +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/tunnel/create.md b/docs/subcommands/VPN Gateway/ipsec/tunnel/create.md new file mode 100644 index 000000000..4e51c847d --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/tunnel/create.md @@ -0,0 +1,72 @@ +--- +description: "Create a IPSec tunnel" +--- + +# VpnIpsecTunnelCreate + +## Usage + +```text +ionosctl vpn ipsec tunnel create [flags] +``` + +## Aliases + +For `tunnel` command: + +```text +[p] +``` + +For `create` command: + +```text +[c post] +``` + +## Description + +Create IPSec tunnels + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --auth-method string The authentication method for the IPSec tunnel. Valid values are PSK or RSA (required) + --cloud-network-cidrs strings The network CIDRs on the "Left" side that are allowed to connect to the IPSec tunnel, i.e the CIDRs within your IONOS Cloud LAN. Specify "0.0.0.0/0" or "::/0" for all addresses. + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description RemoteHost AuthMethod PSKKey IKEDiffieHellmanGroup IKEEncryptionAlgorithm IKEIntegrityAlgorithm IKELifetime ESPDiffieHellmanGroup ESPEncryptionAlgorithm ESPIntegrityAlgorithm ESPLifetime CloudNetworkCIDRs PeerNetworkCIDRs Status StatusMessage] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --description string Description of the IPSec Tunnel + --esp-diffie-hellman-group string The Diffie-Hellman Group to use for IPSec Encryption.. Can be one of: 15-MODP3072, 16-MODP4096, 19-ECP256, 20-ECP384, 21-ECP521, 28-ECP256BP, 29-ECP384BP, 30-ECP512BP + --esp-encryption-algorithm string The encryption algorithm to use for IPSec Encryption.. Can be one of: AES128-CTR, AES256-CTR, AES128-GCM-16, AES256-GCM-16, AES128-GCM-12, AES256-GCM-12, AES128-CCM-12, AES256-CCM-12, AES128, AES256 + --esp-integrity-algorithm string The integrity algorithm to use for IPSec Encryption.. Can be one of: SHA256, SHA384, SHA512, AES-XCBC + --esp-lifetime int32 The phase lifetime in seconds + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the IPSec Gateway (required) + -h, --help Print usage + --host string The remote peer host fully qualified domain name or IPV4 IP to connect to. * __Note__: This should be the public IP of the remote peer. * Tunnels only support IPV4 or hostname (fully qualified DNS name). (required) + --ike-diffie-hellman-group string The Diffie-Hellman Group to use for IPSec Encryption.. Can be one of: 15-MODP3072, 16-MODP4096, 19-ECP256, 20-ECP384, 21-ECP521, 28-ECP256BP, 29-ECP384BP, 30-ECP512BP + --ike-encryption-algorithm string The encryption algorithm to use for IPSec Encryption.. Can be one of: AES128, AES256 + --ike-integrity-algorithm string The integrity algorithm to use for IPSec Encryption.. Can be one of: SHA256, SHA384, SHA512, AES-XCBC + --ike-lifetime int32 The phase lifetime in seconds + --json-properties string Path to a JSON file containing the desired properties. Overrides any other properties set. + --json-properties-example If set, prints a complete JSON which could be used for --json-properties and exits. Hint: Pipe me to a .json file + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --name string Name of the IPSec Tunnel (required) + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + --peer-network-cidrs strings The network CIDRs on the "Right" side that are allowed to connect to the IPSec tunnel. Specify "0.0.0.0/0" or "::/0" for all addresses. + --psk-key string The pre-shared key for the IPSec tunnel (required) + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn ipsec tunnel create --gateway-id GATEWAY_ID --name NAME --host HOST --auth-method AUTH_METHOD --psk-key PSK_KEY --ike-diffie-hellman-group IKE_DIFFIE_HELLMAN_GROUP --ike-encryption-algorithm IKE_ENCRYPTION_ALGORITHM --ike-integrity-algorithm IKE_INTEGRITY_ALGORITHM --ike-lifetime IKE_LIFETIME --esp-diffie-hellman-group ESP_DIFFIE_HELLMAN_GROUP --esp-encryption-algorithm ESP_ENCRYPTION_ALGORITHM --esp-integrity-algorithm ESP_INTEGRITY_ALGORITHM --esp-lifetime ESP_LIFETIME --cloud-network-cidrs CLOUD_NETWORK_CIDRS --peer-network-cidrs PEER_NETWORK_CIDRS +ionosctl vpn ipsec tunnel create --json-properties JSON_PROPERTIES +ionosctl vpn ipsec tunnel create --json-properties JSON_PROPERTIES json-properties-example +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/tunnel/delete.md b/docs/subcommands/VPN Gateway/ipsec/tunnel/delete.md new file mode 100644 index 000000000..f16bd2913 --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/tunnel/delete.md @@ -0,0 +1,55 @@ +--- +description: "Remove a IPSec Tunnel" +--- + +# VpnIpsecTunnelDelete + +## Usage + +```text +ionosctl vpn ipsec tunnel delete [flags] +``` + +## Aliases + +For `tunnel` command: + +```text +[p] +``` + +For `delete` command: + +```text +[d del rm] +``` + +## Description + +Remove a IPSec Tunnel + +## Options + +```text + -a, --all Delete all tunnels. Required or --tunnel-id + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description RemoteHost AuthMethod PSKKey IKEDiffieHellmanGroup IKEEncryptionAlgorithm IKEIntegrityAlgorithm IKELifetime ESPDiffieHellmanGroup ESPEncryptionAlgorithm ESPIntegrityAlgorithm ESPLifetime CloudNetworkCIDRs PeerNetworkCIDRs Status StatusMessage] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + --gateway-id string The ID of the IPSec Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -i, --tunnel-id string The ID of the IPSec Tunnel you want to delete (required) + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn ipsec tunnel delete --gateway-id GATEWAY_ID --tunnel-id TUNNEL_ID +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/tunnel/get.md b/docs/subcommands/VPN Gateway/ipsec/tunnel/get.md new file mode 100644 index 000000000..5aeeb80b7 --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/tunnel/get.md @@ -0,0 +1,54 @@ +--- +description: "Find a tunnel by ID" +--- + +# VpnIpsecTunnelGet + +## Usage + +```text +ionosctl vpn ipsec tunnel get [flags] +``` + +## Aliases + +For `tunnel` command: + +```text +[p] +``` + +For `get` command: + +```text +[g] +``` + +## Description + +Find a tunnel by ID + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description RemoteHost AuthMethod PSKKey IKEDiffieHellmanGroup IKEEncryptionAlgorithm IKEIntegrityAlgorithm IKELifetime ESPDiffieHellmanGroup ESPEncryptionAlgorithm ESPIntegrityAlgorithm ESPLifetime CloudNetworkCIDRs PeerNetworkCIDRs Status StatusMessage] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + --gateway-id string The ID of the IPSec Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -i, --tunnel-id string The ID of the IPSec Tunnel (required) + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn ipsec tunnel get --gateway-id GATEWAY_ID --tunnel-id TUNNEL_ID +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/tunnel/list.md b/docs/subcommands/VPN Gateway/ipsec/tunnel/list.md new file mode 100644 index 000000000..7fb6b0c0c --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/tunnel/list.md @@ -0,0 +1,55 @@ +--- +description: "List IPSec Tunnels" +--- + +# VpnIpsecTunnelList + +## Usage + +```text +ionosctl vpn ipsec tunnel list [flags] +``` + +## Aliases + +For `tunnel` command: + +```text +[p] +``` + +For `list` command: + +```text +[l ls] +``` + +## Description + +List IPSec Tunnels + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description RemoteHost AuthMethod PSKKey IKEDiffieHellmanGroup IKEEncryptionAlgorithm IKEIntegrityAlgorithm IKELifetime ESPDiffieHellmanGroup ESPEncryptionAlgorithm ESPIntegrityAlgorithm ESPLifetime CloudNetworkCIDRs PeerNetworkCIDRs Status StatusMessage] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the IPSec Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + -M, --max-results int32 The maximum number of elements to return + --no-headers Don't print table headers when table output is used + --offset int32 Skip a certain number of results + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn ipsec tunnel list --gateway-id GATEWAY_ID +``` + diff --git a/docs/subcommands/VPN Gateway/ipsec/tunnel/update.md b/docs/subcommands/VPN Gateway/ipsec/tunnel/update.md new file mode 100644 index 000000000..0119ee284 --- /dev/null +++ b/docs/subcommands/VPN Gateway/ipsec/tunnel/update.md @@ -0,0 +1,71 @@ +--- +description: "Update a IPSec Tunnel" +--- + +# VpnIpsecTunnelUpdate + +## Usage + +```text +ionosctl vpn ipsec tunnel update [flags] +``` + +## Aliases + +For `tunnel` command: + +```text +[p] +``` + +For `update` command: + +```text +[u patch put] +``` + +## Description + +Update a IPSec Tunnel + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --auth-method string The authentication method for the IPSec tunnel. Valid values are PSK or RSA (required) + --cloud-network-cidrs strings The network CIDRs on the "Left" side that are allowed to connect to the IPSec tunnel, i.e the CIDRs within your IONOS Cloud LAN. Specify "0.0.0.0/0" or "::/0" for all addresses. + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description RemoteHost AuthMethod PSKKey IKEDiffieHellmanGroup IKEEncryptionAlgorithm IKEIntegrityAlgorithm IKELifetime ESPDiffieHellmanGroup ESPEncryptionAlgorithm ESPIntegrityAlgorithm ESPLifetime CloudNetworkCIDRs PeerNetworkCIDRs Status StatusMessage] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --description string Description of the IPSec Tunnel + --esp-diffie-hellman-group string The Diffie-Hellman Group to use for IPSec Encryption.. Can be one of: 15-MODP3072, 16-MODP4096, 19-ECP256, 20-ECP384, 21-ECP521, 28-ECP256BP, 29-ECP384BP, 30-ECP512BP + --esp-encryption-algorithm string The encryption algorithm to use for IPSec Encryption.. Can be one of: AES128-CTR, AES256-CTR, AES128-GCM-16, AES256-GCM-16, AES128-GCM-12, AES256-GCM-12, AES128-CCM-12, AES256-CCM-12, AES128, AES256 + --esp-integrity-algorithm string The integrity algorithm to use for IPSec Encryption.. Can be one of: SHA256, SHA384, SHA512, AES-XCBC + --esp-lifetime int32 The phase lifetime in seconds + -f, --force Force command to execute without user input + --gateway-id string The ID of the IPSec Gateway (required) + -h, --help Print usage + --host string The remote peer host fully qualified domain name or IPV4 IP to connect to. * __Note__: This should be the public IP of the remote peer. * Tunnels only support IPV4 or hostname (fully qualified DNS name). (required) + --ike-diffie-hellman-group string The Diffie-Hellman Group to use for IPSec Encryption.. Can be one of: 15-MODP3072, 16-MODP4096, 19-ECP256, 20-ECP384, 21-ECP521, 28-ECP256BP, 29-ECP384BP, 30-ECP512BP + --ike-encryption-algorithm string The encryption algorithm to use for IPSec Encryption.. Can be one of: AES128, AES256 + --ike-integrity-algorithm string The integrity algorithm to use for IPSec Encryption.. Can be one of: SHA256, SHA384, SHA512, AES-XCBC + --ike-lifetime int32 The phase lifetime in seconds + --json-properties string Path to a JSON file containing the desired properties. Overrides any other properties set. + --json-properties-example If set, prints a complete JSON which could be used for --json-properties and exits. Hint: Pipe me to a .json file + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --name string Name of the IPSec Tunnel (required) + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + --peer-network-cidrs strings The network CIDRs on the "Right" side that are allowed to connect to the IPSec tunnel. Specify "0.0.0.0/0" or "::/0" for all addresses. + --psk-key string The pre-shared key for the IPSec tunnel (required) + -q, --quiet Quiet output + -i, --tunnel-id string The ID of the IPSec Tunnel (required) + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn ipsec tunnel update --gateway-id GATEWAY_ID --tunnel-id TUNNEL_ID --name NAME +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/gateway/create.md b/docs/subcommands/VPN Gateway/wireguard/gateway/create.md new file mode 100644 index 000000000..3e02d6ec8 --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/gateway/create.md @@ -0,0 +1,68 @@ +--- +description: "Create a WireGuard Gateway" +--- + +# VpnWireguardGatewayCreate + +## Usage + +```text +ionosctl vpn wireguard gateway create [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `gateway` command: + +```text +[g gw] +``` + +For `create` command: + +```text +[c post] +``` + +## Description + +Create a WireGuard Gateway + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name PublicKey Description GatewayIP InterfaceIPv4 InterfaceIPv6 DatacenterId LanId ConnectionIPv4 ConnectionIPv6 InterfaceIP ListenPort Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --connection-ip string A LAN IPv4 or IPv6 address in CIDR notation that will be assigned to the VPN Gateway (required) + --datacenter-id string The datacenter to connect your VPN Gateway to (required) + --description string Description of the WireGuard Gateway + -f, --force Force command to execute without user input + --gateway-ip string The IP of an IPBlock in the same location as the provided datacenter (required) + -h, --help Print usage + --interface-ip string The IPv4 or IPv6 address (with CIDR mask) to be assigned to the WireGuard interface (required) + --lan-id string The numeric LAN ID to connect your VPN Gateway to (required) + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + -n, --name string Name of the WireGuard Gateway (required) + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + --port int Port that WireGuard Server will listen on (default 51820) + -K, --private-key string Specify the private key (required or --private-key-path) + -k, --private-key-path string Specify the private key from a file (required or --private-key) + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wireguard gateway create --name NAME --datacenter-id DATACENTER_ID --lan-id LAN_ID --connection-ip CONNECTION_IP --gateway-ip GATEWAY_IP --interface-ip INTERFACE_IP --private-key PRIVATE_KEY +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/gateway/delete.md b/docs/subcommands/VPN Gateway/wireguard/gateway/delete.md new file mode 100644 index 000000000..27ef8dbf0 --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/gateway/delete.md @@ -0,0 +1,60 @@ +--- +description: "Delete a gateway" +--- + +# VpnWireguardGatewayDelete + +## Usage + +```text +ionosctl vpn wireguard gateway delete [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `gateway` command: + +```text +[g gw] +``` + +For `delete` command: + +```text +[del d] +``` + +## Description + +Delete a gateway + +## Options + +```text + -a, --all Delete all gateways. Required or --gateway-id + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name PublicKey Description GatewayIP InterfaceIPv4 InterfaceIPv6 DatacenterId LanId ConnectionIPv4 ConnectionIPv6 InterfaceIP ListenPort Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the WireGuard Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wg gateway delete --gateway-id GATEWAY_ID +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/gateway/get.md b/docs/subcommands/VPN Gateway/wireguard/gateway/get.md new file mode 100644 index 000000000..86f9c8576 --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/gateway/get.md @@ -0,0 +1,59 @@ +--- +description: "Find a gateway by ID" +--- + +# VpnWireguardGatewayGet + +## Usage + +```text +ionosctl vpn wireguard gateway get [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `gateway` command: + +```text +[g gw] +``` + +For `get` command: + +```text +[g] +``` + +## Description + +Find a gateway by ID + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name PublicKey Description GatewayIP InterfaceIPv4 InterfaceIPv6 DatacenterId LanId ConnectionIPv4 ConnectionIPv6 InterfaceIP ListenPort Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the WireGuard Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wireguard gateway get --gateway-id GATEWAY_ID +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/gateway/list.md b/docs/subcommands/VPN Gateway/wireguard/gateway/list.md new file mode 100644 index 000000000..1faf83807 --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/gateway/list.md @@ -0,0 +1,60 @@ +--- +description: "List WireGuard Gateways" +--- + +# VpnWireguardGatewayList + +## Usage + +```text +ionosctl vpn wireguard gateway list [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `gateway` command: + +```text +[g gw] +``` + +For `list` command: + +```text +[l ls] +``` + +## Description + +List WireGuard Gateways + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name PublicKey Description GatewayIP InterfaceIPv4 InterfaceIPv6 DatacenterId LanId ConnectionIPv4 ConnectionIPv6 InterfaceIP ListenPort Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + -M, --max-results int32 The maximum number of elements to return + --no-headers Don't print table headers when table output is used + --offset int32 Skip a certain number of results + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wireguard gateway list +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/gateway/update.md b/docs/subcommands/VPN Gateway/wireguard/gateway/update.md new file mode 100644 index 000000000..a49ed62fc --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/gateway/update.md @@ -0,0 +1,69 @@ +--- +description: "Update a WireGuard Gateway" +--- + +# VpnWireguardGatewayUpdate + +## Usage + +```text +ionosctl vpn wireguard gateway update [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `gateway` command: + +```text +[g gw] +``` + +For `update` command: + +```text +[u put patch] +``` + +## Description + +Update a WireGuard Gateway. Note: The private key MUST be provided again (or changed) on updates. + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name PublicKey Description GatewayIP InterfaceIPv4 InterfaceIPv6 DatacenterId LanId ConnectionIPv4 ConnectionIPv6 InterfaceIP ListenPort Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --connection-ip string A LAN IPv4 or IPv6 address in CIDR notation that will be assigned to the VPN Gateway (required) + --datacenter-id string The datacenter to connect your VPN Gateway to (required) + --description string Description of the WireGuard Gateway + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the WireGuard Gateway (required) + --gateway-ip string The IP of an IPBlock in the same location as the provided datacenter (required) + -h, --help Print usage + --interface-ip string The IPv4 or IPv6 address (with CIDR mask) to be assigned to the WireGuard interface (required) + --lan-id string The numeric LAN ID to connect your VPN Gateway to (required) + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + -n, --name string Name of the WireGuard Gateway (required) + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + --port int Port that WireGuard Server will listen on (default 51820) + -K, --private-key string Specify the private key (required or --private-key-path) + -k, --private-key-path string Specify the private key from a file (required or --private-key) + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wireguard gateway update --gateway-id GATEWAY_ID --name NAME --datacenter-id DATACENTER_ID --lan-id LAN_ID --connection-ip CONNECTION_IP --gateway-ip GATEWAY_IP --interface-ip INTERFACE_IP +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/peer/create.md b/docs/subcommands/VPN Gateway/wireguard/peer/create.md new file mode 100644 index 000000000..d1ca8d777 --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/peer/create.md @@ -0,0 +1,65 @@ +--- +description: "Create a WireGuard Peer" +--- + +# VpnWireguardPeerCreate + +## Usage + +```text +ionosctl vpn wireguard peer create [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `peer` command: + +```text +[p] +``` + +For `create` command: + +```text +[c post] +``` + +## Description + +Create WireGuard Peers. There is a limit to the total number of peers. Please refer to product documentation + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description Host Port WhitelistIPs PublicKey Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --description string Description of the WireGuard Peer + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the WireGuard Gateway (required) + -h, --help Print usage + --host string Hostname or IPV4 address that the WireGuard Server will connect to (required) + --ips strings Comma separated subnets of CIDRs that are allowed to connect to the WireGuard Gateway. Specify "a.b.c.d/32" for an individual IP address. Specify "0.0.0.0/0" or "::/0" for all addresses (required) + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --name string Name of the WireGuard Peer (required) + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + --port int Port that the WireGuard Server will connect to (default 51820) + --public-key string Public key of the connecting peer (required) + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wireguard peer create --gateway-id GATEWAY_ID --name NAME --ips IPS --public-key PUBLIC_KEY --host HOST +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/peer/delete.md b/docs/subcommands/VPN Gateway/wireguard/peer/delete.md new file mode 100644 index 000000000..8831afa7d --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/peer/delete.md @@ -0,0 +1,61 @@ +--- +description: "Remove a WireGuard Peer" +--- + +# VpnWireguardPeerDelete + +## Usage + +```text +ionosctl vpn wireguard peer delete [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `peer` command: + +```text +[p] +``` + +For `delete` command: + +```text +[d del rm] +``` + +## Description + +Remove a WireGuard Peer + +## Options + +```text + -a, --all Delete all peers. Required or --peer-id + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description Host Port WhitelistIPs PublicKey Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + --gateway-id string The ID of the WireGuard Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -i, --peer-id string The ID of the WireGuard Peer you want to delete (required) + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wireguard peer delete --gateway-id GATEWAY_ID --peer-id PEER_ID +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/peer/get.md b/docs/subcommands/VPN Gateway/wireguard/peer/get.md new file mode 100644 index 000000000..d085fcdac --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/peer/get.md @@ -0,0 +1,60 @@ +--- +description: "Find a peer by ID" +--- + +# VpnWireguardPeerGet + +## Usage + +```text +ionosctl vpn wireguard peer get [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `peer` command: + +```text +[p] +``` + +For `get` command: + +```text +[g] +``` + +## Description + +Find a peer by ID + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description Host Port WhitelistIPs PublicKey Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + --gateway-id string The ID of the WireGuard Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -i, --peer-id string The ID of the WireGuard Peer (required) + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wg peer get --gateway-id GATEWAY_ID --peer-id PEER_ID +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/peer/list.md b/docs/subcommands/VPN Gateway/wireguard/peer/list.md new file mode 100644 index 000000000..b846bbed1 --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/peer/list.md @@ -0,0 +1,61 @@ +--- +description: "List WireGuard Peers" +--- + +# VpnWireguardPeerList + +## Usage + +```text +ionosctl vpn wireguard peer list [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `peer` command: + +```text +[p] +``` + +For `list` command: + +```text +[l ls] +``` + +## Description + +List WireGuard Peers + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description Host Port WhitelistIPs PublicKey Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -f, --force Force command to execute without user input + -i, --gateway-id string The ID of the Wireguard Gateway (required) + -h, --help Print usage + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + -M, --max-results int32 The maximum number of elements to return + --no-headers Don't print table headers when table output is used + --offset int32 Skip a certain number of results + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wireguard peer list --gateway-id GATEWAY_ID +``` + diff --git a/docs/subcommands/VPN Gateway/wireguard/peer/update.md b/docs/subcommands/VPN Gateway/wireguard/peer/update.md new file mode 100644 index 000000000..7b796fec9 --- /dev/null +++ b/docs/subcommands/VPN Gateway/wireguard/peer/update.md @@ -0,0 +1,66 @@ +--- +description: "Update a WireGuard Peer" +--- + +# VpnWireguardPeerUpdate + +## Usage + +```text +ionosctl vpn wireguard peer update [flags] +``` + +## Aliases + +For `wireguard` command: + +```text +[wg] +``` + +For `peer` command: + +```text +[p] +``` + +For `update` command: + +```text +[u patch put] +``` + +## Description + +Update a WireGuard Peer + +## Options + +```text + -u, --api-url string Override default host URL (default "https://vpn.de-txl.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [ID Name Description Host Port WhitelistIPs PublicKey Status] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --description string Description of the WireGuard Peer + -f, --force Force command to execute without user input + --gateway-id string The ID of the WireGuard Gateway (required) + -h, --help Print usage + --host string Hostname or IPV4 address that the WireGuard Server will connect to (required) + --ips strings Comma separated subnets of CIDRs that are allowed to connect to the WireGuard Gateway. Specify "a.b.c.d/32" for an individual IP address. Specify "0.0.0.0/0" or "::/0" for all addresses (required) + -l, --location string Location of the resource to operate on. Can be one of: de/txl, de/fra, es/vit, fr/par, gb/lhr, gb/bhx, us/ewr, us/las, us/mci + --name string Name of the WireGuard Peer (required) + --no-headers Don't print table headers when table output is used + -o, --output string Desired output format [text|json|api-json] (default "text") + -i, --peer-id string The ID of the WireGuard Peer (required) + --port int Port that the WireGuard Server will connect to (default 51820) + --public-key string Public key of the connecting peer (required) + -q, --quiet Quiet output + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl vpn wireguard peer update --gateway-id GATEWAY_ID --peer-id PEER_ID --name NAME --description DESCRIPTION --ips IPS --public-key PUBLIC_KEY --host HOST --port PORT +``` + diff --git a/docs/summary.md b/docs/summary.md index df8c5f75e..69cfb7f66 100644 --- a/docs/summary.md +++ b/docs/summary.md @@ -501,6 +501,33 @@ * server * [get](subcommands%2FVM%20Autoscaling%2Fserver%2Fget.md) * [list](subcommands%2FVM%20Autoscaling%2Fserver%2Flist.md) +* VPN Gateway + * ipsec + * gateway + * [create](subcommands%2FVPN%20Gateway%2Fipsec%2Fgateway%2Fcreate.md) + * [delete](subcommands%2FVPN%20Gateway%2Fipsec%2Fgateway%2Fdelete.md) + * [get](subcommands%2FVPN%20Gateway%2Fipsec%2Fgateway%2Fget.md) + * [list](subcommands%2FVPN%20Gateway%2Fipsec%2Fgateway%2Flist.md) + * [update](subcommands%2FVPN%20Gateway%2Fipsec%2Fgateway%2Fupdate.md) + * tunnel + * [create](subcommands%2FVPN%20Gateway%2Fipsec%2Ftunnel%2Fcreate.md) + * [delete](subcommands%2FVPN%20Gateway%2Fipsec%2Ftunnel%2Fdelete.md) + * [get](subcommands%2FVPN%20Gateway%2Fipsec%2Ftunnel%2Fget.md) + * [list](subcommands%2FVPN%20Gateway%2Fipsec%2Ftunnel%2Flist.md) + * [update](subcommands%2FVPN%20Gateway%2Fipsec%2Ftunnel%2Fupdate.md) + * wireguard + * gateway + * [create](subcommands%2FVPN%20Gateway%2Fwireguard%2Fgateway%2Fcreate.md) + * [delete](subcommands%2FVPN%20Gateway%2Fwireguard%2Fgateway%2Fdelete.md) + * [get](subcommands%2FVPN%20Gateway%2Fwireguard%2Fgateway%2Fget.md) + * [list](subcommands%2FVPN%20Gateway%2Fwireguard%2Fgateway%2Flist.md) + * [update](subcommands%2FVPN%20Gateway%2Fwireguard%2Fgateway%2Fupdate.md) + * peer + * [create](subcommands%2FVPN%20Gateway%2Fwireguard%2Fpeer%2Fcreate.md) + * [delete](subcommands%2FVPN%20Gateway%2Fwireguard%2Fpeer%2Fdelete.md) + * [get](subcommands%2FVPN%20Gateway%2Fwireguard%2Fpeer%2Fget.md) + * [list](subcommands%2FVPN%20Gateway%2Fwireguard%2Fpeer%2Flist.md) + * [update](subcommands%2FVPN%20Gateway%2Fwireguard%2Fpeer%2Fupdate.md) ## Legal diff --git a/go.mod b/go.mod index c97768df8..a30d63365 100644 --- a/go.mod +++ b/go.mod @@ -43,6 +43,7 @@ require ( github.com/ionos-cloud/sdk-go-cdn v1.1.0 github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.1.1 github.com/ionos-cloud/sdk-go-kafka v1.1.0 + github.com/ionos-cloud/sdk-go-vpn v1.0.1 ) require ( diff --git a/go.sum b/go.sum index 7d51c8c49..9f1062b74 100644 --- a/go.sum +++ b/go.sum @@ -268,6 +268,8 @@ github.com/ionos-cloud/sdk-go-logging v1.0.1 h1:MB9jPoBUL3mZ+ois7kXYy67x0FopAw2a github.com/ionos-cloud/sdk-go-logging v1.0.1/go.mod h1:P2JQJpUgH3ZyfyJmv6jMwcB1NJIVVZSL+/bllhWpwc8= github.com/ionos-cloud/sdk-go-vm-autoscaling v1.0.1 h1:KABL25MC7DrIHn9lQzKSPkwXhqvRkPYtFd+1HEogmAE= github.com/ionos-cloud/sdk-go-vm-autoscaling v1.0.1/go.mod h1:Q5d1R6silarsX5jWLPBHd/1PSC5zZNf2ONvXB+fygC0= +github.com/ionos-cloud/sdk-go-vpn v1.0.1 h1:SsHNozjTGUfRZdQRxLsy/PX1Yp/J7ssJfk36HIgYJxE= +github.com/ionos-cloud/sdk-go-vpn v1.0.1/go.mod h1:d0OyuDsIvEQV65h8DaGvsZy4BJcLq7tTWnscULodtIc= github.com/ionos-cloud/sdk-go/v6 v6.1.11 h1:J/uRN4UWO3wCyGOeDdMKv8LWRzKu6UIkLEaes38Kzh8= github.com/ionos-cloud/sdk-go/v6 v6.1.11/go.mod h1:EzEgRIDxBELvfoa/uBN0kOQaqovLjUWEB7iW4/Q+t4k= github.com/ionoscloudsdk/comptplus v1.0.4 h1:1kq+lY17BZCiKLuR1gTJPVBYd1ro9Dqi0C24YKdE74M= diff --git a/internal/client/client.go b/internal/client/client.go index 132527d7c..cef71eebd 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -126,7 +126,6 @@ func (c *Client) TestCreds() error { // TODO: This currently skips if the server URL is manually overwritten. (i.e. staging environment, or regional APIs) return nil } - _, _, err := c.CloudClient.DefaultApi.ApiInfoGet(context.Background()).MaxResults(1).Depth(0).Execute() if err != nil { usedScheme := "used token" diff --git a/internal/client/model.go b/internal/client/model.go index 5aebcc9a2..9dad567cc 100644 --- a/internal/client/model.go +++ b/internal/client/model.go @@ -17,6 +17,7 @@ import ( dns "github.com/ionos-cloud/sdk-go-dns" logsvc "github.com/ionos-cloud/sdk-go-logging" vmasc "github.com/ionos-cloud/sdk-go-vm-autoscaling" + vpn "github.com/ionos-cloud/sdk-go-vpn" cloudv6 "github.com/ionos-cloud/sdk-go/v6" "github.com/spf13/viper" @@ -70,6 +71,7 @@ type Client struct { DnsClient *dns.APIClient LoggingServiceClient *logsvc.APIClient VMAscClient *vmasc.AutoScalingGroupsApiService + VPNClient *vpn.APIClient PostgresClient *postgres.APIClient MongoClient *mongo.APIClient @@ -121,6 +123,9 @@ func newClient(name, pwd, token, hostUrl string, usedLayer *Layer) *Client { cdnConfig := cdn.NewConfiguration(name, pwd, token, hostUrl) cdnConfig.UserAgent = appendUserAgent(cdnConfig.UserAgent) + vpnConfig := vpn.NewConfiguration(name, pwd, token, hostUrl) + vpnConfig.UserAgent = appendUserAgent(vpnConfig.UserAgent) + kafkaConfig := kafka.NewConfiguration(name, pwd, token, hostUrl) kafkaConfig.UserAgent = appendUserAgent(kafkaConfig.UserAgent) @@ -133,6 +138,7 @@ func newClient(name, pwd, token, hostUrl string, usedLayer *Layer) *Client { DnsClient: dns.NewAPIClient(dnsConfig), LoggingServiceClient: logsvc.NewAPIClient(logsConfig), VMAscClient: vmasc.NewAPIClient(vmascConfig).AutoScalingGroupsApi, + VPNClient: vpn.NewAPIClient(vpnConfig), PostgresClient: postgres.NewAPIClient(postgresConfig), MongoClient: mongo.NewAPIClient(mongoConfig), diff --git a/internal/config/config.go b/internal/config/config.go index 46d04812a..7a25863ba 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -22,7 +22,6 @@ var FieldsWithSensitiveDataInConfigFile = []string{ // GetServerUrl returns the server URL the SDK should use, with support for layered fallbacks. func GetServerUrl() string { viper.AutomaticEnv() - if val := viper.GetString(constants.ArgServerUrl); viper.IsSet(constants.ArgServerUrl) && val != "" { // 1. Above all, use global flag val return val @@ -38,10 +37,10 @@ func GetServerUrl() string { } val := cfgFields[constants.CfgServerUrl] - if val != "" { - // 3. Fallback to non-empty cfg field + if val != "" { // 3. Fallback to non-empty cfg field return val } + // 4. Return empty string. SDKs should handle it, per docs return "" } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 36afc3ae1..42ba9440b 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -252,7 +252,7 @@ func TestGetServerUrl(t *testing.T) { expectedServerUrl: constants.DefaultApiURL, }, { - name: "CFG value is returned", + name: "CFG value is preferred over defaults", flagVal: "", envVal: "", cfgVal: "cfg-url", diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 78b807a02..9d3987171 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -35,6 +35,33 @@ Within each layer, a token takes precedence over a username and password combina FlagLanId = "lan-id" FlagEdition = "edition" + FlagGatewayID = "gateway-id" + FlagTunnelID = "tunnel-id" + FlagPeerID = "peer-id" + FlagGatewayIP = "gateway-ip" + FlagInterfaceIP = "interface-ip" + FlagConnectionIP = "connection-ip" + FlagPrivateKey = "private-key" + FlagPrivateKeyPath = "private-key-path" + FlagPublicKey = "public-key" + FlagHost = "host" + FlagPort = "port" + FlagAuthMethod = "auth-method" + FlagPSKKey = "psk-key" + + FlagIKEDiffieHellmanGroup = "ike-diffie-hellman-group" + FlagIKEEncryptionAlgorithm = "ike-encryption-algorithm" + FlagIKEIntegrityAlgorithm = "ike-integrity-algorithm" + FlagIKELifetime = "ike-lifetime" + + FlagESPDiffieHellmanGroup = "esp-diffie-hellman-group" + FlagESPIntegrityAlgorithm = "esp-integrity-algorithm" + FlagESPEncryptionAlgorithm = "esp-encryption-algorithm" + FlagESPLifetime = "esp-lifetime" + + FlagCloudNetworkCIDRs = "cloud-network-cidrs" + FlagPeerNetworkCIDRs = "peer-network-cidrs" + FlagCores = "cores" FlagRam = "ram" FlagAvailabilityZone = "availability-zone" @@ -162,6 +189,7 @@ const ( LoggingApiRegionalURL = "https://logging.%s.ionos.com" CDNApiRegionalURL = "https://cdn.%s.ionos.com" MariaDBApiRegionalURL = "https://mariadb.%s.ionos.com" + VPNApiRegionalURL = "https://vpn.%s.ionos.com" KafkaApiRegionalURL = "https://kafka.%s.ionos.com" ) @@ -170,6 +198,7 @@ var ( LoggingAPILocations = []string{"de/txl", "de/fra", "gb/lhr", "fr/par", "es/vit"} CDNLocations = []string{"de/fra"} MariaDBLocations = []string{"de/txl", "de/fra", "es/vit", "fr/par", "gb/lhr", "us/ewr", "us/las", "us/mci"} + VPNLocations = []string{"de/txl", "de/fra", "es/vit", "fr/par", "gb/lhr", "gb/bhx", "us/ewr", "us/las", "us/mci"} KafkaLocations = []string{ "de/fra", "de/txl", // other locations not yet available. will be added in the future. diff --git a/internal/core/doc/doc.go b/internal/core/doc/doc.go index 969411f75..d4a7886b3 100644 --- a/internal/core/doc/doc.go +++ b/internal/core/doc/doc.go @@ -40,6 +40,7 @@ var nonComputeNamespaces = map[string]string{ "kafka": "Kafka", "config": "CLI Setup", "vm-autoscaling": "VM Autoscaling", + "vpn": "VPN Gateway", "logging-service": "Logging-Service", } diff --git a/internal/core/flag.go b/internal/core/flag.go index 340f0ffef..186ae2705 100644 --- a/internal/core/flag.go +++ b/internal/core/flag.go @@ -30,6 +30,8 @@ func FlagUsage(flag string) string { } // FlagsUsage calls FlagUsage for every flag in the slice +// +// FlagsUsage ("datacenter-id") -> "--datacenter-id DATACENTER_ID" func FlagsUsage(flags ...string) string { usage := "" for _, flagName := range flags { diff --git a/internal/printer/json2table/jsonpaths/vpn.go b/internal/printer/json2table/jsonpaths/vpn.go new file mode 100644 index 000000000..b9ce5da14 --- /dev/null +++ b/internal/printer/json2table/jsonpaths/vpn.go @@ -0,0 +1,64 @@ +package jsonpaths + +var VPNWireguardGateway = map[string]string{ + "ID": "id", + "Name": "properties.name", + "Description": "properties.description", + "GatewayIP": "properties.gatewayIP", + "InterfaceIPv4": "properties.interfaceIPv4CIDR", + "InterfaceIPv6": "properties.interfaceIPv6CIDR", + "ListenPort": "properties.listenPort", + "DatacenterId": "properties.connections[0].datacenterId", + "LanId": "properties.connections[0].lanId", + "ConnectionIPv4": "properties.connections[0].ipv4CIDR", + "ConnectionIPv6": "properties.connections[0].ipv6CIDR", + "Status": "metadata.status", + "StatusMessage": "metadata.statusMessage", + "PublicKey": "metadata.publicKey", +} + +var VPNWireguardPeer = map[string]string{ + "ID": "id", + "Name": "properties.name", + "Description": "properties.description", + "Host": "properties.endpoint.host", + "Port": "properties.endpoint.port", + "WhitelistIPs": "properties.allowedIPs", + "PublicKey": "properties.publicKey", + "Status": "metadata.status", +} + +var VPNIPSecGateway = map[string]string{ + "ID": "id", + "Name": "properties.name", + "Description": "properties.description", + "GatewayIP": "properties.gatewayIP", + "Version": "properties.version", + "DatacenterId": "properties.connections[0].datacenterId", + "LanId": "properties.connections[0].lanId", + "ConnectionIPv4": "properties.connections[0].ipv4CIDR", + "ConnectionIPv6": "properties.connections[0].ipv6CIDR", + "Status": "metadata.status", + "StatusMessage": "metadata.statusMessage", +} + +var VPNIPSecTunnel = map[string]string{ + "ID": "id", + "Name": "properties.name", + "Description": "properties.description", + "RemoteHost": "properties.remoteHost", + "AuthMethod": "properties.auth.method", + "PSKKey": "properties.auth.psk.key", + "IKEDiffieHellmanGroup": "properties.ike.diffieHellmanGroup", + "IKEEncryptionAlgorithm": "properties.ike.encryptionAlgorithm", + "IKEIntegrityAlgorithm": "properties.ike.integrityAlgorithm", + "IKELifetime": "properties.ike.lifetime", + "ESPDiffieHellmanGroup": "properties.esp.diffieHellmanGroup", + "ESPEncryptionAlgorithm": "properties.esp.encryptionAlgorithm", + "ESPIntegrityAlgorithm": "properties.esp.integrityAlgorithm", + "ESPLifetime": "properties.esp.lifetime", + "CloudNetworkCIDRs": "properties.cloudNetworkCIDRs", + "PeerNetworkCIDRs": "properties.peerNetworkCIDRs", + "Status": "metadata.status", + "StatusMessage": "metadata.statusMessage", +} diff --git a/internal/printer/json2table/resource2table/vpn.go b/internal/printer/json2table/resource2table/vpn.go new file mode 100644 index 000000000..cf8cc74de --- /dev/null +++ b/internal/printer/json2table/resource2table/vpn.go @@ -0,0 +1,87 @@ +package resource2table + +import ( + "fmt" + + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths" + vpn "github.com/ionos-cloud/sdk-go-vpn" +) + +func ConvertVPNWireguardGatewaysToTable(gateways vpn.WireguardGatewayReadList) ([]map[string]interface{}, error) { + items, ok := gateways.GetItemsOk() + if !ok || items == nil { + return nil, fmt.Errorf("could not retrieve Wireguard Gateway items") + } + + var usersConverted []map[string]interface{} + for _, item := range *items { + temp, err := ConvertVPNWireguardGatewayToTable(item) + if err != nil { + return nil, err + } + + usersConverted = append(usersConverted, temp...) + } + + return usersConverted, nil +} + +func ConvertVPNWireguardGatewayToTable(gateway vpn.WireguardGatewayRead) ([]map[string]interface{}, error) { + table, err := json2table.ConvertJSONToTable("", jsonpaths.VPNWireguardGateway, gateway) + if err != nil { + return nil, fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + + for _, connection := range *gateway.Properties.Connections { + table[0]["DatacenterId"] = *connection.DatacenterId + table[0]["LanId"] = *connection.LanId + if connection.Ipv4CIDR != nil { + table[0]["ConnectionIPv4"] = *connection.Ipv4CIDR + } + if connection.Ipv6CIDR != nil { + table[0]["ConnectionIPv6"] = *connection.Ipv6CIDR + } + } + + return table, nil +} + +func ConvertVPNIPSecGatewaysToTable(gateways vpn.IPSecGatewayReadList) ([]map[string]interface{}, error) { + items, ok := gateways.GetItemsOk() + if !ok || items == nil { + return nil, fmt.Errorf("could not retrieve IPSec Gateway items") + } + + var usersConverted []map[string]interface{} + for _, item := range *items { + temp, err := ConvertVPNIPSecGatewayToTable(item) + if err != nil { + return nil, err + } + + usersConverted = append(usersConverted, temp...) + } + + return usersConverted, nil +} + +func ConvertVPNIPSecGatewayToTable(gateway vpn.IPSecGatewayRead) ([]map[string]interface{}, error) { + table, err := json2table.ConvertJSONToTable("", jsonpaths.VPNIPSecGateway, gateway) + if err != nil { + return nil, fmt.Errorf("could not convert from JSON to Table format: %w", err) + } + + for _, connection := range *gateway.Properties.Connections { + table[0]["DatacenterId"] = *connection.DatacenterId + table[0]["LanId"] = *connection.LanId + if connection.Ipv4CIDR != nil { + table[0]["ConnectionIPv4"] = *connection.Ipv4CIDR + } + if connection.Ipv6CIDR != nil { + table[0]["ConnectionIPv6"] = *connection.Ipv6CIDR + } + } + + return table, nil +} diff --git a/test/bats/setup.bats b/test/bats/setup.bats index 9f87802cd..a1d02368b 100644 --- a/test/bats/setup.bats +++ b/test/bats/setup.bats @@ -104,15 +104,12 @@ find_or_create_resource() { local find_command="$1" local create_command="$2" - run bash -c "$find_command" + bash -c "$find_command" if [ "$status" -eq 0 ] && [ -n "$output" ]; then - local resource_id=$(echo "$output") - echo "$resource_id" + echo "$output" return 0 fi - run bash -c "$create_command" - assert_success - local new_resource_id=$(echo "$output") - echo "$new_resource_id" + bash -c "$create_command" + echo "$output" } diff --git a/test/bats/vpn/ipsec.bats b/test/bats/vpn/ipsec.bats new file mode 100644 index 000000000..282d26c6f --- /dev/null +++ b/test/bats/vpn/ipsec.bats @@ -0,0 +1,122 @@ +#!/usr/bin/env bats + +# tags: vpn, ipsec, tunnel + +BATS_LIBS_PATH="${LIBS_PATH:-../libs}" # fallback to relative path if not set +load "${BATS_LIBS_PATH}/bats-assert/load" +load "${BATS_LIBS_PATH}/bats-support/load" +load '../setup.bats' + +location="es/vit" + +setup_file() { + export IONOS_TOKEN=$(ionosctl token generate) + mkdir -p /tmp/bats_test +} + +@test "Create datacenter, LAN, and IP block" { + datacenter_id=$(ionosctl datacenter create --name "CLI-Test-$(randStr 8)" --location "${location}" -o json 2> /dev/null | jq -r '.id') + [ -n "$datacenter_id" ] || fail "Failed to create datacenter" + echo "$datacenter_id" > /tmp/bats_test/datacenter_id + + sleep 60 + + lan_id=$(ionosctl lan create --datacenter-id "$datacenter_id" --public=false -o json 2> /dev/null | jq -r '.id') + [ -n "$lan_id" ] || fail "Failed to create LAN" + echo "$lan_id" > /tmp/bats_test/lan_id + + ipblock_id=$(ionosctl ipblock create --location "$location" --size 1 -o json 2> /dev/null | jq -r '.id') + [ -n "$ipblock_id" ] || fail "Failed to create IP block" + echo "$ipblock_id" > /tmp/bats_test/ipblock_id + + ipblock_ip=$(ionosctl ipblock get --ipblock-id "$ipblock_id" -o json 2> /dev/null | jq -r '.properties.ips[0]') + [ -n "$ipblock_ip" ] || fail "Failed to retrieve IP block IP" + echo "$ipblock_ip" > /tmp/bats_test/ipblock_ip + + lan_status="" + i=0 + while [ "$lan_status" != "AVAILABLE" ] && [ $i -lt 30 ]; do + lan_status=$(ionosctl lan get --lan-id "$lan_id" --datacenter-id "$datacenter_id" -o json 2> /dev/null | jq -r '.metadata.state') + sleep 10 + i=$((i+1)) + done + [ "$lan_status" = "AVAILABLE" ] || fail "LAN is not available" +} + +@test "Create IPSec Gateway" { + datacenter_id=$(cat /tmp/bats_test/datacenter_id) + lan_id=$(cat /tmp/bats_test/lan_id) + ipblock_ip=$(cat /tmp/bats_test/ipblock_ip) + + run ionosctl vpn ipsec gateway create --location "${location}" --name "cli-test-$(randStr 6)" \ + --datacenter-id "$datacenter_id" --lan-id "$lan_id" --connection-ip "10.7.222.239/24" --gateway-ip "$ipblock_ip" \ + -o json 2> /dev/null + assert_success + + gateway_id=$(echo "$output" | jq -r '.id') + [ -n "$gateway_id" ] || fail "Failed to create IPSec Gateway" + echo "$gateway_id" > /tmp/bats_test/ipsec_gateway_id + + run ionosctl vpn ipsec gateway get --location "${location}" --gateway-id "$gateway_id" -o json 2> /dev/null + assert_success + assert_equal "$gateway_id" "$(echo "$output" | jq -r '.id')" +} + +@test "Update IPSec Gateway name" { + gateway_id=$(cat /tmp/bats_test/ipsec_gateway_id) + new_name="cli-test-updated-$(randStr 6)" + + run ionosctl vpn ipsec gateway update --location "${location}" --gateway-id "$gateway_id" --name "$new_name" -o json 2> /dev/null + assert_success + + run ionosctl vpn ipsec gateway get --location "${location}" --gateway-id "$gateway_id" -o json 2> /dev/null + assert_success + assert_equal "$new_name" "$(echo "$output" | jq -r '.properties.name')" +} + +@test "Create IPSec Tunnel" { + gateway_id=$(cat /tmp/bats_test/ipsec_gateway_id) + + run ionosctl vpn ipsec tunnel create --location "${location}" --gateway-id "$gateway_id" --name "cli-test-tunnel" \ + --host "192.168.1.1" --auth-method "PSK" --psk-key "$(openssl rand -base64 32)" \ + --ike-diffie-hellman-group "19-ECP256" --ike-encryption-algorithm "AES256" --ike-integrity-algorithm "SHA256" --ike-lifetime 86400 \ + --esp-diffie-hellman-group "19-ECP256" --esp-encryption-algorithm "AES256" --esp-integrity-algorithm "SHA256" --esp-lifetime 3600 \ + --cloud-network-cidrs "10.0.0.0/16" --peer-network-cidrs "192.168.0.0/16" -o json 2> /dev/null + assert_success + + tunnel_id=$(echo "$output" | jq -r '.id') + [ -n "$tunnel_id" ] || fail "Failed to create IPSec Tunnel" + echo "$tunnel_id" > /tmp/bats_test/ipsec_tunnel_id + + run ionosctl vpn ipsec tunnel get --location "${location}" --gateway-id "$gateway_id" --tunnel-id "$tunnel_id" -o json 2> /dev/null + assert_success + assert_equal "$tunnel_id" "$(echo "$output" | jq -r '.id')" +} + +@test "Update IPSec Tunnel" { + gateway_id=$(cat /tmp/bats_test/ipsec_gateway_id) + tunnel_id=$(cat /tmp/bats_test/ipsec_tunnel_id) + new_name="cli-tunnel-updated-$(randStr 6)" + new_psk="$(openssl rand -base64 32)" + + run ionosctl vpn ipsec tunnel update --location "${location}" --gateway-id "$gateway_id" \ + --tunnel-id "$tunnel_id" --name "$new_name" --psk-key "$new_psk" -o json 2> /dev/null + assert_success + + run ionosctl vpn ipsec tunnel get --location "${location}" --gateway-id "$gateway_id" --tunnel-id "$tunnel_id" -o json 2> /dev/null + assert_success + assert_equal "$new_name" "$(echo "$output" | jq -r '.properties.name')" +} + +teardown_file() { + ionosctl vpn ipsec gateway delete -af --location "${location}" + + sleep 30 + + ionosctl datacenter delete --datacenter-id "$(cat /tmp/bats_test/datacenter_id)" -f + ionosctl ipblock delete --ipblock-id "$(cat /tmp/bats_test/ipblock_id)" -f + + ionosctl token delete --token "$IONOS_TOKEN" --f + + rm -rf /tmp/bats_test +} diff --git a/test/bats/vpn/wireguard.bats b/test/bats/vpn/wireguard.bats new file mode 100644 index 000000000..bd99f364a --- /dev/null +++ b/test/bats/vpn/wireguard.bats @@ -0,0 +1,164 @@ +#!/usr/bin/env bats + +# tags: vpn, wireguard, peer + +BATS_LIBS_PATH="${LIBS_PATH:-../libs}" # fallback to relative path if not set +load "${BATS_LIBS_PATH}/bats-assert/load" +load "${BATS_LIBS_PATH}/bats-support/load" +load '../setup.bats' + +location="de/txl" + +setup_file() { + export IONOS_TOKEN=$(ionosctl token generate) + mkdir -p /tmp/bats_test +} + +@test "Create datacenter, LAN, and IP block" { + datacenter_id=$(ionosctl datacenter create --name "CLI-Test-$(randStr 8)" --location "${location}" -o json 2> /dev/null | jq -r '.id') + [ -n "$datacenter_id" ] || fail "Failed to create datacenter" + echo "$datacenter_id" > /tmp/bats_test/datacenter_id + + sleep 60 + + lan_id=$(ionosctl lan create --datacenter-id "$datacenter_id" --public=false -o json 2> /dev/null | jq -r '.id') + [ -n "$lan_id" ] || fail "Failed to create LAN" + echo "$lan_id" > /tmp/bats_test/lan_id + + ipblock_id=$(ionosctl ipblock create --location "$location" --size 1 -o json 2> /dev/null | jq -r '.id') + [ -n "$ipblock_id" ] || fail "Failed to create IP block" + echo "$ipblock_id" > /tmp/bats_test/ipblock_id + + ipblock_ip=$(ionosctl ipblock get --ipblock-id "$ipblock_id" -o json 2> /dev/null | jq -r '.properties.ips[0]') + [ -n "$ipblock_ip" ] || fail "Failed to retrieve IP block IP" + echo "$ipblock_ip" > /tmp/bats_test/ipblock_ip + + lan_status="" + i=0 + while [ "$lan_status" != "AVAILABLE" ] && [ $i -lt 30 ]; do + lan_status=$(ionosctl lan get --lan-id "$lan_id" --datacenter-id "$datacenter_id" -o json 2> /dev/null | jq -r '.metadata.state') + sleep 10 + i=$((i+1)) + done + [ "$lan_status" = "AVAILABLE" ] || fail "LAN is not available" + +} + +@test "Create Wireguard Gateway" { + # generate private key + run ionosctl vpn wireguard gateway create --location "${location}" --name "cli-test-$(randStr 6)" \ + --datacenter-id "$(cat /tmp/bats_test/datacenter_id)" --lan-id 1 --connection-ip 10.7.222.239/24 \ + --gateway-ip "$(cat /tmp/bats_test/ipblock_ip)" --interface-ip 10.7.222.97/24 --private-key "$(openssl rand -base64 32)" \ + -o json 2> /dev/null + assert_success + + gateway_id=$(echo "$output" | jq -r '.id') + assert_regex "$gateway_id" "$uuid_v4_regex" + echo "$gateway_id" > /tmp/bats_test/gateway_id + + # check if the gateway is created + run ionosctl vpn wireguard gateway get --location "${location}" --gateway-id "$gateway_id" -o json 2> /dev/null + assert_success + assert_equal "$gateway_id" "$(echo "$output" | jq -r '.id')" + + # check if the gateway is in the list + run ionosctl vpn wireguard gateway list --location "${location}" -o json -M 1 2> /dev/null + assert_success + assert_equal "$(echo "$output" | jq -r '.items | length')" "1" +} + +@test "Update name of Wireguard Gateway with cols flag" { + new_name="cli-test-$(randStr 6)" + + run ionosctl vpn wireguard gateway update --location "${location}" --gateway-id "$(cat /tmp/bats_test/gateway_id)" \ + --private-key "$(openssl rand -base64 32)" --name "$new_name" --cols ID --no-headers 2> /dev/null + assert_success + assert_output "$(cat /tmp/bats_test/gateway_id)" + + run ionosctl vpn wireguard gateway get --location "${location}" --gateway-id "$(cat /tmp/bats_test/gateway_id)" --cols name --no-headers 2> /dev/null + assert_success + assert_output "$new_name" + + # Not using no-headers shows the header and the value + run ionosctl vpn wireguard gateway get --location "${location}" --gateway-id "$(cat /tmp/bats_test/gateway_id)" --cols name 2> /dev/null + assert_success + assert_output -p "Name" + assert_output -p "$new_name" +} + +@test "Can use --private-key-path flag for updating private key" { + new_key=$(openssl rand -base64 32) + echo "$new_key" > /tmp/bats_test/new_key + + run ionosctl vpn wireguard gateway update --location "${location}" --gateway-id "$(cat /tmp/bats_test/gateway_id)" \ + --private-key-path /tmp/bats_test/new_key -f + assert_success + + rm /tmp/bats_test/new_key +} + +@test "Create Wireguard Peer" { + run ionosctl vpn wireguard peer create --location "${location}" --name "cli-test-$(randStr 6)" \ + --gateway-id "$(cat /tmp/bats_test/gateway_id)" --public-key "$(openssl rand -base64 32)" \ + --ips "::/0" --host "$(cat /tmp/bats_test/ipblock_ip)" -o json 2> /dev/null + assert_success + + peer_id=$(echo "$output" | jq -r '.id') + assert_regex "$peer_id" "$uuid_v4_regex" + echo "$peer_id" > /tmp/bats_test/peer_id + + run ionosctl vpn wireguard peer get --location "${location}" --gateway-id "$(cat /tmp/bats_test/gateway_id)" \ + --peer-id "$peer_id" -o json 2> /dev/null + assert_success + assert_equal "$peer_id" "$(echo "$output" | jq -r '.id')" + + run ionosctl vpn wireguard peer list --location "${location}" \ + --gateway-id "$(cat /tmp/bats_test/gateway_id)" -o json -M 1 2> /dev/null + assert_success + assert_equal "$(echo "$output" | jq -r '.items | length')" "1" +} + +@test "Update name of Wireguard Peer with cols flag" { + new_name="cli-test-$(randStr 6)" + + run ionosctl vpn wireguard peer update --location "${location}" --gateway-id "$(cat /tmp/bats_test/gateway_id)" \ + --peer-id "$(cat /tmp/bats_test/peer_id)" --name "$new_name" --cols ID --no-headers 2> /dev/null + assert_success + assert_output "$(cat /tmp/bats_test/peer_id)" + + run ionosctl vpn wireguard peer get --location "${location}" --gateway-id "$(cat /tmp/bats_test/gateway_id)" \ + --peer-id "$(cat /tmp/bats_test/peer_id)" --cols name --no-headers 2> /dev/null + assert_success + assert_output "$new_name" + + # Not using no-headers shows the header and the value + run ionosctl vpn wireguard peer get --location "${location}" \ + --gateway-id "$(cat /tmp/bats_test/gateway_id)" --peer-id "$(cat /tmp/bats_test/peer_id)" --cols name 2> /dev/null + assert_success + assert_output -p "Name" + assert_output -p "$new_name" +} + +@test "Delete Wireguard Peer" { + run ionosctl vpn wireguard peer delete --location "${location}" \ + --gateway-id "$(cat /tmp/bats_test/gateway_id)" --peer-id "$(cat /tmp/bats_test/peer_id)" -f + assert_success + + run ionosctl vpn wireguard peer list --location "${location}" \ + --gateway-id "$(cat /tmp/bats_test/gateway_id)" -o json -M 1 2> /dev/null + assert_success + assert_equal "$(echo "$output" | jq -r '.items | length')" "0" +} + +teardown_file() { + ionosctl vpn wireguard gateway delete -af --location "${location}" + + sleep 30 + + ionosctl datacenter delete --datacenter-id "$(cat /tmp/bats_test/datacenter_id)" -f + ionosctl ipblock delete --ipblock-id "$(cat /tmp/bats_test/ipblock_id)" -f + + ionosctl token delete --token "$IONOS_TOKEN" + + rm -rf /tmp/bats_test +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/.gitbook.yaml b/vendor/github.com/ionos-cloud/sdk-go-vpn/.gitbook.yaml new file mode 100644 index 000000000..6c8fbd82b --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/.gitbook.yaml @@ -0,0 +1,4 @@ +root: docs +structure: + readme: README.md + summary: summary.md diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/.gitignore b/vendor/github.com/ionos-cloud/sdk-go-vpn/.gitignore new file mode 100644 index 000000000..daf913b1b --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/.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/vendor/github.com/ionos-cloud/sdk-go-vpn/.travis.yml b/vendor/github.com/ionos-cloud/sdk-go-vpn/.travis.yml new file mode 100644 index 000000000..f5cb2ce9a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/.travis.yml @@ -0,0 +1,8 @@ +language: go + +install: + - go get -d -v . + +script: + - go build -v ./ + diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/LICENSE b/vendor/github.com/ionos-cloud/sdk-go-vpn/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/README.md b/vendor/github.com/ionos-cloud/sdk-go-vpn/README.md new file mode 100644 index 000000000..922214826 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/README.md @@ -0,0 +1,166 @@ +# Go API client for ionoscloud + +POC Docs for VPN gateway as service + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. + +- API version: 0.0.1 +- Package version: v1.0.1 +- Build package: org.openapitools.codegen.languages.GoClientCodegen +For more information, please visit [https://docs.ionos.com/support/general-information/contact-information](https://docs.ionos.com/support/general-information/contact-information) + +## Installation + +Install the following dependencies: + +```shell +go get github.com/stretchr/testify/assert +go get golang.org/x/net/context +``` + +Put the package under your project folder and add the following in import: + +```golang +import ionoscloud "github.com/ionos-cloud/sdk-go-vpn" +``` + +To use a proxy, set the environment variable `HTTP_PROXY`: + +```golang +os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") +``` + +## Configuration of Server URL + +Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. + +### Select Server Configuration + +For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`. + +```golang +ctx := context.WithValue(context.Background(), ionoscloud.ContextServerIndex, 1) +``` + +### Templated Server URL + +Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`. + +```golang +ctx := context.WithValue(context.Background(), ionoscloud.ContextServerVariables, map[string]string{ + "basePath": "v2", +}) +``` + +Note, enum values are always validated and all unused variables are silently ignored. + +## Documentation for API Endpoints + +All URIs are relative to *https://vpn.de-fra.ionos.com* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*IPSecGatewaysApi* | [**IpsecgatewaysDelete**](docs/api/IPSecGatewaysApi.md#ipsecgatewaysdelete) | **Delete** /ipsecgateways/{gatewayId} | Delete IPSecGateway +*IPSecGatewaysApi* | [**IpsecgatewaysFindById**](docs/api/IPSecGatewaysApi.md#ipsecgatewaysfindbyid) | **Get** /ipsecgateways/{gatewayId} | Retrieve IPSecGateway +*IPSecGatewaysApi* | [**IpsecgatewaysGet**](docs/api/IPSecGatewaysApi.md#ipsecgatewaysget) | **Get** /ipsecgateways | Retrieve all IPSecGateways +*IPSecGatewaysApi* | [**IpsecgatewaysPost**](docs/api/IPSecGatewaysApi.md#ipsecgatewayspost) | **Post** /ipsecgateways | Create IPSecGateway +*IPSecGatewaysApi* | [**IpsecgatewaysPut**](docs/api/IPSecGatewaysApi.md#ipsecgatewaysput) | **Put** /ipsecgateways/{gatewayId} | Ensure IPSecGateway +*IPSecTunnelsApi* | [**IpsecgatewaysTunnelsDelete**](docs/api/IPSecTunnelsApi.md#ipsecgatewaystunnelsdelete) | **Delete** /ipsecgateways/{gatewayId}/tunnels/{tunnelId} | Delete IPSecTunnel +*IPSecTunnelsApi* | [**IpsecgatewaysTunnelsFindById**](docs/api/IPSecTunnelsApi.md#ipsecgatewaystunnelsfindbyid) | **Get** /ipsecgateways/{gatewayId}/tunnels/{tunnelId} | Retrieve IPSecTunnel +*IPSecTunnelsApi* | [**IpsecgatewaysTunnelsGet**](docs/api/IPSecTunnelsApi.md#ipsecgatewaystunnelsget) | **Get** /ipsecgateways/{gatewayId}/tunnels | Retrieve all IPSecTunnels +*IPSecTunnelsApi* | [**IpsecgatewaysTunnelsPost**](docs/api/IPSecTunnelsApi.md#ipsecgatewaystunnelspost) | **Post** /ipsecgateways/{gatewayId}/tunnels | Create IPSecTunnel +*IPSecTunnelsApi* | [**IpsecgatewaysTunnelsPut**](docs/api/IPSecTunnelsApi.md#ipsecgatewaystunnelsput) | **Put** /ipsecgateways/{gatewayId}/tunnels/{tunnelId} | Ensure IPSecTunnel +*WireguardGatewaysApi* | [**WireguardgatewaysDelete**](docs/api/WireguardGatewaysApi.md#wireguardgatewaysdelete) | **Delete** /wireguardgateways/{gatewayId} | Delete WireguardGateway +*WireguardGatewaysApi* | [**WireguardgatewaysFindById**](docs/api/WireguardGatewaysApi.md#wireguardgatewaysfindbyid) | **Get** /wireguardgateways/{gatewayId} | Retrieve WireguardGateway +*WireguardGatewaysApi* | [**WireguardgatewaysGet**](docs/api/WireguardGatewaysApi.md#wireguardgatewaysget) | **Get** /wireguardgateways | Retrieve all WireguardGateways +*WireguardGatewaysApi* | [**WireguardgatewaysPost**](docs/api/WireguardGatewaysApi.md#wireguardgatewayspost) | **Post** /wireguardgateways | Create WireguardGateway +*WireguardGatewaysApi* | [**WireguardgatewaysPut**](docs/api/WireguardGatewaysApi.md#wireguardgatewaysput) | **Put** /wireguardgateways/{gatewayId} | Ensure WireguardGateway +*WireguardPeersApi* | [**WireguardgatewaysPeersDelete**](docs/api/WireguardPeersApi.md#wireguardgatewayspeersdelete) | **Delete** /wireguardgateways/{gatewayId}/peers/{peerId} | Delete WireguardPeer +*WireguardPeersApi* | [**WireguardgatewaysPeersFindById**](docs/api/WireguardPeersApi.md#wireguardgatewayspeersfindbyid) | **Get** /wireguardgateways/{gatewayId}/peers/{peerId} | Retrieve WireguardPeer +*WireguardPeersApi* | [**WireguardgatewaysPeersGet**](docs/api/WireguardPeersApi.md#wireguardgatewayspeersget) | **Get** /wireguardgateways/{gatewayId}/peers | Retrieve all WireguardPeers +*WireguardPeersApi* | [**WireguardgatewaysPeersPost**](docs/api/WireguardPeersApi.md#wireguardgatewayspeerspost) | **Post** /wireguardgateways/{gatewayId}/peers | Create WireguardPeer +*WireguardPeersApi* | [**WireguardgatewaysPeersPut**](docs/api/WireguardPeersApi.md#wireguardgatewayspeersput) | **Put** /wireguardgateways/{gatewayId}/peers/{peerId} | Ensure WireguardPeer + + +## Documentation For Models + + - [Connection](docs/models/Connection.md) + - [ESPEncryption](docs/models/ESPEncryption.md) + - [Error](docs/models/Error.md) + - [ErrorMessages](docs/models/ErrorMessages.md) + - [IKEEncryption](docs/models/IKEEncryption.md) + - [IPSecGateway](docs/models/IPSecGateway.md) + - [IPSecGatewayCreate](docs/models/IPSecGatewayCreate.md) + - [IPSecGatewayEnsure](docs/models/IPSecGatewayEnsure.md) + - [IPSecGatewayMetadata](docs/models/IPSecGatewayMetadata.md) + - [IPSecGatewayRead](docs/models/IPSecGatewayRead.md) + - [IPSecGatewayReadList](docs/models/IPSecGatewayReadList.md) + - [IPSecGatewayReadListAllOf](docs/models/IPSecGatewayReadListAllOf.md) + - [IPSecPSK](docs/models/IPSecPSK.md) + - [IPSecTunnel](docs/models/IPSecTunnel.md) + - [IPSecTunnelAuth](docs/models/IPSecTunnelAuth.md) + - [IPSecTunnelCreate](docs/models/IPSecTunnelCreate.md) + - [IPSecTunnelEnsure](docs/models/IPSecTunnelEnsure.md) + - [IPSecTunnelMetadata](docs/models/IPSecTunnelMetadata.md) + - [IPSecTunnelRead](docs/models/IPSecTunnelRead.md) + - [IPSecTunnelReadList](docs/models/IPSecTunnelReadList.md) + - [IPSecTunnelReadListAllOf](docs/models/IPSecTunnelReadListAllOf.md) + - [Links](docs/models/Links.md) + - [Metadata](docs/models/Metadata.md) + - [Pagination](docs/models/Pagination.md) + - [ResourceStatus](docs/models/ResourceStatus.md) + - [WireguardEndpoint](docs/models/WireguardEndpoint.md) + - [WireguardGateway](docs/models/WireguardGateway.md) + - [WireguardGatewayCreate](docs/models/WireguardGatewayCreate.md) + - [WireguardGatewayEnsure](docs/models/WireguardGatewayEnsure.md) + - [WireguardGatewayMetadata](docs/models/WireguardGatewayMetadata.md) + - [WireguardGatewayMetadataAllOf](docs/models/WireguardGatewayMetadataAllOf.md) + - [WireguardGatewayRead](docs/models/WireguardGatewayRead.md) + - [WireguardGatewayReadList](docs/models/WireguardGatewayReadList.md) + - [WireguardGatewayReadListAllOf](docs/models/WireguardGatewayReadListAllOf.md) + - [WireguardPeer](docs/models/WireguardPeer.md) + - [WireguardPeerCreate](docs/models/WireguardPeerCreate.md) + - [WireguardPeerEnsure](docs/models/WireguardPeerEnsure.md) + - [WireguardPeerMetadata](docs/models/WireguardPeerMetadata.md) + - [WireguardPeerRead](docs/models/WireguardPeerRead.md) + - [WireguardPeerReadList](docs/models/WireguardPeerReadList.md) + - [WireguardPeerReadListAllOf](docs/models/WireguardPeerReadListAllOf.md) + + +## Documentation For Authorization + + +Authentication schemes defined for the API: +### tokenAuth + +- **Type**: HTTP Bearer token authentication + +Example + +```golang +auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING") +r, err := client.Service.Operation(auth, args) +``` + + +## Documentation for Utility Methods + +Due to the fact that model structure members are all pointers, this package contains +a number of utility functions to easily obtain pointers to values of basic types. +Each of these functions takes a value of the given basic type and returns a pointer to it: + +* `PtrBool` +* `PtrInt` +* `PtrInt32` +* `PtrInt64` +* `PtrFloat` +* `PtrFloat32` +* `PtrFloat64` +* `PtrString` +* `PtrTime` + +## Author + +support@cloud.ionos.com + diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/api_ip_sec_gateways.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/api_ip_sec_gateways.go new file mode 100644 index 000000000..4086cad22 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/api_ip_sec_gateways.go @@ -0,0 +1,1018 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + _context "context" + "fmt" + "io" + _nethttp "net/http" + _neturl "net/url" + "strings" +) + +// Linger please +var ( + _ _context.Context +) + +// IPSecGatewaysApiService IPSecGatewaysApi service +type IPSecGatewaysApiService service + +type ApiIpsecgatewaysDeleteRequest struct { + ctx _context.Context + ApiService *IPSecGatewaysApiService + gatewayId string +} + +func (r ApiIpsecgatewaysDeleteRequest) Execute() (*APIResponse, error) { + return r.ApiService.IpsecgatewaysDeleteExecute(r) +} + +/* + * IpsecgatewaysDelete Delete IPSecGateway + * Deletes the specified IPSecGateway. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gatewayId The ID (UUID) of the IPSecGateway. + * @return ApiIpsecgatewaysDeleteRequest + */ +func (a *IPSecGatewaysApiService) IpsecgatewaysDelete(ctx _context.Context, gatewayId string) ApiIpsecgatewaysDeleteRequest { + return ApiIpsecgatewaysDeleteRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + */ +func (a *IPSecGatewaysApiService) IpsecgatewaysDeleteExecute(r ApiIpsecgatewaysDeleteRequest) (*APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecGatewaysApiService.IpsecgatewaysDelete") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways/{gatewayId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysDelete", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + return localVarAPIResponse, newErr + } + + return localVarAPIResponse, nil +} + +type ApiIpsecgatewaysFindByIdRequest struct { + ctx _context.Context + ApiService *IPSecGatewaysApiService + gatewayId string +} + +func (r ApiIpsecgatewaysFindByIdRequest) Execute() (IPSecGatewayRead, *APIResponse, error) { + return r.ApiService.IpsecgatewaysFindByIdExecute(r) +} + +/* + * IpsecgatewaysFindById Retrieve IPSecGateway + * Returns the IPSecGateway by ID. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gatewayId The ID (UUID) of the IPSecGateway. + * @return ApiIpsecgatewaysFindByIdRequest + */ +func (a *IPSecGatewaysApiService) IpsecgatewaysFindById(ctx _context.Context, gatewayId string) ApiIpsecgatewaysFindByIdRequest { + return ApiIpsecgatewaysFindByIdRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + * @return IPSecGatewayRead + */ +func (a *IPSecGatewaysApiService) IpsecgatewaysFindByIdExecute(r ApiIpsecgatewaysFindByIdRequest) (IPSecGatewayRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue IPSecGatewayRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecGatewaysApiService.IpsecgatewaysFindById") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways/{gatewayId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysFindById", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiIpsecgatewaysGetRequest struct { + ctx _context.Context + ApiService *IPSecGatewaysApiService + offset *int32 + limit *int32 +} + +func (r ApiIpsecgatewaysGetRequest) Offset(offset int32) ApiIpsecgatewaysGetRequest { + r.offset = &offset + return r +} +func (r ApiIpsecgatewaysGetRequest) Limit(limit int32) ApiIpsecgatewaysGetRequest { + r.limit = &limit + return r +} + +func (r ApiIpsecgatewaysGetRequest) Execute() (IPSecGatewayReadList, *APIResponse, error) { + return r.ApiService.IpsecgatewaysGetExecute(r) +} + +/* + - IpsecgatewaysGet Retrieve all IPSecGateways + - This endpoint enables retrieving all IPSecGateways using + +pagination and optional filters. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @return ApiIpsecgatewaysGetRequest +*/ +func (a *IPSecGatewaysApiService) IpsecgatewaysGet(ctx _context.Context) ApiIpsecgatewaysGetRequest { + return ApiIpsecgatewaysGetRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return IPSecGatewayReadList + */ +func (a *IPSecGatewaysApiService) IpsecgatewaysGetExecute(r ApiIpsecgatewaysGetRequest) (IPSecGatewayReadList, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue IPSecGatewayReadList + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecGatewaysApiService.IpsecgatewaysGet") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.offset != nil { + localVarQueryParams.Add("offset", parameterToString(*r.offset, "")) + } + if r.limit != nil { + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) + } + // 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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysGet", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiIpsecgatewaysPostRequest struct { + ctx _context.Context + ApiService *IPSecGatewaysApiService + iPSecGatewayCreate *IPSecGatewayCreate +} + +func (r ApiIpsecgatewaysPostRequest) IPSecGatewayCreate(iPSecGatewayCreate IPSecGatewayCreate) ApiIpsecgatewaysPostRequest { + r.iPSecGatewayCreate = &iPSecGatewayCreate + return r +} + +func (r ApiIpsecgatewaysPostRequest) Execute() (IPSecGatewayRead, *APIResponse, error) { + return r.ApiService.IpsecgatewaysPostExecute(r) +} + +/* + - IpsecgatewaysPost Create IPSecGateway + - Creates a new IPSecGateway. + +The full IPSecGateway needs to be provided to create the object. +Optional data will be filled with defaults or left empty. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @return ApiIpsecgatewaysPostRequest +*/ +func (a *IPSecGatewaysApiService) IpsecgatewaysPost(ctx _context.Context) ApiIpsecgatewaysPostRequest { + return ApiIpsecgatewaysPostRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return IPSecGatewayRead + */ +func (a *IPSecGatewaysApiService) IpsecgatewaysPostExecute(r ApiIpsecgatewaysPostRequest) (IPSecGatewayRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue IPSecGatewayRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecGatewaysApiService.IpsecgatewaysPost") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.iPSecGatewayCreate == nil { + return localVarReturnValue, nil, reportError("iPSecGatewayCreate 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.iPSecGatewayCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysPost", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiIpsecgatewaysPutRequest struct { + ctx _context.Context + ApiService *IPSecGatewaysApiService + gatewayId string + iPSecGatewayEnsure *IPSecGatewayEnsure +} + +func (r ApiIpsecgatewaysPutRequest) IPSecGatewayEnsure(iPSecGatewayEnsure IPSecGatewayEnsure) ApiIpsecgatewaysPutRequest { + r.iPSecGatewayEnsure = &iPSecGatewayEnsure + return r +} + +func (r ApiIpsecgatewaysPutRequest) Execute() (IPSecGatewayRead, *APIResponse, error) { + return r.ApiService.IpsecgatewaysPutExecute(r) +} + +/* + - IpsecgatewaysPut Ensure IPSecGateway + - Ensures that the IPSecGateway with the provided ID is created or modified. + +The full IPSecGateway needs to be provided to ensure +(either update or create) the IPSecGateway. Non present data will +only be filled with defaults or left empty, but not take +previous values into consideration. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param gatewayId The ID (UUID) of the IPSecGateway. + - @return ApiIpsecgatewaysPutRequest +*/ +func (a *IPSecGatewaysApiService) IpsecgatewaysPut(ctx _context.Context, gatewayId string) ApiIpsecgatewaysPutRequest { + return ApiIpsecgatewaysPutRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + * @return IPSecGatewayRead + */ +func (a *IPSecGatewaysApiService) IpsecgatewaysPutExecute(r ApiIpsecgatewaysPutRequest) (IPSecGatewayRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue IPSecGatewayRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecGatewaysApiService.IpsecgatewaysPut") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways/{gatewayId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.iPSecGatewayEnsure == nil { + return localVarReturnValue, nil, reportError("iPSecGatewayEnsure 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.iPSecGatewayEnsure + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysPut", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/api_ip_sec_tunnels.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/api_ip_sec_tunnels.go new file mode 100644 index 000000000..149c8bb81 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/api_ip_sec_tunnels.go @@ -0,0 +1,1038 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + _context "context" + "fmt" + "io" + _nethttp "net/http" + _neturl "net/url" + "strings" +) + +// Linger please +var ( + _ _context.Context +) + +// IPSecTunnelsApiService IPSecTunnelsApi service +type IPSecTunnelsApiService service + +type ApiIpsecgatewaysTunnelsDeleteRequest struct { + ctx _context.Context + ApiService *IPSecTunnelsApiService + gatewayId string + tunnelId string +} + +func (r ApiIpsecgatewaysTunnelsDeleteRequest) Execute() (*APIResponse, error) { + return r.ApiService.IpsecgatewaysTunnelsDeleteExecute(r) +} + +/* + * IpsecgatewaysTunnelsDelete Delete IPSecTunnel + * Deletes the specified IPSecTunnel. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gatewayId The ID (UUID) of the IPSecGateway. + * @param tunnelId The ID (UUID) of the IPSecTunnel. + * @return ApiIpsecgatewaysTunnelsDeleteRequest + */ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsDelete(ctx _context.Context, gatewayId string, tunnelId string) ApiIpsecgatewaysTunnelsDeleteRequest { + return ApiIpsecgatewaysTunnelsDeleteRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + tunnelId: tunnelId, + } +} + +/* + * Execute executes the request + */ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsDeleteExecute(r ApiIpsecgatewaysTunnelsDeleteRequest) (*APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecTunnelsApiService.IpsecgatewaysTunnelsDelete") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways/{gatewayId}/tunnels/{tunnelId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"tunnelId"+"}", _neturl.PathEscape(parameterToString(r.tunnelId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysTunnelsDelete", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + return localVarAPIResponse, newErr + } + + return localVarAPIResponse, nil +} + +type ApiIpsecgatewaysTunnelsFindByIdRequest struct { + ctx _context.Context + ApiService *IPSecTunnelsApiService + gatewayId string + tunnelId string +} + +func (r ApiIpsecgatewaysTunnelsFindByIdRequest) Execute() (IPSecTunnelRead, *APIResponse, error) { + return r.ApiService.IpsecgatewaysTunnelsFindByIdExecute(r) +} + +/* + * IpsecgatewaysTunnelsFindById Retrieve IPSecTunnel + * Returns the IPSecTunnel by ID. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gatewayId The ID (UUID) of the IPSecGateway. + * @param tunnelId The ID (UUID) of the IPSecTunnel. + * @return ApiIpsecgatewaysTunnelsFindByIdRequest + */ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsFindById(ctx _context.Context, gatewayId string, tunnelId string) ApiIpsecgatewaysTunnelsFindByIdRequest { + return ApiIpsecgatewaysTunnelsFindByIdRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + tunnelId: tunnelId, + } +} + +/* + * Execute executes the request + * @return IPSecTunnelRead + */ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsFindByIdExecute(r ApiIpsecgatewaysTunnelsFindByIdRequest) (IPSecTunnelRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue IPSecTunnelRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecTunnelsApiService.IpsecgatewaysTunnelsFindById") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways/{gatewayId}/tunnels/{tunnelId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"tunnelId"+"}", _neturl.PathEscape(parameterToString(r.tunnelId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysTunnelsFindById", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiIpsecgatewaysTunnelsGetRequest struct { + ctx _context.Context + ApiService *IPSecTunnelsApiService + gatewayId string + offset *int32 + limit *int32 +} + +func (r ApiIpsecgatewaysTunnelsGetRequest) Offset(offset int32) ApiIpsecgatewaysTunnelsGetRequest { + r.offset = &offset + return r +} +func (r ApiIpsecgatewaysTunnelsGetRequest) Limit(limit int32) ApiIpsecgatewaysTunnelsGetRequest { + r.limit = &limit + return r +} + +func (r ApiIpsecgatewaysTunnelsGetRequest) Execute() (IPSecTunnelReadList, *APIResponse, error) { + return r.ApiService.IpsecgatewaysTunnelsGetExecute(r) +} + +/* + - IpsecgatewaysTunnelsGet Retrieve all IPSecTunnels + - This endpoint enables retrieving all IPSecTunnels using + +pagination and optional filters. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param gatewayId The ID (UUID) of the IPSecGateway. + - @return ApiIpsecgatewaysTunnelsGetRequest +*/ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsGet(ctx _context.Context, gatewayId string) ApiIpsecgatewaysTunnelsGetRequest { + return ApiIpsecgatewaysTunnelsGetRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + * @return IPSecTunnelReadList + */ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsGetExecute(r ApiIpsecgatewaysTunnelsGetRequest) (IPSecTunnelReadList, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue IPSecTunnelReadList + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecTunnelsApiService.IpsecgatewaysTunnelsGet") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways/{gatewayId}/tunnels" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.offset != nil { + localVarQueryParams.Add("offset", parameterToString(*r.offset, "")) + } + if r.limit != nil { + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) + } + // 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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysTunnelsGet", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiIpsecgatewaysTunnelsPostRequest struct { + ctx _context.Context + ApiService *IPSecTunnelsApiService + gatewayId string + iPSecTunnelCreate *IPSecTunnelCreate +} + +func (r ApiIpsecgatewaysTunnelsPostRequest) IPSecTunnelCreate(iPSecTunnelCreate IPSecTunnelCreate) ApiIpsecgatewaysTunnelsPostRequest { + r.iPSecTunnelCreate = &iPSecTunnelCreate + return r +} + +func (r ApiIpsecgatewaysTunnelsPostRequest) Execute() (IPSecTunnelRead, *APIResponse, error) { + return r.ApiService.IpsecgatewaysTunnelsPostExecute(r) +} + +/* + - IpsecgatewaysTunnelsPost Create IPSecTunnel + - Creates a new IPSecTunnel. + +The full IPSecTunnel needs to be provided to create the object. +Optional data will be filled with defaults or left empty. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param gatewayId The ID (UUID) of the IPSecGateway. + - @return ApiIpsecgatewaysTunnelsPostRequest +*/ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsPost(ctx _context.Context, gatewayId string) ApiIpsecgatewaysTunnelsPostRequest { + return ApiIpsecgatewaysTunnelsPostRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + * @return IPSecTunnelRead + */ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsPostExecute(r ApiIpsecgatewaysTunnelsPostRequest) (IPSecTunnelRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue IPSecTunnelRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecTunnelsApiService.IpsecgatewaysTunnelsPost") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways/{gatewayId}/tunnels" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.iPSecTunnelCreate == nil { + return localVarReturnValue, nil, reportError("iPSecTunnelCreate 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.iPSecTunnelCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysTunnelsPost", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiIpsecgatewaysTunnelsPutRequest struct { + ctx _context.Context + ApiService *IPSecTunnelsApiService + gatewayId string + tunnelId string + iPSecTunnelEnsure *IPSecTunnelEnsure +} + +func (r ApiIpsecgatewaysTunnelsPutRequest) IPSecTunnelEnsure(iPSecTunnelEnsure IPSecTunnelEnsure) ApiIpsecgatewaysTunnelsPutRequest { + r.iPSecTunnelEnsure = &iPSecTunnelEnsure + return r +} + +func (r ApiIpsecgatewaysTunnelsPutRequest) Execute() (IPSecTunnelRead, *APIResponse, error) { + return r.ApiService.IpsecgatewaysTunnelsPutExecute(r) +} + +/* + - IpsecgatewaysTunnelsPut Ensure IPSecTunnel + - Ensures that the IPSecTunnel with the provided ID is created or modified. + +The full IPSecTunnel needs to be provided to ensure +(either update or create) the IPSecTunnel. Non present data will +only be filled with defaults or left empty, but not take +previous values into consideration. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param gatewayId The ID (UUID) of the IPSecGateway. + - @param tunnelId The ID (UUID) of the IPSecTunnel. + - @return ApiIpsecgatewaysTunnelsPutRequest +*/ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsPut(ctx _context.Context, gatewayId string, tunnelId string) ApiIpsecgatewaysTunnelsPutRequest { + return ApiIpsecgatewaysTunnelsPutRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + tunnelId: tunnelId, + } +} + +/* + * Execute executes the request + * @return IPSecTunnelRead + */ +func (a *IPSecTunnelsApiService) IpsecgatewaysTunnelsPutExecute(r ApiIpsecgatewaysTunnelsPutRequest) (IPSecTunnelRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue IPSecTunnelRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IPSecTunnelsApiService.IpsecgatewaysTunnelsPut") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/ipsecgateways/{gatewayId}/tunnels/{tunnelId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"tunnelId"+"}", _neturl.PathEscape(parameterToString(r.tunnelId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.iPSecTunnelEnsure == nil { + return localVarReturnValue, nil, reportError("iPSecTunnelEnsure 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.iPSecTunnelEnsure + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "IpsecgatewaysTunnelsPut", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/api_wireguard_gateways.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/api_wireguard_gateways.go new file mode 100644 index 000000000..469d3fa8c --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/api_wireguard_gateways.go @@ -0,0 +1,1018 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + _context "context" + "fmt" + "io" + _nethttp "net/http" + _neturl "net/url" + "strings" +) + +// Linger please +var ( + _ _context.Context +) + +// WireguardGatewaysApiService WireguardGatewaysApi service +type WireguardGatewaysApiService service + +type ApiWireguardgatewaysDeleteRequest struct { + ctx _context.Context + ApiService *WireguardGatewaysApiService + gatewayId string +} + +func (r ApiWireguardgatewaysDeleteRequest) Execute() (*APIResponse, error) { + return r.ApiService.WireguardgatewaysDeleteExecute(r) +} + +/* + * WireguardgatewaysDelete Delete WireguardGateway + * Deletes the specified WireguardGateway. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gatewayId The ID (UUID) of the WireguardGateway. + * @return ApiWireguardgatewaysDeleteRequest + */ +func (a *WireguardGatewaysApiService) WireguardgatewaysDelete(ctx _context.Context, gatewayId string) ApiWireguardgatewaysDeleteRequest { + return ApiWireguardgatewaysDeleteRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + */ +func (a *WireguardGatewaysApiService) WireguardgatewaysDeleteExecute(r ApiWireguardgatewaysDeleteRequest) (*APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardGatewaysApiService.WireguardgatewaysDelete") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways/{gatewayId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysDelete", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + return localVarAPIResponse, newErr + } + + return localVarAPIResponse, nil +} + +type ApiWireguardgatewaysFindByIdRequest struct { + ctx _context.Context + ApiService *WireguardGatewaysApiService + gatewayId string +} + +func (r ApiWireguardgatewaysFindByIdRequest) Execute() (WireguardGatewayRead, *APIResponse, error) { + return r.ApiService.WireguardgatewaysFindByIdExecute(r) +} + +/* + * WireguardgatewaysFindById Retrieve WireguardGateway + * Returns the WireguardGateway by ID. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gatewayId The ID (UUID) of the WireguardGateway. + * @return ApiWireguardgatewaysFindByIdRequest + */ +func (a *WireguardGatewaysApiService) WireguardgatewaysFindById(ctx _context.Context, gatewayId string) ApiWireguardgatewaysFindByIdRequest { + return ApiWireguardgatewaysFindByIdRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + * @return WireguardGatewayRead + */ +func (a *WireguardGatewaysApiService) WireguardgatewaysFindByIdExecute(r ApiWireguardgatewaysFindByIdRequest) (WireguardGatewayRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue WireguardGatewayRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardGatewaysApiService.WireguardgatewaysFindById") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways/{gatewayId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysFindById", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiWireguardgatewaysGetRequest struct { + ctx _context.Context + ApiService *WireguardGatewaysApiService + offset *int32 + limit *int32 +} + +func (r ApiWireguardgatewaysGetRequest) Offset(offset int32) ApiWireguardgatewaysGetRequest { + r.offset = &offset + return r +} +func (r ApiWireguardgatewaysGetRequest) Limit(limit int32) ApiWireguardgatewaysGetRequest { + r.limit = &limit + return r +} + +func (r ApiWireguardgatewaysGetRequest) Execute() (WireguardGatewayReadList, *APIResponse, error) { + return r.ApiService.WireguardgatewaysGetExecute(r) +} + +/* + - WireguardgatewaysGet Retrieve all WireguardGateways + - This endpoint enables retrieving all WireguardGateways using + +pagination and optional filters. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @return ApiWireguardgatewaysGetRequest +*/ +func (a *WireguardGatewaysApiService) WireguardgatewaysGet(ctx _context.Context) ApiWireguardgatewaysGetRequest { + return ApiWireguardgatewaysGetRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return WireguardGatewayReadList + */ +func (a *WireguardGatewaysApiService) WireguardgatewaysGetExecute(r ApiWireguardgatewaysGetRequest) (WireguardGatewayReadList, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue WireguardGatewayReadList + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardGatewaysApiService.WireguardgatewaysGet") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.offset != nil { + localVarQueryParams.Add("offset", parameterToString(*r.offset, "")) + } + if r.limit != nil { + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) + } + // 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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysGet", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiWireguardgatewaysPostRequest struct { + ctx _context.Context + ApiService *WireguardGatewaysApiService + wireguardGatewayCreate *WireguardGatewayCreate +} + +func (r ApiWireguardgatewaysPostRequest) WireguardGatewayCreate(wireguardGatewayCreate WireguardGatewayCreate) ApiWireguardgatewaysPostRequest { + r.wireguardGatewayCreate = &wireguardGatewayCreate + return r +} + +func (r ApiWireguardgatewaysPostRequest) Execute() (WireguardGatewayRead, *APIResponse, error) { + return r.ApiService.WireguardgatewaysPostExecute(r) +} + +/* + - WireguardgatewaysPost Create WireguardGateway + - Creates a new WireguardGateway. + +The full WireguardGateway needs to be provided to create the object. +Optional data will be filled with defaults or left empty. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @return ApiWireguardgatewaysPostRequest +*/ +func (a *WireguardGatewaysApiService) WireguardgatewaysPost(ctx _context.Context) ApiWireguardgatewaysPostRequest { + return ApiWireguardgatewaysPostRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return WireguardGatewayRead + */ +func (a *WireguardGatewaysApiService) WireguardgatewaysPostExecute(r ApiWireguardgatewaysPostRequest) (WireguardGatewayRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue WireguardGatewayRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardGatewaysApiService.WireguardgatewaysPost") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.wireguardGatewayCreate == nil { + return localVarReturnValue, nil, reportError("wireguardGatewayCreate 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.wireguardGatewayCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysPost", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiWireguardgatewaysPutRequest struct { + ctx _context.Context + ApiService *WireguardGatewaysApiService + gatewayId string + wireguardGatewayEnsure *WireguardGatewayEnsure +} + +func (r ApiWireguardgatewaysPutRequest) WireguardGatewayEnsure(wireguardGatewayEnsure WireguardGatewayEnsure) ApiWireguardgatewaysPutRequest { + r.wireguardGatewayEnsure = &wireguardGatewayEnsure + return r +} + +func (r ApiWireguardgatewaysPutRequest) Execute() (WireguardGatewayRead, *APIResponse, error) { + return r.ApiService.WireguardgatewaysPutExecute(r) +} + +/* + - WireguardgatewaysPut Ensure WireguardGateway + - Ensures that the WireguardGateway with the provided ID is created or modified. + +The full WireguardGateway needs to be provided to ensure +(either update or create) the WireguardGateway. Non present data will +only be filled with defaults or left empty, but not take +previous values into consideration. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param gatewayId The ID (UUID) of the WireguardGateway. + - @return ApiWireguardgatewaysPutRequest +*/ +func (a *WireguardGatewaysApiService) WireguardgatewaysPut(ctx _context.Context, gatewayId string) ApiWireguardgatewaysPutRequest { + return ApiWireguardgatewaysPutRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + * @return WireguardGatewayRead + */ +func (a *WireguardGatewaysApiService) WireguardgatewaysPutExecute(r ApiWireguardgatewaysPutRequest) (WireguardGatewayRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue WireguardGatewayRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardGatewaysApiService.WireguardgatewaysPut") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways/{gatewayId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.wireguardGatewayEnsure == nil { + return localVarReturnValue, nil, reportError("wireguardGatewayEnsure 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.wireguardGatewayEnsure + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysPut", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/api_wireguard_peers.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/api_wireguard_peers.go new file mode 100644 index 000000000..4e57a7d53 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/api_wireguard_peers.go @@ -0,0 +1,1038 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + _context "context" + "fmt" + "io" + _nethttp "net/http" + _neturl "net/url" + "strings" +) + +// Linger please +var ( + _ _context.Context +) + +// WireguardPeersApiService WireguardPeersApi service +type WireguardPeersApiService service + +type ApiWireguardgatewaysPeersDeleteRequest struct { + ctx _context.Context + ApiService *WireguardPeersApiService + gatewayId string + peerId string +} + +func (r ApiWireguardgatewaysPeersDeleteRequest) Execute() (*APIResponse, error) { + return r.ApiService.WireguardgatewaysPeersDeleteExecute(r) +} + +/* + * WireguardgatewaysPeersDelete Delete WireguardPeer + * Deletes the specified WireguardPeer. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gatewayId The ID (UUID) of the WireguardGateway. + * @param peerId The ID (UUID) of the WireguardPeer. + * @return ApiWireguardgatewaysPeersDeleteRequest + */ +func (a *WireguardPeersApiService) WireguardgatewaysPeersDelete(ctx _context.Context, gatewayId string, peerId string) ApiWireguardgatewaysPeersDeleteRequest { + return ApiWireguardgatewaysPeersDeleteRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + peerId: peerId, + } +} + +/* + * Execute executes the request + */ +func (a *WireguardPeersApiService) WireguardgatewaysPeersDeleteExecute(r ApiWireguardgatewaysPeersDeleteRequest) (*APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardPeersApiService.WireguardgatewaysPeersDelete") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways/{gatewayId}/peers/{peerId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"peerId"+"}", _neturl.PathEscape(parameterToString(r.peerId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysPeersDelete", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + return localVarAPIResponse, newErr + } + + return localVarAPIResponse, nil +} + +type ApiWireguardgatewaysPeersFindByIdRequest struct { + ctx _context.Context + ApiService *WireguardPeersApiService + gatewayId string + peerId string +} + +func (r ApiWireguardgatewaysPeersFindByIdRequest) Execute() (WireguardPeerRead, *APIResponse, error) { + return r.ApiService.WireguardgatewaysPeersFindByIdExecute(r) +} + +/* + * WireguardgatewaysPeersFindById Retrieve WireguardPeer + * Returns the WireguardPeer by ID. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gatewayId The ID (UUID) of the WireguardGateway. + * @param peerId The ID (UUID) of the WireguardPeer. + * @return ApiWireguardgatewaysPeersFindByIdRequest + */ +func (a *WireguardPeersApiService) WireguardgatewaysPeersFindById(ctx _context.Context, gatewayId string, peerId string) ApiWireguardgatewaysPeersFindByIdRequest { + return ApiWireguardgatewaysPeersFindByIdRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + peerId: peerId, + } +} + +/* + * Execute executes the request + * @return WireguardPeerRead + */ +func (a *WireguardPeersApiService) WireguardgatewaysPeersFindByIdExecute(r ApiWireguardgatewaysPeersFindByIdRequest) (WireguardPeerRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue WireguardPeerRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardPeersApiService.WireguardgatewaysPeersFindById") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways/{gatewayId}/peers/{peerId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"peerId"+"}", _neturl.PathEscape(parameterToString(r.peerId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysPeersFindById", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiWireguardgatewaysPeersGetRequest struct { + ctx _context.Context + ApiService *WireguardPeersApiService + gatewayId string + offset *int32 + limit *int32 +} + +func (r ApiWireguardgatewaysPeersGetRequest) Offset(offset int32) ApiWireguardgatewaysPeersGetRequest { + r.offset = &offset + return r +} +func (r ApiWireguardgatewaysPeersGetRequest) Limit(limit int32) ApiWireguardgatewaysPeersGetRequest { + r.limit = &limit + return r +} + +func (r ApiWireguardgatewaysPeersGetRequest) Execute() (WireguardPeerReadList, *APIResponse, error) { + return r.ApiService.WireguardgatewaysPeersGetExecute(r) +} + +/* + - WireguardgatewaysPeersGet Retrieve all WireguardPeers + - This endpoint enables retrieving all WireguardPeers using + +pagination and optional filters. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param gatewayId The ID (UUID) of the WireguardGateway. + - @return ApiWireguardgatewaysPeersGetRequest +*/ +func (a *WireguardPeersApiService) WireguardgatewaysPeersGet(ctx _context.Context, gatewayId string) ApiWireguardgatewaysPeersGetRequest { + return ApiWireguardgatewaysPeersGetRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + * @return WireguardPeerReadList + */ +func (a *WireguardPeersApiService) WireguardgatewaysPeersGetExecute(r ApiWireguardgatewaysPeersGetRequest) (WireguardPeerReadList, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue WireguardPeerReadList + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardPeersApiService.WireguardgatewaysPeersGet") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways/{gatewayId}/peers" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.offset != nil { + localVarQueryParams.Add("offset", parameterToString(*r.offset, "")) + } + if r.limit != nil { + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) + } + // 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, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysPeersGet", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiWireguardgatewaysPeersPostRequest struct { + ctx _context.Context + ApiService *WireguardPeersApiService + gatewayId string + wireguardPeerCreate *WireguardPeerCreate +} + +func (r ApiWireguardgatewaysPeersPostRequest) WireguardPeerCreate(wireguardPeerCreate WireguardPeerCreate) ApiWireguardgatewaysPeersPostRequest { + r.wireguardPeerCreate = &wireguardPeerCreate + return r +} + +func (r ApiWireguardgatewaysPeersPostRequest) Execute() (WireguardPeerRead, *APIResponse, error) { + return r.ApiService.WireguardgatewaysPeersPostExecute(r) +} + +/* + - WireguardgatewaysPeersPost Create WireguardPeer + - Creates a new WireguardPeer. + +The full WireguardPeer needs to be provided to create the object. +Optional data will be filled with defaults or left empty. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param gatewayId The ID (UUID) of the WireguardGateway. + - @return ApiWireguardgatewaysPeersPostRequest +*/ +func (a *WireguardPeersApiService) WireguardgatewaysPeersPost(ctx _context.Context, gatewayId string) ApiWireguardgatewaysPeersPostRequest { + return ApiWireguardgatewaysPeersPostRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + } +} + +/* + * Execute executes the request + * @return WireguardPeerRead + */ +func (a *WireguardPeersApiService) WireguardgatewaysPeersPostExecute(r ApiWireguardgatewaysPeersPostRequest) (WireguardPeerRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue WireguardPeerRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardPeersApiService.WireguardgatewaysPeersPost") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways/{gatewayId}/peers" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.wireguardPeerCreate == nil { + return localVarReturnValue, nil, reportError("wireguardPeerCreate 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.wireguardPeerCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysPeersPost", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + +type ApiWireguardgatewaysPeersPutRequest struct { + ctx _context.Context + ApiService *WireguardPeersApiService + gatewayId string + peerId string + wireguardPeerEnsure *WireguardPeerEnsure +} + +func (r ApiWireguardgatewaysPeersPutRequest) WireguardPeerEnsure(wireguardPeerEnsure WireguardPeerEnsure) ApiWireguardgatewaysPeersPutRequest { + r.wireguardPeerEnsure = &wireguardPeerEnsure + return r +} + +func (r ApiWireguardgatewaysPeersPutRequest) Execute() (WireguardPeerRead, *APIResponse, error) { + return r.ApiService.WireguardgatewaysPeersPutExecute(r) +} + +/* + - WireguardgatewaysPeersPut Ensure WireguardPeer + - Ensures that the WireguardPeer with the provided ID is created or modified. + +The full WireguardPeer needs to be provided to ensure +(either update or create) the WireguardPeer. Non present data will +only be filled with defaults or left empty, but not take +previous values into consideration. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param gatewayId The ID (UUID) of the WireguardGateway. + - @param peerId The ID (UUID) of the WireguardPeer. + - @return ApiWireguardgatewaysPeersPutRequest +*/ +func (a *WireguardPeersApiService) WireguardgatewaysPeersPut(ctx _context.Context, gatewayId string, peerId string) ApiWireguardgatewaysPeersPutRequest { + return ApiWireguardgatewaysPeersPutRequest{ + ApiService: a, + ctx: ctx, + gatewayId: gatewayId, + peerId: peerId, + } +} + +/* + * Execute executes the request + * @return WireguardPeerRead + */ +func (a *WireguardPeersApiService) WireguardgatewaysPeersPutExecute(r ApiWireguardgatewaysPeersPutRequest) (WireguardPeerRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue WireguardPeerRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WireguardPeersApiService.WireguardgatewaysPeersPut") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/wireguardgateways/{gatewayId}/peers/{peerId}" + localVarPath = strings.Replace(localVarPath, "{"+"gatewayId"+"}", _neturl.PathEscape(parameterToString(r.gatewayId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"peerId"+"}", _neturl.PathEscape(parameterToString(r.peerId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.wireguardPeerEnsure == nil { + return localVarReturnValue, nil, reportError("wireguardPeerEnsure 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.wireguardPeerEnsure + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "WireguardgatewaysPeersPut", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/client.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/client.go new file mode 100644 index 000000000..de6613fe1 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/client.go @@ -0,0 +1,752 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "bytes" + "context" + "crypto/sha256" + "crypto/tls" + "crypto/x509" + "encoding/hex" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "mime/multipart" + "net" + "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\.[^;]+|problem\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) +) + +const ( + RequestStatusQueued = "QUEUED" + RequestStatusRunning = "RUNNING" + RequestStatusFailed = "FAILED" + RequestStatusDone = "DONE" + + Version = "v1.0.1" +) + +// APIClient manages communication with the VPN Gateways 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 + + IPSecGatewaysApi *IPSecGatewaysApiService + + IPSecTunnelsApi *IPSecTunnelsApiService + + WireguardGatewaysApi *WireguardGatewaysApiService + + WireguardPeersApi *WireguardPeersApiService +} + +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 + } + //enable certificate pinning if the env variable is set + pkFingerprint := os.Getenv(IonosPinnedCertEnvVar) + if pkFingerprint != "" { + httpTransport := &http.Transport{} + AddPinnedCert(httpTransport, pkFingerprint) + cfg.HTTPClient.Transport = httpTransport + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.IPSecGatewaysApi = (*IPSecGatewaysApiService)(&c.common) + c.IPSecTunnelsApi = (*IPSecTunnelsApiService)(&c.common) + c.WireguardGatewaysApi = (*WireguardGatewaysApiService)(&c.common) + c.WireguardPeersApi = (*WireguardPeersApiService)(&c.common) + + return c +} + +// AddPinnedCert - enables pinning of the sha256 public fingerprint to the http client's transport +func AddPinnedCert(transport *http.Transport, pkFingerprint string) { + if pkFingerprint != "" { + transport.DialTLSContext = addPinnedCertVerification([]byte(pkFingerprint), new(tls.Config)) + } +} + +// TLSDial can be assigned to a http.Transport's DialTLS field. +type TLSDial func(ctx context.Context, network, addr string) (net.Conn, error) + +// addPinnedCertVerification returns a TLSDial function which checks that +// the remote server provides a certificate whose SHA256 fingerprint matches +// the provided value. +// +// The returned dialer function can be plugged into a http.Transport's DialTLS +// field to allow for certificate pinning. +func addPinnedCertVerification(fingerprint []byte, tlsConfig *tls.Config) TLSDial { + return func(ctx context.Context, network, addr string) (net.Conn, error) { + //fingerprints can be added with ':', we need to trim + fingerprint = bytes.ReplaceAll(fingerprint, []byte(":"), []byte("")) + fingerprint = bytes.ReplaceAll(fingerprint, []byte(" "), []byte("")) + //we are manually checking a certificate, so we need to enable insecure + tlsConfig.InsecureSkipVerify = true + + // Dial the connection to get certificates to check + conn, err := tls.Dial(network, addr, tlsConfig) + if err != nil { + return nil, err + } + + if err := verifyPinnedCert(fingerprint, conn.ConnectionState().PeerCertificates); err != nil { + _ = conn.Close() + return nil, err + } + + return conn, nil + } +} + +// verifyPinnedCert iterates the list of peer certificates and attempts to +// locate a certificate that is not a CA and whose public key fingerprint matches pkFingerprint. +func verifyPinnedCert(pkFingerprint []byte, peerCerts []*x509.Certificate) error { + for _, cert := range peerCerts { + fingerprint := sha256.Sum256(cert.Raw) + + var bytesFingerPrint = make([]byte, hex.EncodedLen(len(fingerprint[:]))) + hex.Encode(bytesFingerPrint, fingerprint[:]) + + // we have a match, and it's not an authority certificate + if cert.IsCA == false && bytes.EqualFold(bytesFingerPrint, pkFingerprint) { + return nil + } + } + + return fmt.Errorf("remote server presented a certificate which does not match the provided fingerprint") +} + +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 insenstive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.ToLower(a) == strings.ToLower(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 +} + +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string + + switch collectionFormat { + case "pipes": + delimiter = "|" + case "ssv": + delimiter = " " + case "tsv": + delimiter = "\t" + case "csv": + delimiter = "," + } + + if reflect.TypeOf(obj).Kind() == reflect.Slice { + return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") + } else if t, ok := obj.(time.Time); ok { + return t.Format(time.RFC3339) + } + + return fmt.Sprintf("%v", obj) +} + +// 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, time.Duration, error) { + retryCount := 0 + + var resp *http.Response + var httpRequestTime time.Duration + var err error + + for { + + retryCount++ + + /* we need to clone the request with every retry time because Body closes after the request */ + var clonedRequest *http.Request = request.Clone(request.Context()) + if request.Body != nil { + clonedRequest.Body, err = request.GetBody() + if err != nil { + return nil, httpRequestTime, err + } + } + + if c.cfg.Debug || c.cfg.LogLevel.Satisfies(Trace) { + dump, err := httputil.DumpRequestOut(clonedRequest, true) + if err == nil { + c.cfg.Logger.Printf(" DumpRequestOut : %s\n", string(dump)) + } else { + c.cfg.Logger.Printf(" DumpRequestOut err: %+v", err) + } + c.cfg.Logger.Printf("\n try no: %d\n", retryCount) + } + + httpRequestStartTime := time.Now() + clonedRequest.Close = true + resp, err = c.cfg.HTTPClient.Do(clonedRequest) + httpRequestTime = time.Since(httpRequestStartTime) + if err != nil { + return resp, httpRequestTime, err + } + + if c.cfg.Debug || c.cfg.LogLevel.Satisfies(Trace) { + dump, err := httputil.DumpResponse(resp, true) + if err == nil { + c.cfg.Logger.Printf("\n DumpResponse : %s\n", string(dump)) + } else { + c.cfg.Logger.Printf(" DumpResponse err %+v", err) + } + } + + var backoffTime time.Duration + + switch resp.StatusCode { + case http.StatusServiceUnavailable, + http.StatusGatewayTimeout, + http.StatusBadGateway: + if request.Method == http.MethodPost { + return resp, httpRequestTime, err + } + backoffTime = c.GetConfig().WaitTime + + case http.StatusTooManyRequests: + if retryAfterSeconds := resp.Header.Get("Retry-After"); retryAfterSeconds != "" { + waitTime, err := time.ParseDuration(retryAfterSeconds + "s") + if err != nil { + return resp, httpRequestTime, err + } + backoffTime = waitTime + } else { + backoffTime = c.GetConfig().WaitTime + } + default: + return resp, httpRequestTime, err + + } + + if retryCount >= c.GetConfig().MaxRetries { + if c.cfg.Debug || c.cfg.LogLevel.Satisfies(Debug) { + c.cfg.Logger.Printf(" Number of maximum retries exceeded (%d retries)\n", c.cfg.MaxRetries) + } + break + } else { + c.backOff(request.Context(), backoffTime) + } + } + + return resp, httpRequestTime, err +} + +func (c *APIClient) backOff(ctx context.Context, t time.Duration) { + if t > c.GetConfig().MaxWaitTime { + t = c.GetConfig().MaxWaitTime + } + if c.cfg.Debug || c.cfg.LogLevel.Satisfies(Debug) { + c.cfg.Logger.Printf(" Sleeping %s before retrying request\n", t.String()) + } + if t <= 0 { + return + } + + timer := time.NewTimer(t) + defer timer.Stop() + + select { + case <-ctx.Done(): + case <-timer.C: + } +} + +// 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 +} + +// 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, + formFileName string, + fileName string, + fileBytes []byte) (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(fileBytes) > 0 && fileName != "") { + 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) + } + } + } + if len(fileBytes) > 0 && fileName != "" { + w.Boundary() + //_, fileNm := filepath.Split(fileName) + part, err := w.CreateFormFile(formFileName, filepath.Base(fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(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() + /* adding default query params */ + for k, v := range c.cfg.DefaultQueryParams { + if _, ok := queryParams[k]; !ok { + queryParams[k] = v + } + } + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = query.Encode() + + // 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.Set(h, v) + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if c.cfg.Token != "" { + localVarRequest.Header.Add("Authorization", "Bearer "+c.cfg.Token) + } else { + if c.cfg.Username != "" { + localVarRequest.SetBasicAuth(c.cfg.Username, c.cfg.Password) + } + } + + 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) + } + + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer "+auth) + } + + } + + 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 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 fmt.Errorf("undefined response type for content %s", contentType) +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + 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...) +} + +// 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 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) { + err = xml.NewEncoder(bodyBuf).Encode(body) + } + + 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 { + statusCode int + body []byte + error string + model interface{} +} + +// NewGenericOpenAPIError - constructor for GenericOpenAPIError +func NewGenericOpenAPIError(message string, body []byte, model interface{}, statusCode int) *GenericOpenAPIError { + return &GenericOpenAPIError{ + statusCode: statusCode, + body: body, + error: message, + model: model, + } +} + +// Error returns non-empty string if there was an error. +func (e GenericOpenAPIError) Error() string { + return e.error +} + +// SetError sets the error string +func (e *GenericOpenAPIError) SetError(error string) { + e.error = error +} + +// Body returns the raw bytes of the response +func (e GenericOpenAPIError) Body() []byte { + return e.body +} + +// SetBody sets the raw body of the error +func (e *GenericOpenAPIError) SetBody(body []byte) { + e.body = body +} + +// Model returns the unpacked model of the error +func (e GenericOpenAPIError) Model() interface{} { + return e.model +} + +// SetModel sets the model of the error +func (e *GenericOpenAPIError) SetModel(model interface{}) { + e.model = model +} + +// StatusCode returns the status code of the error +func (e GenericOpenAPIError) StatusCode() int { + return e.statusCode +} + +// SetStatusCode sets the status code of the error +func (e *GenericOpenAPIError) SetStatusCode(statusCode int) { + e.statusCode = statusCode +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/configuration.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/configuration.go new file mode 100644 index 000000000..3ee08e13a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/configuration.go @@ -0,0 +1,328 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "context" + "fmt" + "net/http" + "net/url" + "os" + "strings" + "time" +) + +const ( + IonosUsernameEnvVar = "IONOS_USERNAME" + IonosPasswordEnvVar = "IONOS_PASSWORD" + IonosTokenEnvVar = "IONOS_TOKEN" + IonosApiUrlEnvVar = "IONOS_API_URL" + IonosPinnedCertEnvVar = "IONOS_PINNED_CERT" + IonosLogLevelEnvVar = "IONOS_LOG_LEVEL" + DefaultIonosServerUrl = "https://vpn.de-fra.ionos.com" + DefaultIonosBasePath = "" + defaultMaxRetries = 3 + defaultWaitTime = time.Duration(100) * time.Millisecond + defaultMaxWaitTime = time.Duration(2000) * time.Millisecond +) + +var ( + IonosServerUrls = []string{ + "https://vpn.de-fra.ionos.com", + "https://vpn.de-txl.ionos.com", + "https://vpn.es-vit.ionos.com", + "https://vpn.gb-lhr.ionos.com", + "https://vpn.us-ewr.ionos.com", + "https://vpn.us-las.ionos.com", + "https://vpn.us-mci.ionos.com", + "https://vpn.fr-par.ionos.com", + } +) + +// 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") + + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + // ContextAPIKeys takes a string apikey as authentication for the request + ContextAPIKeys = contextKey("apiKeys") + + // ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request. + ContextHttpSignatureAuth = contextKey("httpsignature") + + // 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"` + DefaultQueryParams url.Values `json:"defaultQueryParams,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + Debug bool `json:"debug,omitempty"` + Servers ServerConfigurations + OperationServers map[string]ServerConfigurations + HTTPClient *http.Client + LogLevel LogLevel + Logger Logger + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Token string `json:"token,omitempty"` + MaxRetries int `json:"maxRetries,omitempty"` + WaitTime time.Duration `json:"waitTime,omitempty"` + MaxWaitTime time.Duration `json:"maxWaitTime,omitempty"` +} + +// NewConfiguration returns a new Configuration object +func NewConfiguration(username, password, token, hostUrl string) *Configuration { + cfg := &Configuration{ + DefaultHeader: make(map[string]string), + DefaultQueryParams: url.Values{}, + UserAgent: "ionos-cloud-sdk-go-vpn/vv1.0.1", + Debug: false, + Username: username, + Password: password, + Token: token, + MaxRetries: defaultMaxRetries, + MaxWaitTime: defaultMaxWaitTime, + WaitTime: defaultWaitTime, + Logger: NewDefaultLogger(), + LogLevel: getLogLevelFromEnv(), + Servers: ServerConfigurations{ + { + URL: getServerUrl(hostUrl), + Description: "Production de-fra", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production de-txl", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production es-vit", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production gb-lhr", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production us-ewr", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production us-las", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production us-mci", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production fr-par", + }, + }, + OperationServers: map[string]ServerConfigurations{}, + } + return cfg +} + +func NewConfigurationFromEnv() *Configuration { + return NewConfiguration(os.Getenv(IonosUsernameEnvVar), os.Getenv(IonosPasswordEnvVar), os.Getenv(IonosTokenEnvVar), os.Getenv(IonosApiUrlEnvVar)) +} + +// 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 +} + +func (c *Configuration) AddDefaultQueryParam(key string, value string) { + c.DefaultQueryParams[key] = []string{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) +} + +func getServerUrl(serverUrl string) string { + if serverUrl == "" { + return DefaultIonosServerUrl + } + // Support both HTTPS & HTTP schemas + if !strings.HasPrefix(serverUrl, "https://") && !strings.HasPrefix(serverUrl, "http://") { + serverUrl = fmt.Sprintf("https://%s", serverUrl) + } + if !strings.HasSuffix(serverUrl, DefaultIonosBasePath) { + serverUrl = fmt.Sprintf("%s%s", serverUrl, DefaultIonosBasePath) + } + return serverUrl +} + +// 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/vendor/github.com/ionos-cloud/sdk-go-vpn/logger.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/logger.go new file mode 100644 index 000000000..0859a9da4 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/logger.go @@ -0,0 +1,81 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "log" + "os" + "strings" +) + +type LogLevel uint + +func (l *LogLevel) Get() LogLevel { + if l != nil { + return *l + } + return Off +} + +// Satisfies returns true if this LogLevel is at least high enough for v +func (l *LogLevel) Satisfies(v LogLevel) bool { + return l.Get() >= v +} + +const ( + Off LogLevel = 0x100 * iota + Debug + // Trace We recommend you only set this field for debugging purposes. + // Disable it in your production environments because it can log sensitive data. + // It logs the full request and response without encryption, even for an HTTPS call. + // Verbose request and response logging can also significantly impact your application's performance. + Trace +) + +var LogLevelMap = map[string]LogLevel{ + "off": Off, + "debug": Debug, + "trace": Trace, +} + +// getLogLevelFromEnv - gets LogLevel type from env variable IONOS_LOG_LEVEL +// returns Off if an invalid log level is encountered +func getLogLevelFromEnv() LogLevel { + strLogLevel := "off" + if os.Getenv(IonosLogLevelEnvVar) != "" { + strLogLevel = os.Getenv(IonosLogLevelEnvVar) + } + + logLevel, ok := LogLevelMap[strings.ToLower(strLogLevel)] + if !ok { + log.Printf("Cannot set logLevel for value: %s, setting loglevel to Off", strLogLevel) + } + return logLevel +} + +type Logger interface { + Printf(format string, args ...interface{}) +} + +func NewDefaultLogger() Logger { + return &defaultLogger{ + logger: log.New(os.Stderr, "IONOSLOG ", log.LstdFlags), + } +} + +type defaultLogger struct { + logger *log.Logger +} + +func (l defaultLogger) Printf(format string, args ...interface{}) { + l.logger.Printf(format, args...) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_connection.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_connection.go new file mode 100644 index 000000000..c45c6d25d --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_connection.go @@ -0,0 +1,259 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Connection Details about the network connection for your VPN Gateway. +type Connection struct { + // The datacenter to connect your VPN Gateway to. + DatacenterId *string `json:"datacenterId"` + // The numeric LAN ID to connect your VPN Gateway to. + LanId *string `json:"lanId"` + // Describes a range of IP V4 addresses in CIDR notation. + Ipv4CIDR *string `json:"ipv4CIDR"` + // Describes a range of IP V6 addresses in CIDR notation. + Ipv6CIDR *string `json:"ipv6CIDR,omitempty"` +} + +// NewConnection instantiates a new Connection 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 NewConnection(datacenterId string, lanId string, ipv4CIDR string) *Connection { + this := Connection{} + + this.DatacenterId = &datacenterId + this.LanId = &lanId + this.Ipv4CIDR = &ipv4CIDR + + return &this +} + +// NewConnectionWithDefaults instantiates a new Connection 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 NewConnectionWithDefaults() *Connection { + this := Connection{} + return &this +} + +// GetDatacenterId returns the DatacenterId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Connection) GetDatacenterId() *string { + if o == nil { + return nil + } + + return o.DatacenterId + +} + +// GetDatacenterIdOk returns a tuple with the DatacenterId 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 *Connection) GetDatacenterIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DatacenterId, true +} + +// SetDatacenterId sets field value +func (o *Connection) SetDatacenterId(v string) { + + o.DatacenterId = &v + +} + +// HasDatacenterId returns a boolean if a field has been set. +func (o *Connection) HasDatacenterId() bool { + if o != nil && o.DatacenterId != nil { + return true + } + + return false +} + +// GetLanId returns the LanId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Connection) GetLanId() *string { + if o == nil { + return nil + } + + return o.LanId + +} + +// GetLanIdOk returns a tuple with the LanId 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 *Connection) GetLanIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LanId, true +} + +// SetLanId sets field value +func (o *Connection) SetLanId(v string) { + + o.LanId = &v + +} + +// HasLanId returns a boolean if a field has been set. +func (o *Connection) HasLanId() bool { + if o != nil && o.LanId != nil { + return true + } + + return false +} + +// GetIpv4CIDR returns the Ipv4CIDR field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Connection) GetIpv4CIDR() *string { + if o == nil { + return nil + } + + return o.Ipv4CIDR + +} + +// GetIpv4CIDROk returns a tuple with the Ipv4CIDR 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 *Connection) GetIpv4CIDROk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Ipv4CIDR, true +} + +// SetIpv4CIDR sets field value +func (o *Connection) SetIpv4CIDR(v string) { + + o.Ipv4CIDR = &v + +} + +// HasIpv4CIDR returns a boolean if a field has been set. +func (o *Connection) HasIpv4CIDR() bool { + if o != nil && o.Ipv4CIDR != nil { + return true + } + + return false +} + +// GetIpv6CIDR returns the Ipv6CIDR field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Connection) GetIpv6CIDR() *string { + if o == nil { + return nil + } + + return o.Ipv6CIDR + +} + +// GetIpv6CIDROk returns a tuple with the Ipv6CIDR 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 *Connection) GetIpv6CIDROk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Ipv6CIDR, true +} + +// SetIpv6CIDR sets field value +func (o *Connection) SetIpv6CIDR(v string) { + + o.Ipv6CIDR = &v + +} + +// HasIpv6CIDR returns a boolean if a field has been set. +func (o *Connection) HasIpv6CIDR() bool { + if o != nil && o.Ipv6CIDR != nil { + return true + } + + return false +} + +func (o Connection) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.DatacenterId != nil { + toSerialize["datacenterId"] = o.DatacenterId + } + + if o.LanId != nil { + toSerialize["lanId"] = o.LanId + } + + if o.Ipv4CIDR != nil { + toSerialize["ipv4CIDR"] = o.Ipv4CIDR + } + + if o.Ipv6CIDR != nil { + toSerialize["ipv6CIDR"] = o.Ipv6CIDR + } + + return json.Marshal(toSerialize) +} + +type NullableConnection struct { + value *Connection + isSet bool +} + +func (v NullableConnection) Get() *Connection { + return v.value +} + +func (v *NullableConnection) Set(val *Connection) { + v.value = val + v.isSet = true +} + +func (v NullableConnection) IsSet() bool { + return v.isSet +} + +func (v *NullableConnection) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableConnection(val *Connection) *NullableConnection { + return &NullableConnection{value: val, isSet: true} +} + +func (v NullableConnection) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableConnection) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_error.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_error.go new file mode 100644 index 000000000..9afa2ff15 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_error.go @@ -0,0 +1,167 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Error The Error object is used to represent an error response from the API. +type Error struct { + // The HTTP status code of the operation. + HttpStatus *int32 `json:"httpStatus,omitempty"` + // A list of error messages. + Messages *[]ErrorMessages `json:"messages,omitempty"` +} + +// NewError instantiates a new Error 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 NewError() *Error { + this := Error{} + + return &this +} + +// NewErrorWithDefaults instantiates a new Error 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 NewErrorWithDefaults() *Error { + this := Error{} + return &this +} + +// GetHttpStatus returns the HttpStatus field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *Error) GetHttpStatus() *int32 { + if o == nil { + return nil + } + + return o.HttpStatus + +} + +// GetHttpStatusOk returns a tuple with the HttpStatus 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 *Error) GetHttpStatusOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.HttpStatus, true +} + +// SetHttpStatus sets field value +func (o *Error) SetHttpStatus(v int32) { + + o.HttpStatus = &v + +} + +// HasHttpStatus returns a boolean if a field has been set. +func (o *Error) HasHttpStatus() bool { + if o != nil && o.HttpStatus != nil { + return true + } + + return false +} + +// GetMessages returns the Messages field value +// If the value is explicit nil, the zero value for []ErrorMessages will be returned +func (o *Error) GetMessages() *[]ErrorMessages { + if o == nil { + return nil + } + + return o.Messages + +} + +// GetMessagesOk returns a tuple with the Messages 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 *Error) GetMessagesOk() (*[]ErrorMessages, bool) { + if o == nil { + return nil, false + } + + return o.Messages, true +} + +// SetMessages sets field value +func (o *Error) SetMessages(v []ErrorMessages) { + + o.Messages = &v + +} + +// HasMessages returns a boolean if a field has been set. +func (o *Error) HasMessages() bool { + if o != nil && o.Messages != nil { + return true + } + + return false +} + +func (o Error) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.HttpStatus != nil { + toSerialize["httpStatus"] = o.HttpStatus + } + + if o.Messages != nil { + toSerialize["messages"] = o.Messages + } + + return json.Marshal(toSerialize) +} + +type NullableError struct { + value *Error + isSet bool +} + +func (v NullableError) Get() *Error { + return v.value +} + +func (v *NullableError) Set(val *Error) { + v.value = val + v.isSet = true +} + +func (v NullableError) IsSet() bool { + return v.isSet +} + +func (v *NullableError) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableError(val *Error) *NullableError { + return &NullableError{value: val, isSet: true} +} + +func (v NullableError) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableError) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_error_messages.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_error_messages.go new file mode 100644 index 000000000..1f22b696e --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_error_messages.go @@ -0,0 +1,167 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ErrorMessages struct for ErrorMessages +type ErrorMessages struct { + // Application internal error code + ErrorCode *string `json:"errorCode,omitempty"` + // A human readable explanation specific to this occurrence of the problem. + Message *string `json:"message,omitempty"` +} + +// NewErrorMessages instantiates a new ErrorMessages 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 NewErrorMessages() *ErrorMessages { + this := ErrorMessages{} + + return &this +} + +// NewErrorMessagesWithDefaults instantiates a new ErrorMessages 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 NewErrorMessagesWithDefaults() *ErrorMessages { + this := ErrorMessages{} + return &this +} + +// GetErrorCode returns the ErrorCode field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ErrorMessages) GetErrorCode() *string { + if o == nil { + return nil + } + + return o.ErrorCode + +} + +// GetErrorCodeOk returns a tuple with the ErrorCode 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 *ErrorMessages) GetErrorCodeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ErrorCode, true +} + +// SetErrorCode sets field value +func (o *ErrorMessages) SetErrorCode(v string) { + + o.ErrorCode = &v + +} + +// HasErrorCode returns a boolean if a field has been set. +func (o *ErrorMessages) HasErrorCode() bool { + if o != nil && o.ErrorCode != nil { + return true + } + + return false +} + +// GetMessage returns the Message field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ErrorMessages) GetMessage() *string { + if o == nil { + return nil + } + + return o.Message + +} + +// GetMessageOk returns a tuple with the Message 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 *ErrorMessages) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Message, true +} + +// SetMessage sets field value +func (o *ErrorMessages) SetMessage(v string) { + + o.Message = &v + +} + +// HasMessage returns a boolean if a field has been set. +func (o *ErrorMessages) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +func (o ErrorMessages) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.ErrorCode != nil { + toSerialize["errorCode"] = o.ErrorCode + } + + if o.Message != nil { + toSerialize["message"] = o.Message + } + + return json.Marshal(toSerialize) +} + +type NullableErrorMessages struct { + value *ErrorMessages + isSet bool +} + +func (v NullableErrorMessages) Get() *ErrorMessages { + return v.value +} + +func (v *NullableErrorMessages) Set(val *ErrorMessages) { + v.value = val + v.isSet = true +} + +func (v NullableErrorMessages) IsSet() bool { + return v.isSet +} + +func (v *NullableErrorMessages) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableErrorMessages(val *ErrorMessages) *NullableErrorMessages { + return &NullableErrorMessages{value: val, isSet: true} +} + +func (v NullableErrorMessages) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableErrorMessages) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_esp_encryption.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_esp_encryption.go new file mode 100644 index 000000000..0ff83e0c0 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_esp_encryption.go @@ -0,0 +1,260 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ESPEncryption Settings for the IPSec SA (ESP) phase. +type ESPEncryption struct { + // The Diffie-Hellman Group to use for IPSec Encryption.\\ Options: - 15-MODP3072 - 16-MODP4096 - 19-ECP256 - 20-ECP384 - 21-ECP521 - 28-ECP256BP - 29-ECP384BP - 30-ECP512BP + DiffieHellmanGroup *string `json:"diffieHellmanGroup,omitempty"` + // The encryption algorithm to use for IPSec Encryption.\\ Options: - AES128-CTR - AES256-CTR - AES128-GCM-16 - AES256-GCM-16 - AES128-GCM-12 - AES256-GCM-12 - AES128-CCM-12 - AES256-CCM-12 - AES128 - AES256 + EncryptionAlgorithm *string `json:"encryptionAlgorithm,omitempty"` + // The integrity algorithm to use for IPSec Encryption.\\ Options: - SHA256 - SHA384 - SHA512 - AES-XCBC + IntegrityAlgorithm *string `json:"integrityAlgorithm,omitempty"` + // The phase lifetime in seconds. + Lifetime *int32 `json:"lifetime,omitempty"` +} + +// NewESPEncryption instantiates a new ESPEncryption 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 NewESPEncryption() *ESPEncryption { + this := ESPEncryption{} + + var lifetime int32 = 3600 + this.Lifetime = &lifetime + + return &this +} + +// NewESPEncryptionWithDefaults instantiates a new ESPEncryption 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 NewESPEncryptionWithDefaults() *ESPEncryption { + this := ESPEncryption{} + var lifetime int32 = 3600 + this.Lifetime = &lifetime + return &this +} + +// GetDiffieHellmanGroup returns the DiffieHellmanGroup field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ESPEncryption) GetDiffieHellmanGroup() *string { + if o == nil { + return nil + } + + return o.DiffieHellmanGroup + +} + +// GetDiffieHellmanGroupOk returns a tuple with the DiffieHellmanGroup 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 *ESPEncryption) GetDiffieHellmanGroupOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DiffieHellmanGroup, true +} + +// SetDiffieHellmanGroup sets field value +func (o *ESPEncryption) SetDiffieHellmanGroup(v string) { + + o.DiffieHellmanGroup = &v + +} + +// HasDiffieHellmanGroup returns a boolean if a field has been set. +func (o *ESPEncryption) HasDiffieHellmanGroup() bool { + if o != nil && o.DiffieHellmanGroup != nil { + return true + } + + return false +} + +// GetEncryptionAlgorithm returns the EncryptionAlgorithm field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ESPEncryption) GetEncryptionAlgorithm() *string { + if o == nil { + return nil + } + + return o.EncryptionAlgorithm + +} + +// GetEncryptionAlgorithmOk returns a tuple with the EncryptionAlgorithm 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 *ESPEncryption) GetEncryptionAlgorithmOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.EncryptionAlgorithm, true +} + +// SetEncryptionAlgorithm sets field value +func (o *ESPEncryption) SetEncryptionAlgorithm(v string) { + + o.EncryptionAlgorithm = &v + +} + +// HasEncryptionAlgorithm returns a boolean if a field has been set. +func (o *ESPEncryption) HasEncryptionAlgorithm() bool { + if o != nil && o.EncryptionAlgorithm != nil { + return true + } + + return false +} + +// GetIntegrityAlgorithm returns the IntegrityAlgorithm field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ESPEncryption) GetIntegrityAlgorithm() *string { + if o == nil { + return nil + } + + return o.IntegrityAlgorithm + +} + +// GetIntegrityAlgorithmOk returns a tuple with the IntegrityAlgorithm 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 *ESPEncryption) GetIntegrityAlgorithmOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.IntegrityAlgorithm, true +} + +// SetIntegrityAlgorithm sets field value +func (o *ESPEncryption) SetIntegrityAlgorithm(v string) { + + o.IntegrityAlgorithm = &v + +} + +// HasIntegrityAlgorithm returns a boolean if a field has been set. +func (o *ESPEncryption) HasIntegrityAlgorithm() bool { + if o != nil && o.IntegrityAlgorithm != nil { + return true + } + + return false +} + +// GetLifetime returns the Lifetime field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *ESPEncryption) GetLifetime() *int32 { + if o == nil { + return nil + } + + return o.Lifetime + +} + +// GetLifetimeOk returns a tuple with the Lifetime 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 *ESPEncryption) GetLifetimeOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Lifetime, true +} + +// SetLifetime sets field value +func (o *ESPEncryption) SetLifetime(v int32) { + + o.Lifetime = &v + +} + +// HasLifetime returns a boolean if a field has been set. +func (o *ESPEncryption) HasLifetime() bool { + if o != nil && o.Lifetime != nil { + return true + } + + return false +} + +func (o ESPEncryption) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.DiffieHellmanGroup != nil { + toSerialize["diffieHellmanGroup"] = o.DiffieHellmanGroup + } + + if o.EncryptionAlgorithm != nil { + toSerialize["encryptionAlgorithm"] = o.EncryptionAlgorithm + } + + if o.IntegrityAlgorithm != nil { + toSerialize["integrityAlgorithm"] = o.IntegrityAlgorithm + } + + if o.Lifetime != nil { + toSerialize["lifetime"] = o.Lifetime + } + + return json.Marshal(toSerialize) +} + +type NullableESPEncryption struct { + value *ESPEncryption + isSet bool +} + +func (v NullableESPEncryption) Get() *ESPEncryption { + return v.value +} + +func (v *NullableESPEncryption) Set(val *ESPEncryption) { + v.value = val + v.isSet = true +} + +func (v NullableESPEncryption) IsSet() bool { + return v.isSet +} + +func (v *NullableESPEncryption) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableESPEncryption(val *ESPEncryption) *NullableESPEncryption { + return &NullableESPEncryption{value: val, isSet: true} +} + +func (v NullableESPEncryption) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableESPEncryption) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ike_encryption.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ike_encryption.go new file mode 100644 index 000000000..0463098f4 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ike_encryption.go @@ -0,0 +1,260 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IKEEncryption Settings for the initial security exchange phase. +type IKEEncryption struct { + // The Diffie-Hellman Group to use for IPSec Encryption.\\ Options: - 15-MODP3072 - 16-MODP4096 - 19-ECP256 - 20-ECP384 - 21-ECP521 - 28-ECP256BP - 29-ECP384BP - 30-ECP512BP + DiffieHellmanGroup *string `json:"diffieHellmanGroup,omitempty"` + // The encryption algorithm to use for IPSec Encryption.\\ Options: - AES128-CTR - AES256-CTR - AES128-GCM-16 - AES256-GCM-16 - AES128-GCM-12 - AES256-GCM-12 - AES128-CCM-12 - AES256-CCM-12 - AES128 - AES256 + EncryptionAlgorithm *string `json:"encryptionAlgorithm,omitempty"` + // The integrity algorithm to use for IPSec Encryption.\\ Options: - SHA256 - SHA384 - SHA512 - AES-XCBC + IntegrityAlgorithm *string `json:"integrityAlgorithm,omitempty"` + // The phase lifetime in seconds. + Lifetime *int32 `json:"lifetime,omitempty"` +} + +// NewIKEEncryption instantiates a new IKEEncryption 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 NewIKEEncryption() *IKEEncryption { + this := IKEEncryption{} + + var lifetime int32 = 86400 + this.Lifetime = &lifetime + + return &this +} + +// NewIKEEncryptionWithDefaults instantiates a new IKEEncryption 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 NewIKEEncryptionWithDefaults() *IKEEncryption { + this := IKEEncryption{} + var lifetime int32 = 86400 + this.Lifetime = &lifetime + return &this +} + +// GetDiffieHellmanGroup returns the DiffieHellmanGroup field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IKEEncryption) GetDiffieHellmanGroup() *string { + if o == nil { + return nil + } + + return o.DiffieHellmanGroup + +} + +// GetDiffieHellmanGroupOk returns a tuple with the DiffieHellmanGroup 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 *IKEEncryption) GetDiffieHellmanGroupOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DiffieHellmanGroup, true +} + +// SetDiffieHellmanGroup sets field value +func (o *IKEEncryption) SetDiffieHellmanGroup(v string) { + + o.DiffieHellmanGroup = &v + +} + +// HasDiffieHellmanGroup returns a boolean if a field has been set. +func (o *IKEEncryption) HasDiffieHellmanGroup() bool { + if o != nil && o.DiffieHellmanGroup != nil { + return true + } + + return false +} + +// GetEncryptionAlgorithm returns the EncryptionAlgorithm field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IKEEncryption) GetEncryptionAlgorithm() *string { + if o == nil { + return nil + } + + return o.EncryptionAlgorithm + +} + +// GetEncryptionAlgorithmOk returns a tuple with the EncryptionAlgorithm 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 *IKEEncryption) GetEncryptionAlgorithmOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.EncryptionAlgorithm, true +} + +// SetEncryptionAlgorithm sets field value +func (o *IKEEncryption) SetEncryptionAlgorithm(v string) { + + o.EncryptionAlgorithm = &v + +} + +// HasEncryptionAlgorithm returns a boolean if a field has been set. +func (o *IKEEncryption) HasEncryptionAlgorithm() bool { + if o != nil && o.EncryptionAlgorithm != nil { + return true + } + + return false +} + +// GetIntegrityAlgorithm returns the IntegrityAlgorithm field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IKEEncryption) GetIntegrityAlgorithm() *string { + if o == nil { + return nil + } + + return o.IntegrityAlgorithm + +} + +// GetIntegrityAlgorithmOk returns a tuple with the IntegrityAlgorithm 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 *IKEEncryption) GetIntegrityAlgorithmOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.IntegrityAlgorithm, true +} + +// SetIntegrityAlgorithm sets field value +func (o *IKEEncryption) SetIntegrityAlgorithm(v string) { + + o.IntegrityAlgorithm = &v + +} + +// HasIntegrityAlgorithm returns a boolean if a field has been set. +func (o *IKEEncryption) HasIntegrityAlgorithm() bool { + if o != nil && o.IntegrityAlgorithm != nil { + return true + } + + return false +} + +// GetLifetime returns the Lifetime field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *IKEEncryption) GetLifetime() *int32 { + if o == nil { + return nil + } + + return o.Lifetime + +} + +// GetLifetimeOk returns a tuple with the Lifetime 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 *IKEEncryption) GetLifetimeOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Lifetime, true +} + +// SetLifetime sets field value +func (o *IKEEncryption) SetLifetime(v int32) { + + o.Lifetime = &v + +} + +// HasLifetime returns a boolean if a field has been set. +func (o *IKEEncryption) HasLifetime() bool { + if o != nil && o.Lifetime != nil { + return true + } + + return false +} + +func (o IKEEncryption) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.DiffieHellmanGroup != nil { + toSerialize["diffieHellmanGroup"] = o.DiffieHellmanGroup + } + + if o.EncryptionAlgorithm != nil { + toSerialize["encryptionAlgorithm"] = o.EncryptionAlgorithm + } + + if o.IntegrityAlgorithm != nil { + toSerialize["integrityAlgorithm"] = o.IntegrityAlgorithm + } + + if o.Lifetime != nil { + toSerialize["lifetime"] = o.Lifetime + } + + return json.Marshal(toSerialize) +} + +type NullableIKEEncryption struct { + value *IKEEncryption + isSet bool +} + +func (v NullableIKEEncryption) Get() *IKEEncryption { + return v.value +} + +func (v *NullableIKEEncryption) Set(val *IKEEncryption) { + v.value = val + v.isSet = true +} + +func (v NullableIKEEncryption) IsSet() bool { + return v.isSet +} + +func (v *NullableIKEEncryption) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIKEEncryption(val *IKEEncryption) *NullableIKEEncryption { + return &NullableIKEEncryption{value: val, isSet: true} +} + +func (v NullableIKEEncryption) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIKEEncryption) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway.go new file mode 100644 index 000000000..80ec24494 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway.go @@ -0,0 +1,307 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecGateway Properties with all data needed to create a new IPSec Gateway. +type IPSecGateway struct { + // The human readable name of your IPSecGateway. + Name *string `json:"name"` + // Human readable description of the IPSecGateway. + Description *string `json:"description,omitempty"` + // Public IP address to be assigned to the gateway. __Note__: This must be an IP address in the same datacenter as the connections. + GatewayIP *string `json:"gatewayIP"` + // The network connection for your gateway. __Note__: all connections must belong to the same datacenterId. + Connections *[]Connection `json:"connections"` + // The IKE version that is permitted for the VPN tunnels.\\ Options: - IKEv2 + Version *string `json:"version,omitempty"` +} + +// NewIPSecGateway instantiates a new IPSecGateway 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 NewIPSecGateway(name string, gatewayIP string, connections []Connection) *IPSecGateway { + this := IPSecGateway{} + + this.Name = &name + this.GatewayIP = &gatewayIP + this.Connections = &connections + var version string = "IKEv2" + this.Version = &version + + return &this +} + +// NewIPSecGatewayWithDefaults instantiates a new IPSecGateway 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 NewIPSecGatewayWithDefaults() *IPSecGateway { + this := IPSecGateway{} + var version string = "IKEv2" + this.Version = &version + return &this +} + +// GetName returns the Name field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGateway) GetName() *string { + if o == nil { + return nil + } + + return o.Name + +} + +// GetNameOk returns a tuple with the Name 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 *IPSecGateway) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Name, true +} + +// SetName sets field value +func (o *IPSecGateway) SetName(v string) { + + o.Name = &v + +} + +// HasName returns a boolean if a field has been set. +func (o *IPSecGateway) HasName() bool { + if o != nil && o.Name != nil { + return true + } + + return false +} + +// GetDescription returns the Description field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGateway) GetDescription() *string { + if o == nil { + return nil + } + + return o.Description + +} + +// GetDescriptionOk returns a tuple with the Description 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 *IPSecGateway) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Description, true +} + +// SetDescription sets field value +func (o *IPSecGateway) SetDescription(v string) { + + o.Description = &v + +} + +// HasDescription returns a boolean if a field has been set. +func (o *IPSecGateway) HasDescription() bool { + if o != nil && o.Description != nil { + return true + } + + return false +} + +// GetGatewayIP returns the GatewayIP field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGateway) GetGatewayIP() *string { + if o == nil { + return nil + } + + return o.GatewayIP + +} + +// GetGatewayIPOk returns a tuple with the GatewayIP 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 *IPSecGateway) GetGatewayIPOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.GatewayIP, true +} + +// SetGatewayIP sets field value +func (o *IPSecGateway) SetGatewayIP(v string) { + + o.GatewayIP = &v + +} + +// HasGatewayIP returns a boolean if a field has been set. +func (o *IPSecGateway) HasGatewayIP() bool { + if o != nil && o.GatewayIP != nil { + return true + } + + return false +} + +// GetConnections returns the Connections field value +// If the value is explicit nil, the zero value for []Connection will be returned +func (o *IPSecGateway) GetConnections() *[]Connection { + if o == nil { + return nil + } + + return o.Connections + +} + +// GetConnectionsOk returns a tuple with the Connections 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 *IPSecGateway) GetConnectionsOk() (*[]Connection, bool) { + if o == nil { + return nil, false + } + + return o.Connections, true +} + +// SetConnections sets field value +func (o *IPSecGateway) SetConnections(v []Connection) { + + o.Connections = &v + +} + +// HasConnections returns a boolean if a field has been set. +func (o *IPSecGateway) HasConnections() bool { + if o != nil && o.Connections != nil { + return true + } + + return false +} + +// GetVersion returns the Version field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGateway) GetVersion() *string { + if o == nil { + return nil + } + + return o.Version + +} + +// GetVersionOk returns a tuple with the Version 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 *IPSecGateway) GetVersionOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Version, true +} + +// SetVersion sets field value +func (o *IPSecGateway) SetVersion(v string) { + + o.Version = &v + +} + +// HasVersion returns a boolean if a field has been set. +func (o *IPSecGateway) HasVersion() bool { + if o != nil && o.Version != nil { + return true + } + + return false +} + +func (o IPSecGateway) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Name != nil { + toSerialize["name"] = o.Name + } + + if o.Description != nil { + toSerialize["description"] = o.Description + } + + if o.GatewayIP != nil { + toSerialize["gatewayIP"] = o.GatewayIP + } + + if o.Connections != nil { + toSerialize["connections"] = o.Connections + } + + if o.Version != nil { + toSerialize["version"] = o.Version + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecGateway struct { + value *IPSecGateway + isSet bool +} + +func (v NullableIPSecGateway) Get() *IPSecGateway { + return v.value +} + +func (v *NullableIPSecGateway) Set(val *IPSecGateway) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecGateway) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecGateway) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecGateway(val *IPSecGateway) *NullableIPSecGateway { + return &NullableIPSecGateway{value: val, isSet: true} +} + +func (v NullableIPSecGateway) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecGateway) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_create.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_create.go new file mode 100644 index 000000000..ecf6239db --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_create.go @@ -0,0 +1,168 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecGatewayCreate struct for IPSecGatewayCreate +type IPSecGatewayCreate struct { + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *IPSecGateway `json:"properties"` +} + +// NewIPSecGatewayCreate instantiates a new IPSecGatewayCreate 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 NewIPSecGatewayCreate(properties IPSecGateway) *IPSecGatewayCreate { + this := IPSecGatewayCreate{} + + this.Properties = &properties + + return &this +} + +// NewIPSecGatewayCreateWithDefaults instantiates a new IPSecGatewayCreate 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 NewIPSecGatewayCreateWithDefaults() *IPSecGatewayCreate { + this := IPSecGatewayCreate{} + return &this +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *IPSecGatewayCreate) GetMetadata() *map[string]interface{} { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *IPSecGatewayCreate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *IPSecGatewayCreate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *IPSecGatewayCreate) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for IPSecGateway will be returned +func (o *IPSecGatewayCreate) GetProperties() *IPSecGateway { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *IPSecGatewayCreate) GetPropertiesOk() (*IPSecGateway, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *IPSecGatewayCreate) SetProperties(v IPSecGateway) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *IPSecGatewayCreate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o IPSecGatewayCreate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecGatewayCreate struct { + value *IPSecGatewayCreate + isSet bool +} + +func (v NullableIPSecGatewayCreate) Get() *IPSecGatewayCreate { + return v.value +} + +func (v *NullableIPSecGatewayCreate) Set(val *IPSecGatewayCreate) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecGatewayCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecGatewayCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecGatewayCreate(val *IPSecGatewayCreate) *NullableIPSecGatewayCreate { + return &NullableIPSecGatewayCreate{value: val, isSet: true} +} + +func (v NullableIPSecGatewayCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecGatewayCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_ensure.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_ensure.go new file mode 100644 index 000000000..90b67ce06 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_ensure.go @@ -0,0 +1,213 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecGatewayEnsure struct for IPSecGatewayEnsure +type IPSecGatewayEnsure struct { + // The ID (UUID) of the IPSecGateway. + Id *string `json:"id"` + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *IPSecGateway `json:"properties"` +} + +// NewIPSecGatewayEnsure instantiates a new IPSecGatewayEnsure 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 NewIPSecGatewayEnsure(id string, properties IPSecGateway) *IPSecGatewayEnsure { + this := IPSecGatewayEnsure{} + + this.Id = &id + this.Properties = &properties + + return &this +} + +// NewIPSecGatewayEnsureWithDefaults instantiates a new IPSecGatewayEnsure 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 NewIPSecGatewayEnsureWithDefaults() *IPSecGatewayEnsure { + this := IPSecGatewayEnsure{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayEnsure) GetId() *string { + if o == nil { + return nil + } + + 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 *IPSecGatewayEnsure) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *IPSecGatewayEnsure) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *IPSecGatewayEnsure) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *IPSecGatewayEnsure) GetMetadata() *map[string]interface{} { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *IPSecGatewayEnsure) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *IPSecGatewayEnsure) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *IPSecGatewayEnsure) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for IPSecGateway will be returned +func (o *IPSecGatewayEnsure) GetProperties() *IPSecGateway { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *IPSecGatewayEnsure) GetPropertiesOk() (*IPSecGateway, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *IPSecGatewayEnsure) SetProperties(v IPSecGateway) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *IPSecGatewayEnsure) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o IPSecGatewayEnsure) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecGatewayEnsure struct { + value *IPSecGatewayEnsure + isSet bool +} + +func (v NullableIPSecGatewayEnsure) Get() *IPSecGatewayEnsure { + return v.value +} + +func (v *NullableIPSecGatewayEnsure) Set(val *IPSecGatewayEnsure) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecGatewayEnsure) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecGatewayEnsure) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecGatewayEnsure(val *IPSecGatewayEnsure) *NullableIPSecGatewayEnsure { + return &NullableIPSecGatewayEnsure{value: val, isSet: true} +} + +func (v NullableIPSecGatewayEnsure) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecGatewayEnsure) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_metadata.go new file mode 100644 index 000000000..b256f5287 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_metadata.go @@ -0,0 +1,492 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// IPSecGatewayMetadata IPSec Gateway Metadata +type IPSecGatewayMetadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` + // The current status of the resource. The status can be: * `AVAILABLE` - resource exists and is healthy. * `PROVISIONING` - resource is being created or updated. * `DESTROYING` - delete command was issued, the resource is being deleted. * `FAILED`: - resource failed, details in `statusMessage`. + Status *string `json:"status"` + // The message of the failure if the status is `FAILED`. + StatusMessage *string `json:"statusMessage,omitempty"` +} + +// NewIPSecGatewayMetadata instantiates a new IPSecGatewayMetadata 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 NewIPSecGatewayMetadata(status string) *IPSecGatewayMetadata { + this := IPSecGatewayMetadata{} + + this.Status = &status + + return &this +} + +// NewIPSecGatewayMetadataWithDefaults instantiates a new IPSecGatewayMetadata 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 NewIPSecGatewayMetadataWithDefaults() *IPSecGatewayMetadata { + this := IPSecGatewayMetadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *IPSecGatewayMetadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *IPSecGatewayMetadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *IPSecGatewayMetadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayMetadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *IPSecGatewayMetadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *IPSecGatewayMetadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayMetadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *IPSecGatewayMetadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *IPSecGatewayMetadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *IPSecGatewayMetadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *IPSecGatewayMetadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *IPSecGatewayMetadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayMetadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *IPSecGatewayMetadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *IPSecGatewayMetadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayMetadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *IPSecGatewayMetadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *IPSecGatewayMetadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayMetadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *IPSecGatewayMetadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *IPSecGatewayMetadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +// GetStatus returns the Status field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayMetadata) GetStatus() *string { + if o == nil { + return nil + } + + return o.Status + +} + +// GetStatusOk returns a tuple with the Status 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 *IPSecGatewayMetadata) GetStatusOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Status, true +} + +// SetStatus sets field value +func (o *IPSecGatewayMetadata) SetStatus(v string) { + + o.Status = &v + +} + +// HasStatus returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasStatus() bool { + if o != nil && o.Status != nil { + return true + } + + return false +} + +// GetStatusMessage returns the StatusMessage field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayMetadata) GetStatusMessage() *string { + if o == nil { + return nil + } + + return o.StatusMessage + +} + +// GetStatusMessageOk returns a tuple with the StatusMessage 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 *IPSecGatewayMetadata) GetStatusMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.StatusMessage, true +} + +// SetStatusMessage sets field value +func (o *IPSecGatewayMetadata) SetStatusMessage(v string) { + + o.StatusMessage = &v + +} + +// HasStatusMessage returns a boolean if a field has been set. +func (o *IPSecGatewayMetadata) HasStatusMessage() bool { + if o != nil && o.StatusMessage != nil { + return true + } + + return false +} + +func (o IPSecGatewayMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + if o.Status != nil { + toSerialize["status"] = o.Status + } + + if o.StatusMessage != nil { + toSerialize["statusMessage"] = o.StatusMessage + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecGatewayMetadata struct { + value *IPSecGatewayMetadata + isSet bool +} + +func (v NullableIPSecGatewayMetadata) Get() *IPSecGatewayMetadata { + return v.value +} + +func (v *NullableIPSecGatewayMetadata) Set(val *IPSecGatewayMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecGatewayMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecGatewayMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecGatewayMetadata(val *IPSecGatewayMetadata) *NullableIPSecGatewayMetadata { + return &NullableIPSecGatewayMetadata{value: val, isSet: true} +} + +func (v NullableIPSecGatewayMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecGatewayMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read.go new file mode 100644 index 000000000..db98ffc23 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read.go @@ -0,0 +1,303 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecGatewayRead struct for IPSecGatewayRead +type IPSecGatewayRead struct { + // The ID (UUID) of the IPSecGateway. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the IPSecGateway. + Href *string `json:"href"` + Metadata *IPSecGatewayMetadata `json:"metadata"` + Properties *IPSecGateway `json:"properties"` +} + +// NewIPSecGatewayRead instantiates a new IPSecGatewayRead 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 NewIPSecGatewayRead(id string, type_ string, href string, metadata IPSecGatewayMetadata, properties IPSecGateway) *IPSecGatewayRead { + this := IPSecGatewayRead{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Metadata = &metadata + this.Properties = &properties + + return &this +} + +// NewIPSecGatewayReadWithDefaults instantiates a new IPSecGatewayRead 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 NewIPSecGatewayReadWithDefaults() *IPSecGatewayRead { + this := IPSecGatewayRead{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayRead) GetId() *string { + if o == nil { + return nil + } + + 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 *IPSecGatewayRead) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *IPSecGatewayRead) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *IPSecGatewayRead) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayRead) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *IPSecGatewayRead) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *IPSecGatewayRead) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *IPSecGatewayRead) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayRead) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *IPSecGatewayRead) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *IPSecGatewayRead) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *IPSecGatewayRead) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for IPSecGatewayMetadata will be returned +func (o *IPSecGatewayRead) GetMetadata() *IPSecGatewayMetadata { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *IPSecGatewayRead) GetMetadataOk() (*IPSecGatewayMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *IPSecGatewayRead) SetMetadata(v IPSecGatewayMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *IPSecGatewayRead) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for IPSecGateway will be returned +func (o *IPSecGatewayRead) GetProperties() *IPSecGateway { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *IPSecGatewayRead) GetPropertiesOk() (*IPSecGateway, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *IPSecGatewayRead) SetProperties(v IPSecGateway) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *IPSecGatewayRead) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o IPSecGatewayRead) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecGatewayRead struct { + value *IPSecGatewayRead + isSet bool +} + +func (v NullableIPSecGatewayRead) Get() *IPSecGatewayRead { + return v.value +} + +func (v *NullableIPSecGatewayRead) Set(val *IPSecGatewayRead) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecGatewayRead) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecGatewayRead) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecGatewayRead(val *IPSecGatewayRead) *NullableIPSecGatewayRead { + return &NullableIPSecGatewayRead{value: val, isSet: true} +} + +func (v NullableIPSecGatewayRead) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecGatewayRead) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read_list.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read_list.go new file mode 100644 index 000000000..db6f9c955 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read_list.go @@ -0,0 +1,393 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecGatewayReadList struct for IPSecGatewayReadList +type IPSecGatewayReadList struct { + // ID of the list of IPSecGateway resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of IPSecGateway resources. + Href *string `json:"href"` + // The list of IPSecGateway resources. + Items *[]IPSecGatewayRead `json:"items,omitempty"` + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewIPSecGatewayReadList instantiates a new IPSecGatewayReadList 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 NewIPSecGatewayReadList(id string, type_ string, href string, offset int32, limit int32, links Links) *IPSecGatewayReadList { + this := IPSecGatewayReadList{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewIPSecGatewayReadListWithDefaults instantiates a new IPSecGatewayReadList 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 NewIPSecGatewayReadListWithDefaults() *IPSecGatewayReadList { + this := IPSecGatewayReadList{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayReadList) GetId() *string { + if o == nil { + return nil + } + + 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 *IPSecGatewayReadList) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *IPSecGatewayReadList) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *IPSecGatewayReadList) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayReadList) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *IPSecGatewayReadList) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *IPSecGatewayReadList) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *IPSecGatewayReadList) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayReadList) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *IPSecGatewayReadList) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *IPSecGatewayReadList) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *IPSecGatewayReadList) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []IPSecGatewayRead will be returned +func (o *IPSecGatewayReadList) GetItems() *[]IPSecGatewayRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *IPSecGatewayReadList) GetItemsOk() (*[]IPSecGatewayRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *IPSecGatewayReadList) SetItems(v []IPSecGatewayRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *IPSecGatewayReadList) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *IPSecGatewayReadList) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *IPSecGatewayReadList) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *IPSecGatewayReadList) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *IPSecGatewayReadList) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *IPSecGatewayReadList) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *IPSecGatewayReadList) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *IPSecGatewayReadList) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *IPSecGatewayReadList) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *IPSecGatewayReadList) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *IPSecGatewayReadList) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *IPSecGatewayReadList) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *IPSecGatewayReadList) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o IPSecGatewayReadList) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecGatewayReadList struct { + value *IPSecGatewayReadList + isSet bool +} + +func (v NullableIPSecGatewayReadList) Get() *IPSecGatewayReadList { + return v.value +} + +func (v *NullableIPSecGatewayReadList) Set(val *IPSecGatewayReadList) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecGatewayReadList) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecGatewayReadList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecGatewayReadList(val *IPSecGatewayReadList) *NullableIPSecGatewayReadList { + return &NullableIPSecGatewayReadList{value: val, isSet: true} +} + +func (v NullableIPSecGatewayReadList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecGatewayReadList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read_list_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read_list_all_of.go new file mode 100644 index 000000000..b2965b72c --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_gateway_read_list_all_of.go @@ -0,0 +1,259 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecGatewayReadListAllOf struct for IPSecGatewayReadListAllOf +type IPSecGatewayReadListAllOf struct { + // ID of the list of IPSecGateway resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of IPSecGateway resources. + Href *string `json:"href"` + // The list of IPSecGateway resources. + Items *[]IPSecGatewayRead `json:"items,omitempty"` +} + +// NewIPSecGatewayReadListAllOf instantiates a new IPSecGatewayReadListAllOf 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 NewIPSecGatewayReadListAllOf(id string, type_ string, href string) *IPSecGatewayReadListAllOf { + this := IPSecGatewayReadListAllOf{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + + return &this +} + +// NewIPSecGatewayReadListAllOfWithDefaults instantiates a new IPSecGatewayReadListAllOf 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 NewIPSecGatewayReadListAllOfWithDefaults() *IPSecGatewayReadListAllOf { + this := IPSecGatewayReadListAllOf{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayReadListAllOf) GetId() *string { + if o == nil { + return nil + } + + 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 *IPSecGatewayReadListAllOf) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *IPSecGatewayReadListAllOf) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *IPSecGatewayReadListAllOf) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayReadListAllOf) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *IPSecGatewayReadListAllOf) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *IPSecGatewayReadListAllOf) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *IPSecGatewayReadListAllOf) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecGatewayReadListAllOf) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *IPSecGatewayReadListAllOf) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *IPSecGatewayReadListAllOf) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *IPSecGatewayReadListAllOf) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []IPSecGatewayRead will be returned +func (o *IPSecGatewayReadListAllOf) GetItems() *[]IPSecGatewayRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *IPSecGatewayReadListAllOf) GetItemsOk() (*[]IPSecGatewayRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *IPSecGatewayReadListAllOf) SetItems(v []IPSecGatewayRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *IPSecGatewayReadListAllOf) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +func (o IPSecGatewayReadListAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecGatewayReadListAllOf struct { + value *IPSecGatewayReadListAllOf + isSet bool +} + +func (v NullableIPSecGatewayReadListAllOf) Get() *IPSecGatewayReadListAllOf { + return v.value +} + +func (v *NullableIPSecGatewayReadListAllOf) Set(val *IPSecGatewayReadListAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecGatewayReadListAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecGatewayReadListAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecGatewayReadListAllOf(val *IPSecGatewayReadListAllOf) *NullableIPSecGatewayReadListAllOf { + return &NullableIPSecGatewayReadListAllOf{value: val, isSet: true} +} + +func (v NullableIPSecGatewayReadListAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecGatewayReadListAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_psk.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_psk.go new file mode 100644 index 000000000..e35af167a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_psk.go @@ -0,0 +1,125 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecPSK Properties with all data needed to define IPSec Authentication PSK. This is required if the method is PSK. +type IPSecPSK struct { + // The Pre-Shared Key used for IPSec Authentication. + Key *string `json:"key"` +} + +// NewIPSecPSK instantiates a new IPSecPSK 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 NewIPSecPSK(key string) *IPSecPSK { + this := IPSecPSK{} + + this.Key = &key + + return &this +} + +// NewIPSecPSKWithDefaults instantiates a new IPSecPSK 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 NewIPSecPSKWithDefaults() *IPSecPSK { + this := IPSecPSK{} + return &this +} + +// GetKey returns the Key field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecPSK) GetKey() *string { + if o == nil { + return nil + } + + return o.Key + +} + +// GetKeyOk returns a tuple with the Key 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 *IPSecPSK) GetKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Key, true +} + +// SetKey sets field value +func (o *IPSecPSK) SetKey(v string) { + + o.Key = &v + +} + +// HasKey returns a boolean if a field has been set. +func (o *IPSecPSK) HasKey() bool { + if o != nil && o.Key != nil { + return true + } + + return false +} + +func (o IPSecPSK) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Key != nil { + toSerialize["key"] = o.Key + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecPSK struct { + value *IPSecPSK + isSet bool +} + +func (v NullableIPSecPSK) Get() *IPSecPSK { + return v.value +} + +func (v *NullableIPSecPSK) Set(val *IPSecPSK) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecPSK) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecPSK) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecPSK(val *IPSecPSK) *NullableIPSecPSK { + return &NullableIPSecPSK{value: val, isSet: true} +} + +func (v NullableIPSecPSK) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecPSK) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel.go new file mode 100644 index 000000000..6f6f3ef58 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel.go @@ -0,0 +1,436 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecTunnel Properties with all data needed to create a new IPSec Gateway Tunnel.\\ __Note__: there is a limit of 20 tunnels per IPSec Gateway. +type IPSecTunnel struct { + // The human readable name of your IPSec Gateway Tunnel. + Name *string `json:"name"` + // Human readable description of the IPSec Gateway Tunnel. + Description *string `json:"description,omitempty"` + // The remote peer host fully qualified domain name or IPV4 IP to connect to. * __Note__: This should be the public IP of the remote peer. * Tunnels only support IPV4 or hostname (fully qualified DNS name). + RemoteHost *string `json:"remoteHost"` + Auth *IPSecTunnelAuth `json:"auth"` + Ike *IKEEncryption `json:"ike"` + Esp *ESPEncryption `json:"esp"` + // The network CIDRs on the \"Left\" side that are allowed to connect to the IPSec tunnel, i.e the CIDRs within your IONOS Cloud LAN. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses. + CloudNetworkCIDRs *[]string `json:"cloudNetworkCIDRs"` + // The network CIDRs on the \"Right\" side that are allowed to connect to the IPSec tunnel. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses. + PeerNetworkCIDRs *[]string `json:"peerNetworkCIDRs"` +} + +// NewIPSecTunnel instantiates a new IPSecTunnel 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 NewIPSecTunnel(name string, remoteHost string, auth IPSecTunnelAuth, ike IKEEncryption, esp ESPEncryption, cloudNetworkCIDRs []string, peerNetworkCIDRs []string) *IPSecTunnel { + this := IPSecTunnel{} + + this.Name = &name + this.RemoteHost = &remoteHost + this.Auth = &auth + this.Ike = &ike + this.Esp = &esp + this.CloudNetworkCIDRs = &cloudNetworkCIDRs + this.PeerNetworkCIDRs = &peerNetworkCIDRs + + return &this +} + +// NewIPSecTunnelWithDefaults instantiates a new IPSecTunnel 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 NewIPSecTunnelWithDefaults() *IPSecTunnel { + this := IPSecTunnel{} + return &this +} + +// GetName returns the Name field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnel) GetName() *string { + if o == nil { + return nil + } + + return o.Name + +} + +// GetNameOk returns a tuple with the Name 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 *IPSecTunnel) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Name, true +} + +// SetName sets field value +func (o *IPSecTunnel) SetName(v string) { + + o.Name = &v + +} + +// HasName returns a boolean if a field has been set. +func (o *IPSecTunnel) HasName() bool { + if o != nil && o.Name != nil { + return true + } + + return false +} + +// GetDescription returns the Description field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnel) GetDescription() *string { + if o == nil { + return nil + } + + return o.Description + +} + +// GetDescriptionOk returns a tuple with the Description 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 *IPSecTunnel) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Description, true +} + +// SetDescription sets field value +func (o *IPSecTunnel) SetDescription(v string) { + + o.Description = &v + +} + +// HasDescription returns a boolean if a field has been set. +func (o *IPSecTunnel) HasDescription() bool { + if o != nil && o.Description != nil { + return true + } + + return false +} + +// GetRemoteHost returns the RemoteHost field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnel) GetRemoteHost() *string { + if o == nil { + return nil + } + + return o.RemoteHost + +} + +// GetRemoteHostOk returns a tuple with the RemoteHost 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 *IPSecTunnel) GetRemoteHostOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.RemoteHost, true +} + +// SetRemoteHost sets field value +func (o *IPSecTunnel) SetRemoteHost(v string) { + + o.RemoteHost = &v + +} + +// HasRemoteHost returns a boolean if a field has been set. +func (o *IPSecTunnel) HasRemoteHost() bool { + if o != nil && o.RemoteHost != nil { + return true + } + + return false +} + +// GetAuth returns the Auth field value +// If the value is explicit nil, the zero value for IPSecTunnelAuth will be returned +func (o *IPSecTunnel) GetAuth() *IPSecTunnelAuth { + if o == nil { + return nil + } + + return o.Auth + +} + +// GetAuthOk returns a tuple with the Auth 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 *IPSecTunnel) GetAuthOk() (*IPSecTunnelAuth, bool) { + if o == nil { + return nil, false + } + + return o.Auth, true +} + +// SetAuth sets field value +func (o *IPSecTunnel) SetAuth(v IPSecTunnelAuth) { + + o.Auth = &v + +} + +// HasAuth returns a boolean if a field has been set. +func (o *IPSecTunnel) HasAuth() bool { + if o != nil && o.Auth != nil { + return true + } + + return false +} + +// GetIke returns the Ike field value +// If the value is explicit nil, the zero value for IKEEncryption will be returned +func (o *IPSecTunnel) GetIke() *IKEEncryption { + if o == nil { + return nil + } + + return o.Ike + +} + +// GetIkeOk returns a tuple with the Ike 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 *IPSecTunnel) GetIkeOk() (*IKEEncryption, bool) { + if o == nil { + return nil, false + } + + return o.Ike, true +} + +// SetIke sets field value +func (o *IPSecTunnel) SetIke(v IKEEncryption) { + + o.Ike = &v + +} + +// HasIke returns a boolean if a field has been set. +func (o *IPSecTunnel) HasIke() bool { + if o != nil && o.Ike != nil { + return true + } + + return false +} + +// GetEsp returns the Esp field value +// If the value is explicit nil, the zero value for ESPEncryption will be returned +func (o *IPSecTunnel) GetEsp() *ESPEncryption { + if o == nil { + return nil + } + + return o.Esp + +} + +// GetEspOk returns a tuple with the Esp 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 *IPSecTunnel) GetEspOk() (*ESPEncryption, bool) { + if o == nil { + return nil, false + } + + return o.Esp, true +} + +// SetEsp sets field value +func (o *IPSecTunnel) SetEsp(v ESPEncryption) { + + o.Esp = &v + +} + +// HasEsp returns a boolean if a field has been set. +func (o *IPSecTunnel) HasEsp() bool { + if o != nil && o.Esp != nil { + return true + } + + return false +} + +// GetCloudNetworkCIDRs returns the CloudNetworkCIDRs field value +// If the value is explicit nil, the zero value for []string will be returned +func (o *IPSecTunnel) GetCloudNetworkCIDRs() *[]string { + if o == nil { + return nil + } + + return o.CloudNetworkCIDRs + +} + +// GetCloudNetworkCIDRsOk returns a tuple with the CloudNetworkCIDRs 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 *IPSecTunnel) GetCloudNetworkCIDRsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + + return o.CloudNetworkCIDRs, true +} + +// SetCloudNetworkCIDRs sets field value +func (o *IPSecTunnel) SetCloudNetworkCIDRs(v []string) { + + o.CloudNetworkCIDRs = &v + +} + +// HasCloudNetworkCIDRs returns a boolean if a field has been set. +func (o *IPSecTunnel) HasCloudNetworkCIDRs() bool { + if o != nil && o.CloudNetworkCIDRs != nil { + return true + } + + return false +} + +// GetPeerNetworkCIDRs returns the PeerNetworkCIDRs field value +// If the value is explicit nil, the zero value for []string will be returned +func (o *IPSecTunnel) GetPeerNetworkCIDRs() *[]string { + if o == nil { + return nil + } + + return o.PeerNetworkCIDRs + +} + +// GetPeerNetworkCIDRsOk returns a tuple with the PeerNetworkCIDRs 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 *IPSecTunnel) GetPeerNetworkCIDRsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + + return o.PeerNetworkCIDRs, true +} + +// SetPeerNetworkCIDRs sets field value +func (o *IPSecTunnel) SetPeerNetworkCIDRs(v []string) { + + o.PeerNetworkCIDRs = &v + +} + +// HasPeerNetworkCIDRs returns a boolean if a field has been set. +func (o *IPSecTunnel) HasPeerNetworkCIDRs() bool { + if o != nil && o.PeerNetworkCIDRs != nil { + return true + } + + return false +} + +func (o IPSecTunnel) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Name != nil { + toSerialize["name"] = o.Name + } + + if o.Description != nil { + toSerialize["description"] = o.Description + } + + if o.RemoteHost != nil { + toSerialize["remoteHost"] = o.RemoteHost + } + + if o.Auth != nil { + toSerialize["auth"] = o.Auth + } + + if o.Ike != nil { + toSerialize["ike"] = o.Ike + } + + if o.Esp != nil { + toSerialize["esp"] = o.Esp + } + + if o.CloudNetworkCIDRs != nil { + toSerialize["cloudNetworkCIDRs"] = o.CloudNetworkCIDRs + } + + if o.PeerNetworkCIDRs != nil { + toSerialize["peerNetworkCIDRs"] = o.PeerNetworkCIDRs + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecTunnel struct { + value *IPSecTunnel + isSet bool +} + +func (v NullableIPSecTunnel) Get() *IPSecTunnel { + return v.value +} + +func (v *NullableIPSecTunnel) Set(val *IPSecTunnel) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecTunnel) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecTunnel) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecTunnel(val *IPSecTunnel) *NullableIPSecTunnel { + return &NullableIPSecTunnel{value: val, isSet: true} +} + +func (v NullableIPSecTunnel) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecTunnel) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_auth.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_auth.go new file mode 100644 index 000000000..fc2ad0724 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_auth.go @@ -0,0 +1,170 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecTunnelAuth Properties with all data needed to define IPSec Authentication. +type IPSecTunnelAuth struct { + // The Authentication Method to use for IPSec Authentication.\\ Options: - PSK + Method *string `json:"method"` + Psk *IPSecPSK `json:"psk,omitempty"` +} + +// NewIPSecTunnelAuth instantiates a new IPSecTunnelAuth 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 NewIPSecTunnelAuth(method string) *IPSecTunnelAuth { + this := IPSecTunnelAuth{} + + this.Method = &method + + return &this +} + +// NewIPSecTunnelAuthWithDefaults instantiates a new IPSecTunnelAuth 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 NewIPSecTunnelAuthWithDefaults() *IPSecTunnelAuth { + this := IPSecTunnelAuth{} + var method string = "PSK" + this.Method = &method + return &this +} + +// GetMethod returns the Method field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelAuth) GetMethod() *string { + if o == nil { + return nil + } + + return o.Method + +} + +// GetMethodOk returns a tuple with the Method 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 *IPSecTunnelAuth) GetMethodOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Method, true +} + +// SetMethod sets field value +func (o *IPSecTunnelAuth) SetMethod(v string) { + + o.Method = &v + +} + +// HasMethod returns a boolean if a field has been set. +func (o *IPSecTunnelAuth) HasMethod() bool { + if o != nil && o.Method != nil { + return true + } + + return false +} + +// GetPsk returns the Psk field value +// If the value is explicit nil, the zero value for IPSecPSK will be returned +func (o *IPSecTunnelAuth) GetPsk() *IPSecPSK { + if o == nil { + return nil + } + + return o.Psk + +} + +// GetPskOk returns a tuple with the Psk 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 *IPSecTunnelAuth) GetPskOk() (*IPSecPSK, bool) { + if o == nil { + return nil, false + } + + return o.Psk, true +} + +// SetPsk sets field value +func (o *IPSecTunnelAuth) SetPsk(v IPSecPSK) { + + o.Psk = &v + +} + +// HasPsk returns a boolean if a field has been set. +func (o *IPSecTunnelAuth) HasPsk() bool { + if o != nil && o.Psk != nil { + return true + } + + return false +} + +func (o IPSecTunnelAuth) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Method != nil { + toSerialize["method"] = o.Method + } + + if o.Psk != nil { + toSerialize["psk"] = o.Psk + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecTunnelAuth struct { + value *IPSecTunnelAuth + isSet bool +} + +func (v NullableIPSecTunnelAuth) Get() *IPSecTunnelAuth { + return v.value +} + +func (v *NullableIPSecTunnelAuth) Set(val *IPSecTunnelAuth) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecTunnelAuth) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecTunnelAuth) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecTunnelAuth(val *IPSecTunnelAuth) *NullableIPSecTunnelAuth { + return &NullableIPSecTunnelAuth{value: val, isSet: true} +} + +func (v NullableIPSecTunnelAuth) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecTunnelAuth) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_create.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_create.go new file mode 100644 index 000000000..648bb70c6 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_create.go @@ -0,0 +1,168 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecTunnelCreate struct for IPSecTunnelCreate +type IPSecTunnelCreate struct { + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *IPSecTunnel `json:"properties"` +} + +// NewIPSecTunnelCreate instantiates a new IPSecTunnelCreate 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 NewIPSecTunnelCreate(properties IPSecTunnel) *IPSecTunnelCreate { + this := IPSecTunnelCreate{} + + this.Properties = &properties + + return &this +} + +// NewIPSecTunnelCreateWithDefaults instantiates a new IPSecTunnelCreate 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 NewIPSecTunnelCreateWithDefaults() *IPSecTunnelCreate { + this := IPSecTunnelCreate{} + return &this +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *IPSecTunnelCreate) GetMetadata() *map[string]interface{} { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *IPSecTunnelCreate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *IPSecTunnelCreate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *IPSecTunnelCreate) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for IPSecTunnel will be returned +func (o *IPSecTunnelCreate) GetProperties() *IPSecTunnel { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *IPSecTunnelCreate) GetPropertiesOk() (*IPSecTunnel, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *IPSecTunnelCreate) SetProperties(v IPSecTunnel) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *IPSecTunnelCreate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o IPSecTunnelCreate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecTunnelCreate struct { + value *IPSecTunnelCreate + isSet bool +} + +func (v NullableIPSecTunnelCreate) Get() *IPSecTunnelCreate { + return v.value +} + +func (v *NullableIPSecTunnelCreate) Set(val *IPSecTunnelCreate) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecTunnelCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecTunnelCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecTunnelCreate(val *IPSecTunnelCreate) *NullableIPSecTunnelCreate { + return &NullableIPSecTunnelCreate{value: val, isSet: true} +} + +func (v NullableIPSecTunnelCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecTunnelCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_ensure.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_ensure.go new file mode 100644 index 000000000..93fd6519d --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_ensure.go @@ -0,0 +1,213 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecTunnelEnsure struct for IPSecTunnelEnsure +type IPSecTunnelEnsure struct { + // The ID (UUID) of the IPSecTunnel. + Id *string `json:"id"` + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *IPSecTunnel `json:"properties"` +} + +// NewIPSecTunnelEnsure instantiates a new IPSecTunnelEnsure 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 NewIPSecTunnelEnsure(id string, properties IPSecTunnel) *IPSecTunnelEnsure { + this := IPSecTunnelEnsure{} + + this.Id = &id + this.Properties = &properties + + return &this +} + +// NewIPSecTunnelEnsureWithDefaults instantiates a new IPSecTunnelEnsure 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 NewIPSecTunnelEnsureWithDefaults() *IPSecTunnelEnsure { + this := IPSecTunnelEnsure{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelEnsure) GetId() *string { + if o == nil { + return nil + } + + 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 *IPSecTunnelEnsure) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *IPSecTunnelEnsure) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *IPSecTunnelEnsure) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *IPSecTunnelEnsure) GetMetadata() *map[string]interface{} { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *IPSecTunnelEnsure) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *IPSecTunnelEnsure) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *IPSecTunnelEnsure) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for IPSecTunnel will be returned +func (o *IPSecTunnelEnsure) GetProperties() *IPSecTunnel { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *IPSecTunnelEnsure) GetPropertiesOk() (*IPSecTunnel, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *IPSecTunnelEnsure) SetProperties(v IPSecTunnel) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *IPSecTunnelEnsure) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o IPSecTunnelEnsure) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecTunnelEnsure struct { + value *IPSecTunnelEnsure + isSet bool +} + +func (v NullableIPSecTunnelEnsure) Get() *IPSecTunnelEnsure { + return v.value +} + +func (v *NullableIPSecTunnelEnsure) Set(val *IPSecTunnelEnsure) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecTunnelEnsure) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecTunnelEnsure) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecTunnelEnsure(val *IPSecTunnelEnsure) *NullableIPSecTunnelEnsure { + return &NullableIPSecTunnelEnsure{value: val, isSet: true} +} + +func (v NullableIPSecTunnelEnsure) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecTunnelEnsure) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_metadata.go new file mode 100644 index 000000000..4e5d25a50 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_metadata.go @@ -0,0 +1,492 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// IPSecTunnelMetadata IPSec Tunnel Metadata +type IPSecTunnelMetadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` + // The current status of the resource. The status can be: * `AVAILABLE` - resource exists and is healthy. * `PROVISIONING` - resource is being created or updated. * `DESTROYING` - delete command was issued, the resource is being deleted. * `FAILED`: - resource failed, details in `statusMessage`. + Status *string `json:"status"` + // The message of the failure if the status is `FAILED`. + StatusMessage *string `json:"statusMessage,omitempty"` +} + +// NewIPSecTunnelMetadata instantiates a new IPSecTunnelMetadata 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 NewIPSecTunnelMetadata(status string) *IPSecTunnelMetadata { + this := IPSecTunnelMetadata{} + + this.Status = &status + + return &this +} + +// NewIPSecTunnelMetadataWithDefaults instantiates a new IPSecTunnelMetadata 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 NewIPSecTunnelMetadataWithDefaults() *IPSecTunnelMetadata { + this := IPSecTunnelMetadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *IPSecTunnelMetadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *IPSecTunnelMetadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *IPSecTunnelMetadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelMetadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *IPSecTunnelMetadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *IPSecTunnelMetadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelMetadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *IPSecTunnelMetadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *IPSecTunnelMetadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *IPSecTunnelMetadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *IPSecTunnelMetadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *IPSecTunnelMetadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelMetadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *IPSecTunnelMetadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *IPSecTunnelMetadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelMetadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *IPSecTunnelMetadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *IPSecTunnelMetadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelMetadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *IPSecTunnelMetadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *IPSecTunnelMetadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +// GetStatus returns the Status field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelMetadata) GetStatus() *string { + if o == nil { + return nil + } + + return o.Status + +} + +// GetStatusOk returns a tuple with the Status 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 *IPSecTunnelMetadata) GetStatusOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Status, true +} + +// SetStatus sets field value +func (o *IPSecTunnelMetadata) SetStatus(v string) { + + o.Status = &v + +} + +// HasStatus returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasStatus() bool { + if o != nil && o.Status != nil { + return true + } + + return false +} + +// GetStatusMessage returns the StatusMessage field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelMetadata) GetStatusMessage() *string { + if o == nil { + return nil + } + + return o.StatusMessage + +} + +// GetStatusMessageOk returns a tuple with the StatusMessage 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 *IPSecTunnelMetadata) GetStatusMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.StatusMessage, true +} + +// SetStatusMessage sets field value +func (o *IPSecTunnelMetadata) SetStatusMessage(v string) { + + o.StatusMessage = &v + +} + +// HasStatusMessage returns a boolean if a field has been set. +func (o *IPSecTunnelMetadata) HasStatusMessage() bool { + if o != nil && o.StatusMessage != nil { + return true + } + + return false +} + +func (o IPSecTunnelMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + if o.Status != nil { + toSerialize["status"] = o.Status + } + + if o.StatusMessage != nil { + toSerialize["statusMessage"] = o.StatusMessage + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecTunnelMetadata struct { + value *IPSecTunnelMetadata + isSet bool +} + +func (v NullableIPSecTunnelMetadata) Get() *IPSecTunnelMetadata { + return v.value +} + +func (v *NullableIPSecTunnelMetadata) Set(val *IPSecTunnelMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecTunnelMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecTunnelMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecTunnelMetadata(val *IPSecTunnelMetadata) *NullableIPSecTunnelMetadata { + return &NullableIPSecTunnelMetadata{value: val, isSet: true} +} + +func (v NullableIPSecTunnelMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecTunnelMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read.go new file mode 100644 index 000000000..bd7226c62 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read.go @@ -0,0 +1,303 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecTunnelRead struct for IPSecTunnelRead +type IPSecTunnelRead struct { + // The ID (UUID) of the IPSecTunnel. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the IPSecTunnel. + Href *string `json:"href"` + Metadata *IPSecTunnelMetadata `json:"metadata"` + Properties *IPSecTunnel `json:"properties"` +} + +// NewIPSecTunnelRead instantiates a new IPSecTunnelRead 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 NewIPSecTunnelRead(id string, type_ string, href string, metadata IPSecTunnelMetadata, properties IPSecTunnel) *IPSecTunnelRead { + this := IPSecTunnelRead{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Metadata = &metadata + this.Properties = &properties + + return &this +} + +// NewIPSecTunnelReadWithDefaults instantiates a new IPSecTunnelRead 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 NewIPSecTunnelReadWithDefaults() *IPSecTunnelRead { + this := IPSecTunnelRead{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelRead) GetId() *string { + if o == nil { + return nil + } + + 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 *IPSecTunnelRead) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *IPSecTunnelRead) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *IPSecTunnelRead) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelRead) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *IPSecTunnelRead) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *IPSecTunnelRead) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *IPSecTunnelRead) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelRead) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *IPSecTunnelRead) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *IPSecTunnelRead) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *IPSecTunnelRead) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for IPSecTunnelMetadata will be returned +func (o *IPSecTunnelRead) GetMetadata() *IPSecTunnelMetadata { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *IPSecTunnelRead) GetMetadataOk() (*IPSecTunnelMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *IPSecTunnelRead) SetMetadata(v IPSecTunnelMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *IPSecTunnelRead) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for IPSecTunnel will be returned +func (o *IPSecTunnelRead) GetProperties() *IPSecTunnel { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *IPSecTunnelRead) GetPropertiesOk() (*IPSecTunnel, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *IPSecTunnelRead) SetProperties(v IPSecTunnel) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *IPSecTunnelRead) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o IPSecTunnelRead) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecTunnelRead struct { + value *IPSecTunnelRead + isSet bool +} + +func (v NullableIPSecTunnelRead) Get() *IPSecTunnelRead { + return v.value +} + +func (v *NullableIPSecTunnelRead) Set(val *IPSecTunnelRead) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecTunnelRead) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecTunnelRead) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecTunnelRead(val *IPSecTunnelRead) *NullableIPSecTunnelRead { + return &NullableIPSecTunnelRead{value: val, isSet: true} +} + +func (v NullableIPSecTunnelRead) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecTunnelRead) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read_list.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read_list.go new file mode 100644 index 000000000..df82b5e21 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read_list.go @@ -0,0 +1,393 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecTunnelReadList struct for IPSecTunnelReadList +type IPSecTunnelReadList struct { + // ID of the list of IPSecTunnel resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of IPSecTunnel resources. + Href *string `json:"href"` + // The list of IPSecTunnel resources. + Items *[]IPSecTunnelRead `json:"items,omitempty"` + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewIPSecTunnelReadList instantiates a new IPSecTunnelReadList 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 NewIPSecTunnelReadList(id string, type_ string, href string, offset int32, limit int32, links Links) *IPSecTunnelReadList { + this := IPSecTunnelReadList{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewIPSecTunnelReadListWithDefaults instantiates a new IPSecTunnelReadList 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 NewIPSecTunnelReadListWithDefaults() *IPSecTunnelReadList { + this := IPSecTunnelReadList{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelReadList) GetId() *string { + if o == nil { + return nil + } + + 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 *IPSecTunnelReadList) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *IPSecTunnelReadList) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *IPSecTunnelReadList) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelReadList) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *IPSecTunnelReadList) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *IPSecTunnelReadList) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *IPSecTunnelReadList) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelReadList) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *IPSecTunnelReadList) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *IPSecTunnelReadList) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *IPSecTunnelReadList) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []IPSecTunnelRead will be returned +func (o *IPSecTunnelReadList) GetItems() *[]IPSecTunnelRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *IPSecTunnelReadList) GetItemsOk() (*[]IPSecTunnelRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *IPSecTunnelReadList) SetItems(v []IPSecTunnelRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *IPSecTunnelReadList) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *IPSecTunnelReadList) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *IPSecTunnelReadList) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *IPSecTunnelReadList) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *IPSecTunnelReadList) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *IPSecTunnelReadList) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *IPSecTunnelReadList) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *IPSecTunnelReadList) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *IPSecTunnelReadList) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *IPSecTunnelReadList) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *IPSecTunnelReadList) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *IPSecTunnelReadList) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *IPSecTunnelReadList) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o IPSecTunnelReadList) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecTunnelReadList struct { + value *IPSecTunnelReadList + isSet bool +} + +func (v NullableIPSecTunnelReadList) Get() *IPSecTunnelReadList { + return v.value +} + +func (v *NullableIPSecTunnelReadList) Set(val *IPSecTunnelReadList) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecTunnelReadList) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecTunnelReadList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecTunnelReadList(val *IPSecTunnelReadList) *NullableIPSecTunnelReadList { + return &NullableIPSecTunnelReadList{value: val, isSet: true} +} + +func (v NullableIPSecTunnelReadList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecTunnelReadList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read_list_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read_list_all_of.go new file mode 100644 index 000000000..a699def98 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_ip_sec_tunnel_read_list_all_of.go @@ -0,0 +1,259 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IPSecTunnelReadListAllOf struct for IPSecTunnelReadListAllOf +type IPSecTunnelReadListAllOf struct { + // ID of the list of IPSecTunnel resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of IPSecTunnel resources. + Href *string `json:"href"` + // The list of IPSecTunnel resources. + Items *[]IPSecTunnelRead `json:"items,omitempty"` +} + +// NewIPSecTunnelReadListAllOf instantiates a new IPSecTunnelReadListAllOf 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 NewIPSecTunnelReadListAllOf(id string, type_ string, href string) *IPSecTunnelReadListAllOf { + this := IPSecTunnelReadListAllOf{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + + return &this +} + +// NewIPSecTunnelReadListAllOfWithDefaults instantiates a new IPSecTunnelReadListAllOf 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 NewIPSecTunnelReadListAllOfWithDefaults() *IPSecTunnelReadListAllOf { + this := IPSecTunnelReadListAllOf{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelReadListAllOf) GetId() *string { + if o == nil { + return nil + } + + 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 *IPSecTunnelReadListAllOf) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *IPSecTunnelReadListAllOf) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *IPSecTunnelReadListAllOf) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelReadListAllOf) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *IPSecTunnelReadListAllOf) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *IPSecTunnelReadListAllOf) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *IPSecTunnelReadListAllOf) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IPSecTunnelReadListAllOf) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *IPSecTunnelReadListAllOf) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *IPSecTunnelReadListAllOf) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *IPSecTunnelReadListAllOf) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []IPSecTunnelRead will be returned +func (o *IPSecTunnelReadListAllOf) GetItems() *[]IPSecTunnelRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *IPSecTunnelReadListAllOf) GetItemsOk() (*[]IPSecTunnelRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *IPSecTunnelReadListAllOf) SetItems(v []IPSecTunnelRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *IPSecTunnelReadListAllOf) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +func (o IPSecTunnelReadListAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + return json.Marshal(toSerialize) +} + +type NullableIPSecTunnelReadListAllOf struct { + value *IPSecTunnelReadListAllOf + isSet bool +} + +func (v NullableIPSecTunnelReadListAllOf) Get() *IPSecTunnelReadListAllOf { + return v.value +} + +func (v *NullableIPSecTunnelReadListAllOf) Set(val *IPSecTunnelReadListAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableIPSecTunnelReadListAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableIPSecTunnelReadListAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPSecTunnelReadListAllOf(val *IPSecTunnelReadListAllOf) *NullableIPSecTunnelReadListAllOf { + return &NullableIPSecTunnelReadListAllOf{value: val, isSet: true} +} + +func (v NullableIPSecTunnelReadListAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPSecTunnelReadListAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_links.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_links.go new file mode 100644 index 000000000..0c0de5728 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_links.go @@ -0,0 +1,211 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Links URLs to navigate the different pages. As of now we always only return a single page. +type Links struct { + // URL (with offset and limit parameters) of the previous page; only present if offset is greater than 0. + Prev *string `json:"prev,omitempty"` + // URL (with offset and limit parameters) of the current page. + Self *string `json:"self,omitempty"` + // URL (with offset and limit parameters) of the next page; only present if offset + limit is less than the total number of elements. + Next *string `json:"next,omitempty"` +} + +// NewLinks instantiates a new Links 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 NewLinks() *Links { + this := Links{} + + return &this +} + +// NewLinksWithDefaults instantiates a new Links 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 NewLinksWithDefaults() *Links { + this := Links{} + return &this +} + +// GetPrev returns the Prev field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Links) GetPrev() *string { + if o == nil { + return nil + } + + return o.Prev + +} + +// GetPrevOk returns a tuple with the Prev 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 *Links) GetPrevOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Prev, true +} + +// SetPrev sets field value +func (o *Links) SetPrev(v string) { + + o.Prev = &v + +} + +// HasPrev returns a boolean if a field has been set. +func (o *Links) HasPrev() bool { + if o != nil && o.Prev != nil { + return true + } + + return false +} + +// GetSelf returns the Self field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Links) GetSelf() *string { + if o == nil { + return nil + } + + return o.Self + +} + +// GetSelfOk returns a tuple with the Self 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 *Links) GetSelfOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Self, true +} + +// SetSelf sets field value +func (o *Links) SetSelf(v string) { + + o.Self = &v + +} + +// HasSelf returns a boolean if a field has been set. +func (o *Links) HasSelf() bool { + if o != nil && o.Self != nil { + return true + } + + return false +} + +// GetNext returns the Next field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Links) GetNext() *string { + if o == nil { + return nil + } + + return o.Next + +} + +// GetNextOk returns a tuple with the Next 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 *Links) GetNextOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Next, true +} + +// SetNext sets field value +func (o *Links) SetNext(v string) { + + o.Next = &v + +} + +// HasNext returns a boolean if a field has been set. +func (o *Links) HasNext() bool { + if o != nil && o.Next != nil { + return true + } + + return false +} + +func (o Links) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Prev != nil { + toSerialize["prev"] = o.Prev + } + + if o.Self != nil { + toSerialize["self"] = o.Self + } + + if o.Next != nil { + toSerialize["next"] = o.Next + } + + return json.Marshal(toSerialize) +} + +type NullableLinks struct { + value *Links + isSet bool +} + +func (v NullableLinks) Get() *Links { + return v.value +} + +func (v *NullableLinks) Set(val *Links) { + v.value = val + v.isSet = true +} + +func (v NullableLinks) IsSet() bool { + return v.isSet +} + +func (v *NullableLinks) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLinks(val *Links) *NullableLinks { + return &NullableLinks{value: val, isSet: true} +} + +func (v NullableLinks) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLinks) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_metadata.go new file mode 100644 index 000000000..d88600510 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_metadata.go @@ -0,0 +1,402 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// Metadata Metadata of the resource. +type Metadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` +} + +// NewMetadata instantiates a new Metadata 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 NewMetadata() *Metadata { + this := Metadata{} + + return &this +} + +// NewMetadataWithDefaults instantiates a new Metadata 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 NewMetadataWithDefaults() *Metadata { + this := Metadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *Metadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *Metadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *Metadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *Metadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *Metadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *Metadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *Metadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *Metadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *Metadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *Metadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *Metadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *Metadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *Metadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *Metadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *Metadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *Metadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *Metadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *Metadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *Metadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *Metadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *Metadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *Metadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *Metadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +func (o Metadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + return json.Marshal(toSerialize) +} + +type NullableMetadata struct { + value *Metadata + isSet bool +} + +func (v NullableMetadata) Get() *Metadata { + return v.value +} + +func (v *NullableMetadata) Set(val *Metadata) { + v.value = val + v.isSet = true +} + +func (v NullableMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMetadata(val *Metadata) *NullableMetadata { + return &NullableMetadata{value: val, isSet: true} +} + +func (v NullableMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_pagination.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_pagination.go new file mode 100644 index 000000000..d89d1bd4f --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_pagination.go @@ -0,0 +1,214 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Pagination Pagination information. The offset and limit parameters are used to navigate the list of elements. The _links object contains URLs to navigate the different pages. +type Pagination struct { + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewPagination instantiates a new Pagination 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 NewPagination(offset int32, limit int32, links Links) *Pagination { + this := Pagination{} + + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewPaginationWithDefaults instantiates a new Pagination 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 NewPaginationWithDefaults() *Pagination { + this := Pagination{} + return &this +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *Pagination) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *Pagination) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *Pagination) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *Pagination) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *Pagination) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *Pagination) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *Pagination) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *Pagination) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *Pagination) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *Pagination) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *Pagination) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *Pagination) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o Pagination) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullablePagination struct { + value *Pagination + isSet bool +} + +func (v NullablePagination) Get() *Pagination { + return v.value +} + +func (v *NullablePagination) Set(val *Pagination) { + v.value = val + v.isSet = true +} + +func (v NullablePagination) IsSet() bool { + return v.isSet +} + +func (v *NullablePagination) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePagination(val *Pagination) *NullablePagination { + return &NullablePagination{value: val, isSet: true} +} + +func (v NullablePagination) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePagination) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_resource_status.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_resource_status.go new file mode 100644 index 000000000..2fb71a5d6 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_resource_status.go @@ -0,0 +1,169 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ResourceStatus The current status of the resource. +type ResourceStatus struct { + // The current status of the resource. The status can be: * `AVAILABLE` - resource exists and is healthy. * `PROVISIONING` - resource is being created or updated. * `DESTROYING` - delete command was issued, the resource is being deleted. * `FAILED`: - resource failed, details in `statusMessage`. + Status *string `json:"status"` + // The message of the failure if the status is `FAILED`. + StatusMessage *string `json:"statusMessage,omitempty"` +} + +// NewResourceStatus instantiates a new ResourceStatus 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 NewResourceStatus(status string) *ResourceStatus { + this := ResourceStatus{} + + this.Status = &status + + return &this +} + +// NewResourceStatusWithDefaults instantiates a new ResourceStatus 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 NewResourceStatusWithDefaults() *ResourceStatus { + this := ResourceStatus{} + return &this +} + +// GetStatus returns the Status field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ResourceStatus) GetStatus() *string { + if o == nil { + return nil + } + + return o.Status + +} + +// GetStatusOk returns a tuple with the Status 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 *ResourceStatus) GetStatusOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Status, true +} + +// SetStatus sets field value +func (o *ResourceStatus) SetStatus(v string) { + + o.Status = &v + +} + +// HasStatus returns a boolean if a field has been set. +func (o *ResourceStatus) HasStatus() bool { + if o != nil && o.Status != nil { + return true + } + + return false +} + +// GetStatusMessage returns the StatusMessage field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ResourceStatus) GetStatusMessage() *string { + if o == nil { + return nil + } + + return o.StatusMessage + +} + +// GetStatusMessageOk returns a tuple with the StatusMessage 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 *ResourceStatus) GetStatusMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.StatusMessage, true +} + +// SetStatusMessage sets field value +func (o *ResourceStatus) SetStatusMessage(v string) { + + o.StatusMessage = &v + +} + +// HasStatusMessage returns a boolean if a field has been set. +func (o *ResourceStatus) HasStatusMessage() bool { + if o != nil && o.StatusMessage != nil { + return true + } + + return false +} + +func (o ResourceStatus) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Status != nil { + toSerialize["status"] = o.Status + } + + if o.StatusMessage != nil { + toSerialize["statusMessage"] = o.StatusMessage + } + + return json.Marshal(toSerialize) +} + +type NullableResourceStatus struct { + value *ResourceStatus + isSet bool +} + +func (v NullableResourceStatus) Get() *ResourceStatus { + return v.value +} + +func (v *NullableResourceStatus) Set(val *ResourceStatus) { + v.value = val + v.isSet = true +} + +func (v NullableResourceStatus) IsSet() bool { + return v.isSet +} + +func (v *NullableResourceStatus) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableResourceStatus(val *ResourceStatus) *NullableResourceStatus { + return &NullableResourceStatus{value: val, isSet: true} +} + +func (v NullableResourceStatus) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableResourceStatus) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_endpoint.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_endpoint.go new file mode 100644 index 000000000..9a0179f49 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_endpoint.go @@ -0,0 +1,173 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardEndpoint Properties with all data needed to create a new WireGuard Gateway endpoint. +type WireguardEndpoint struct { + // Hostname or IPV4 address that the WireGuard Server will connect to. + Host *string `json:"host"` + // IP port number + Port *int32 `json:"port,omitempty"` +} + +// NewWireguardEndpoint instantiates a new WireguardEndpoint 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 NewWireguardEndpoint(host string) *WireguardEndpoint { + this := WireguardEndpoint{} + + this.Host = &host + var port int32 = 51820 + this.Port = &port + + return &this +} + +// NewWireguardEndpointWithDefaults instantiates a new WireguardEndpoint 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 NewWireguardEndpointWithDefaults() *WireguardEndpoint { + this := WireguardEndpoint{} + var port int32 = 51820 + this.Port = &port + return &this +} + +// GetHost returns the Host field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardEndpoint) GetHost() *string { + if o == nil { + return nil + } + + return o.Host + +} + +// GetHostOk returns a tuple with the Host 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 *WireguardEndpoint) GetHostOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Host, true +} + +// SetHost sets field value +func (o *WireguardEndpoint) SetHost(v string) { + + o.Host = &v + +} + +// HasHost returns a boolean if a field has been set. +func (o *WireguardEndpoint) HasHost() bool { + if o != nil && o.Host != nil { + return true + } + + return false +} + +// GetPort returns the Port field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *WireguardEndpoint) GetPort() *int32 { + if o == nil { + return nil + } + + return o.Port + +} + +// GetPortOk returns a tuple with the Port 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 *WireguardEndpoint) GetPortOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Port, true +} + +// SetPort sets field value +func (o *WireguardEndpoint) SetPort(v int32) { + + o.Port = &v + +} + +// HasPort returns a boolean if a field has been set. +func (o *WireguardEndpoint) HasPort() bool { + if o != nil && o.Port != nil { + return true + } + + return false +} + +func (o WireguardEndpoint) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Host != nil { + toSerialize["host"] = o.Host + } + + if o.Port != nil { + toSerialize["port"] = o.Port + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardEndpoint struct { + value *WireguardEndpoint + isSet bool +} + +func (v NullableWireguardEndpoint) Get() *WireguardEndpoint { + return v.value +} + +func (v *NullableWireguardEndpoint) Set(val *WireguardEndpoint) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardEndpoint) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardEndpoint) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardEndpoint(val *WireguardEndpoint) *NullableWireguardEndpoint { + return &NullableWireguardEndpoint{value: val, isSet: true} +} + +func (v NullableWireguardEndpoint) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardEndpoint) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway.go new file mode 100644 index 000000000..7508e493a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway.go @@ -0,0 +1,440 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardGateway Properties with all data needed to create a new WireGuard Gateway. +type WireguardGateway struct { + // The human readable name of your WireguardGateway. + Name *string `json:"name"` + // Human readable description of the WireguardGateway. + Description *string `json:"description,omitempty"` + // Public IP address to be assigned to the gateway. __Note__: This must be an IP address in the same datacenter as the connections. + GatewayIP *string `json:"gatewayIP"` + // Describes a range of IP V4 addresses in CIDR notation. + InterfaceIPv4CIDR *string `json:"interfaceIPv4CIDR,omitempty"` + // Describes a range of IP V6 addresses in CIDR notation. + InterfaceIPv6CIDR *string `json:"interfaceIPv6CIDR,omitempty"` + // The network connection for your gateway. __Note__: all connections must belong to the same datacenterId. + Connections *[]Connection `json:"connections"` + // PrivateKey used for WireGuard Server + PrivateKey *string `json:"privateKey"` + // IP port number + ListenPort *int32 `json:"listenPort,omitempty"` +} + +// NewWireguardGateway instantiates a new WireguardGateway 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 NewWireguardGateway(name string, gatewayIP string, connections []Connection, privateKey string) *WireguardGateway { + this := WireguardGateway{} + + this.Name = &name + this.GatewayIP = &gatewayIP + this.Connections = &connections + this.PrivateKey = &privateKey + var listenPort int32 = 51820 + this.ListenPort = &listenPort + + return &this +} + +// NewWireguardGatewayWithDefaults instantiates a new WireguardGateway 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 NewWireguardGatewayWithDefaults() *WireguardGateway { + this := WireguardGateway{} + var listenPort int32 = 51820 + this.ListenPort = &listenPort + return &this +} + +// GetName returns the Name field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGateway) GetName() *string { + if o == nil { + return nil + } + + return o.Name + +} + +// GetNameOk returns a tuple with the Name 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 *WireguardGateway) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Name, true +} + +// SetName sets field value +func (o *WireguardGateway) SetName(v string) { + + o.Name = &v + +} + +// HasName returns a boolean if a field has been set. +func (o *WireguardGateway) HasName() bool { + if o != nil && o.Name != nil { + return true + } + + return false +} + +// GetDescription returns the Description field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGateway) GetDescription() *string { + if o == nil { + return nil + } + + return o.Description + +} + +// GetDescriptionOk returns a tuple with the Description 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 *WireguardGateway) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Description, true +} + +// SetDescription sets field value +func (o *WireguardGateway) SetDescription(v string) { + + o.Description = &v + +} + +// HasDescription returns a boolean if a field has been set. +func (o *WireguardGateway) HasDescription() bool { + if o != nil && o.Description != nil { + return true + } + + return false +} + +// GetGatewayIP returns the GatewayIP field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGateway) GetGatewayIP() *string { + if o == nil { + return nil + } + + return o.GatewayIP + +} + +// GetGatewayIPOk returns a tuple with the GatewayIP 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 *WireguardGateway) GetGatewayIPOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.GatewayIP, true +} + +// SetGatewayIP sets field value +func (o *WireguardGateway) SetGatewayIP(v string) { + + o.GatewayIP = &v + +} + +// HasGatewayIP returns a boolean if a field has been set. +func (o *WireguardGateway) HasGatewayIP() bool { + if o != nil && o.GatewayIP != nil { + return true + } + + return false +} + +// GetInterfaceIPv4CIDR returns the InterfaceIPv4CIDR field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGateway) GetInterfaceIPv4CIDR() *string { + if o == nil { + return nil + } + + return o.InterfaceIPv4CIDR + +} + +// GetInterfaceIPv4CIDROk returns a tuple with the InterfaceIPv4CIDR 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 *WireguardGateway) GetInterfaceIPv4CIDROk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.InterfaceIPv4CIDR, true +} + +// SetInterfaceIPv4CIDR sets field value +func (o *WireguardGateway) SetInterfaceIPv4CIDR(v string) { + + o.InterfaceIPv4CIDR = &v + +} + +// HasInterfaceIPv4CIDR returns a boolean if a field has been set. +func (o *WireguardGateway) HasInterfaceIPv4CIDR() bool { + if o != nil && o.InterfaceIPv4CIDR != nil { + return true + } + + return false +} + +// GetInterfaceIPv6CIDR returns the InterfaceIPv6CIDR field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGateway) GetInterfaceIPv6CIDR() *string { + if o == nil { + return nil + } + + return o.InterfaceIPv6CIDR + +} + +// GetInterfaceIPv6CIDROk returns a tuple with the InterfaceIPv6CIDR 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 *WireguardGateway) GetInterfaceIPv6CIDROk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.InterfaceIPv6CIDR, true +} + +// SetInterfaceIPv6CIDR sets field value +func (o *WireguardGateway) SetInterfaceIPv6CIDR(v string) { + + o.InterfaceIPv6CIDR = &v + +} + +// HasInterfaceIPv6CIDR returns a boolean if a field has been set. +func (o *WireguardGateway) HasInterfaceIPv6CIDR() bool { + if o != nil && o.InterfaceIPv6CIDR != nil { + return true + } + + return false +} + +// GetConnections returns the Connections field value +// If the value is explicit nil, the zero value for []Connection will be returned +func (o *WireguardGateway) GetConnections() *[]Connection { + if o == nil { + return nil + } + + return o.Connections + +} + +// GetConnectionsOk returns a tuple with the Connections 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 *WireguardGateway) GetConnectionsOk() (*[]Connection, bool) { + if o == nil { + return nil, false + } + + return o.Connections, true +} + +// SetConnections sets field value +func (o *WireguardGateway) SetConnections(v []Connection) { + + o.Connections = &v + +} + +// HasConnections returns a boolean if a field has been set. +func (o *WireguardGateway) HasConnections() bool { + if o != nil && o.Connections != nil { + return true + } + + return false +} + +// GetPrivateKey returns the PrivateKey field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGateway) GetPrivateKey() *string { + if o == nil { + return nil + } + + return o.PrivateKey + +} + +// GetPrivateKeyOk returns a tuple with the PrivateKey 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 *WireguardGateway) GetPrivateKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.PrivateKey, true +} + +// SetPrivateKey sets field value +func (o *WireguardGateway) SetPrivateKey(v string) { + + o.PrivateKey = &v + +} + +// HasPrivateKey returns a boolean if a field has been set. +func (o *WireguardGateway) HasPrivateKey() bool { + if o != nil && o.PrivateKey != nil { + return true + } + + return false +} + +// GetListenPort returns the ListenPort field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *WireguardGateway) GetListenPort() *int32 { + if o == nil { + return nil + } + + return o.ListenPort + +} + +// GetListenPortOk returns a tuple with the ListenPort 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 *WireguardGateway) GetListenPortOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.ListenPort, true +} + +// SetListenPort sets field value +func (o *WireguardGateway) SetListenPort(v int32) { + + o.ListenPort = &v + +} + +// HasListenPort returns a boolean if a field has been set. +func (o *WireguardGateway) HasListenPort() bool { + if o != nil && o.ListenPort != nil { + return true + } + + return false +} + +func (o WireguardGateway) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Name != nil { + toSerialize["name"] = o.Name + } + + if o.Description != nil { + toSerialize["description"] = o.Description + } + + if o.GatewayIP != nil { + toSerialize["gatewayIP"] = o.GatewayIP + } + + if o.InterfaceIPv4CIDR != nil { + toSerialize["interfaceIPv4CIDR"] = o.InterfaceIPv4CIDR + } + + if o.InterfaceIPv6CIDR != nil { + toSerialize["interfaceIPv6CIDR"] = o.InterfaceIPv6CIDR + } + + if o.Connections != nil { + toSerialize["connections"] = o.Connections + } + + if o.PrivateKey != nil { + toSerialize["privateKey"] = o.PrivateKey + } + + if o.ListenPort != nil { + toSerialize["listenPort"] = o.ListenPort + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardGateway struct { + value *WireguardGateway + isSet bool +} + +func (v NullableWireguardGateway) Get() *WireguardGateway { + return v.value +} + +func (v *NullableWireguardGateway) Set(val *WireguardGateway) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardGateway) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardGateway) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardGateway(val *WireguardGateway) *NullableWireguardGateway { + return &NullableWireguardGateway{value: val, isSet: true} +} + +func (v NullableWireguardGateway) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardGateway) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_create.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_create.go new file mode 100644 index 000000000..b8501ba5e --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_create.go @@ -0,0 +1,168 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardGatewayCreate struct for WireguardGatewayCreate +type WireguardGatewayCreate struct { + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *WireguardGateway `json:"properties"` +} + +// NewWireguardGatewayCreate instantiates a new WireguardGatewayCreate 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 NewWireguardGatewayCreate(properties WireguardGateway) *WireguardGatewayCreate { + this := WireguardGatewayCreate{} + + this.Properties = &properties + + return &this +} + +// NewWireguardGatewayCreateWithDefaults instantiates a new WireguardGatewayCreate 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 NewWireguardGatewayCreateWithDefaults() *WireguardGatewayCreate { + this := WireguardGatewayCreate{} + return &this +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *WireguardGatewayCreate) GetMetadata() *map[string]interface{} { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *WireguardGatewayCreate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *WireguardGatewayCreate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *WireguardGatewayCreate) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for WireguardGateway will be returned +func (o *WireguardGatewayCreate) GetProperties() *WireguardGateway { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *WireguardGatewayCreate) GetPropertiesOk() (*WireguardGateway, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *WireguardGatewayCreate) SetProperties(v WireguardGateway) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *WireguardGatewayCreate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o WireguardGatewayCreate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardGatewayCreate struct { + value *WireguardGatewayCreate + isSet bool +} + +func (v NullableWireguardGatewayCreate) Get() *WireguardGatewayCreate { + return v.value +} + +func (v *NullableWireguardGatewayCreate) Set(val *WireguardGatewayCreate) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardGatewayCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardGatewayCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardGatewayCreate(val *WireguardGatewayCreate) *NullableWireguardGatewayCreate { + return &NullableWireguardGatewayCreate{value: val, isSet: true} +} + +func (v NullableWireguardGatewayCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardGatewayCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_ensure.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_ensure.go new file mode 100644 index 000000000..a1bf1742b --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_ensure.go @@ -0,0 +1,213 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardGatewayEnsure struct for WireguardGatewayEnsure +type WireguardGatewayEnsure struct { + // The ID (UUID) of the WireguardGateway. + Id *string `json:"id"` + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *WireguardGateway `json:"properties"` +} + +// NewWireguardGatewayEnsure instantiates a new WireguardGatewayEnsure 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 NewWireguardGatewayEnsure(id string, properties WireguardGateway) *WireguardGatewayEnsure { + this := WireguardGatewayEnsure{} + + this.Id = &id + this.Properties = &properties + + return &this +} + +// NewWireguardGatewayEnsureWithDefaults instantiates a new WireguardGatewayEnsure 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 NewWireguardGatewayEnsureWithDefaults() *WireguardGatewayEnsure { + this := WireguardGatewayEnsure{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayEnsure) GetId() *string { + if o == nil { + return nil + } + + 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 *WireguardGatewayEnsure) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *WireguardGatewayEnsure) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *WireguardGatewayEnsure) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *WireguardGatewayEnsure) GetMetadata() *map[string]interface{} { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *WireguardGatewayEnsure) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *WireguardGatewayEnsure) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *WireguardGatewayEnsure) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for WireguardGateway will be returned +func (o *WireguardGatewayEnsure) GetProperties() *WireguardGateway { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *WireguardGatewayEnsure) GetPropertiesOk() (*WireguardGateway, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *WireguardGatewayEnsure) SetProperties(v WireguardGateway) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *WireguardGatewayEnsure) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o WireguardGatewayEnsure) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardGatewayEnsure struct { + value *WireguardGatewayEnsure + isSet bool +} + +func (v NullableWireguardGatewayEnsure) Get() *WireguardGatewayEnsure { + return v.value +} + +func (v *NullableWireguardGatewayEnsure) Set(val *WireguardGatewayEnsure) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardGatewayEnsure) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardGatewayEnsure) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardGatewayEnsure(val *WireguardGatewayEnsure) *NullableWireguardGatewayEnsure { + return &NullableWireguardGatewayEnsure{value: val, isSet: true} +} + +func (v NullableWireguardGatewayEnsure) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardGatewayEnsure) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_metadata.go new file mode 100644 index 000000000..8ea6aadc9 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_metadata.go @@ -0,0 +1,537 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// WireguardGatewayMetadata WireGuard Gateway Metadata +type WireguardGatewayMetadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` + // The current status of the resource. The status can be: * `AVAILABLE` - resource exists and is healthy. * `PROVISIONING` - resource is being created or updated. * `DESTROYING` - delete command was issued, the resource is being deleted. * `FAILED`: - resource failed, details in `statusMessage`. + Status *string `json:"status"` + // The message of the failure if the status is `FAILED`. + StatusMessage *string `json:"statusMessage,omitempty"` + // Public key correspondng to the WireGuard Server private key. + PublicKey *string `json:"publicKey"` +} + +// NewWireguardGatewayMetadata instantiates a new WireguardGatewayMetadata 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 NewWireguardGatewayMetadata(status string, publicKey string) *WireguardGatewayMetadata { + this := WireguardGatewayMetadata{} + + this.Status = &status + this.PublicKey = &publicKey + + return &this +} + +// NewWireguardGatewayMetadataWithDefaults instantiates a new WireguardGatewayMetadata 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 NewWireguardGatewayMetadataWithDefaults() *WireguardGatewayMetadata { + this := WireguardGatewayMetadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *WireguardGatewayMetadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *WireguardGatewayMetadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *WireguardGatewayMetadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *WireguardGatewayMetadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *WireguardGatewayMetadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *WireguardGatewayMetadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *WireguardGatewayMetadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *WireguardGatewayMetadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *WireguardGatewayMetadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *WireguardGatewayMetadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *WireguardGatewayMetadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *WireguardGatewayMetadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *WireguardGatewayMetadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *WireguardGatewayMetadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *WireguardGatewayMetadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *WireguardGatewayMetadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +// GetStatus returns the Status field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadata) GetStatus() *string { + if o == nil { + return nil + } + + return o.Status + +} + +// GetStatusOk returns a tuple with the Status 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 *WireguardGatewayMetadata) GetStatusOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Status, true +} + +// SetStatus sets field value +func (o *WireguardGatewayMetadata) SetStatus(v string) { + + o.Status = &v + +} + +// HasStatus returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasStatus() bool { + if o != nil && o.Status != nil { + return true + } + + return false +} + +// GetStatusMessage returns the StatusMessage field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadata) GetStatusMessage() *string { + if o == nil { + return nil + } + + return o.StatusMessage + +} + +// GetStatusMessageOk returns a tuple with the StatusMessage 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 *WireguardGatewayMetadata) GetStatusMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.StatusMessage, true +} + +// SetStatusMessage sets field value +func (o *WireguardGatewayMetadata) SetStatusMessage(v string) { + + o.StatusMessage = &v + +} + +// HasStatusMessage returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasStatusMessage() bool { + if o != nil && o.StatusMessage != nil { + return true + } + + return false +} + +// GetPublicKey returns the PublicKey field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadata) GetPublicKey() *string { + if o == nil { + return nil + } + + return o.PublicKey + +} + +// GetPublicKeyOk returns a tuple with the PublicKey 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 *WireguardGatewayMetadata) GetPublicKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.PublicKey, true +} + +// SetPublicKey sets field value +func (o *WireguardGatewayMetadata) SetPublicKey(v string) { + + o.PublicKey = &v + +} + +// HasPublicKey returns a boolean if a field has been set. +func (o *WireguardGatewayMetadata) HasPublicKey() bool { + if o != nil && o.PublicKey != nil { + return true + } + + return false +} + +func (o WireguardGatewayMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + if o.Status != nil { + toSerialize["status"] = o.Status + } + + if o.StatusMessage != nil { + toSerialize["statusMessage"] = o.StatusMessage + } + + if o.PublicKey != nil { + toSerialize["publicKey"] = o.PublicKey + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardGatewayMetadata struct { + value *WireguardGatewayMetadata + isSet bool +} + +func (v NullableWireguardGatewayMetadata) Get() *WireguardGatewayMetadata { + return v.value +} + +func (v *NullableWireguardGatewayMetadata) Set(val *WireguardGatewayMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardGatewayMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardGatewayMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardGatewayMetadata(val *WireguardGatewayMetadata) *NullableWireguardGatewayMetadata { + return &NullableWireguardGatewayMetadata{value: val, isSet: true} +} + +func (v NullableWireguardGatewayMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardGatewayMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_metadata_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_metadata_all_of.go new file mode 100644 index 000000000..580be389a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_metadata_all_of.go @@ -0,0 +1,125 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardGatewayMetadataAllOf struct for WireguardGatewayMetadataAllOf +type WireguardGatewayMetadataAllOf struct { + // Public key correspondng to the WireGuard Server private key. + PublicKey *string `json:"publicKey"` +} + +// NewWireguardGatewayMetadataAllOf instantiates a new WireguardGatewayMetadataAllOf 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 NewWireguardGatewayMetadataAllOf(publicKey string) *WireguardGatewayMetadataAllOf { + this := WireguardGatewayMetadataAllOf{} + + this.PublicKey = &publicKey + + return &this +} + +// NewWireguardGatewayMetadataAllOfWithDefaults instantiates a new WireguardGatewayMetadataAllOf 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 NewWireguardGatewayMetadataAllOfWithDefaults() *WireguardGatewayMetadataAllOf { + this := WireguardGatewayMetadataAllOf{} + return &this +} + +// GetPublicKey returns the PublicKey field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayMetadataAllOf) GetPublicKey() *string { + if o == nil { + return nil + } + + return o.PublicKey + +} + +// GetPublicKeyOk returns a tuple with the PublicKey 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 *WireguardGatewayMetadataAllOf) GetPublicKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.PublicKey, true +} + +// SetPublicKey sets field value +func (o *WireguardGatewayMetadataAllOf) SetPublicKey(v string) { + + o.PublicKey = &v + +} + +// HasPublicKey returns a boolean if a field has been set. +func (o *WireguardGatewayMetadataAllOf) HasPublicKey() bool { + if o != nil && o.PublicKey != nil { + return true + } + + return false +} + +func (o WireguardGatewayMetadataAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.PublicKey != nil { + toSerialize["publicKey"] = o.PublicKey + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardGatewayMetadataAllOf struct { + value *WireguardGatewayMetadataAllOf + isSet bool +} + +func (v NullableWireguardGatewayMetadataAllOf) Get() *WireguardGatewayMetadataAllOf { + return v.value +} + +func (v *NullableWireguardGatewayMetadataAllOf) Set(val *WireguardGatewayMetadataAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardGatewayMetadataAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardGatewayMetadataAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardGatewayMetadataAllOf(val *WireguardGatewayMetadataAllOf) *NullableWireguardGatewayMetadataAllOf { + return &NullableWireguardGatewayMetadataAllOf{value: val, isSet: true} +} + +func (v NullableWireguardGatewayMetadataAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardGatewayMetadataAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read.go new file mode 100644 index 000000000..67587d21f --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read.go @@ -0,0 +1,303 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardGatewayRead struct for WireguardGatewayRead +type WireguardGatewayRead struct { + // The ID (UUID) of the WireguardGateway. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the WireguardGateway. + Href *string `json:"href"` + Metadata *WireguardGatewayMetadata `json:"metadata"` + Properties *WireguardGateway `json:"properties"` +} + +// NewWireguardGatewayRead instantiates a new WireguardGatewayRead 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 NewWireguardGatewayRead(id string, type_ string, href string, metadata WireguardGatewayMetadata, properties WireguardGateway) *WireguardGatewayRead { + this := WireguardGatewayRead{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Metadata = &metadata + this.Properties = &properties + + return &this +} + +// NewWireguardGatewayReadWithDefaults instantiates a new WireguardGatewayRead 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 NewWireguardGatewayReadWithDefaults() *WireguardGatewayRead { + this := WireguardGatewayRead{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayRead) GetId() *string { + if o == nil { + return nil + } + + 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 *WireguardGatewayRead) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *WireguardGatewayRead) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *WireguardGatewayRead) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayRead) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *WireguardGatewayRead) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *WireguardGatewayRead) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *WireguardGatewayRead) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayRead) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *WireguardGatewayRead) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *WireguardGatewayRead) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *WireguardGatewayRead) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for WireguardGatewayMetadata will be returned +func (o *WireguardGatewayRead) GetMetadata() *WireguardGatewayMetadata { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *WireguardGatewayRead) GetMetadataOk() (*WireguardGatewayMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *WireguardGatewayRead) SetMetadata(v WireguardGatewayMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *WireguardGatewayRead) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for WireguardGateway will be returned +func (o *WireguardGatewayRead) GetProperties() *WireguardGateway { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *WireguardGatewayRead) GetPropertiesOk() (*WireguardGateway, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *WireguardGatewayRead) SetProperties(v WireguardGateway) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *WireguardGatewayRead) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o WireguardGatewayRead) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardGatewayRead struct { + value *WireguardGatewayRead + isSet bool +} + +func (v NullableWireguardGatewayRead) Get() *WireguardGatewayRead { + return v.value +} + +func (v *NullableWireguardGatewayRead) Set(val *WireguardGatewayRead) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardGatewayRead) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardGatewayRead) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardGatewayRead(val *WireguardGatewayRead) *NullableWireguardGatewayRead { + return &NullableWireguardGatewayRead{value: val, isSet: true} +} + +func (v NullableWireguardGatewayRead) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardGatewayRead) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read_list.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read_list.go new file mode 100644 index 000000000..2a12dbf4a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read_list.go @@ -0,0 +1,393 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardGatewayReadList struct for WireguardGatewayReadList +type WireguardGatewayReadList struct { + // ID of the list of WireguardGateway resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of WireguardGateway resources. + Href *string `json:"href"` + // The list of WireguardGateway resources. + Items *[]WireguardGatewayRead `json:"items,omitempty"` + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewWireguardGatewayReadList instantiates a new WireguardGatewayReadList 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 NewWireguardGatewayReadList(id string, type_ string, href string, offset int32, limit int32, links Links) *WireguardGatewayReadList { + this := WireguardGatewayReadList{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewWireguardGatewayReadListWithDefaults instantiates a new WireguardGatewayReadList 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 NewWireguardGatewayReadListWithDefaults() *WireguardGatewayReadList { + this := WireguardGatewayReadList{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayReadList) GetId() *string { + if o == nil { + return nil + } + + 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 *WireguardGatewayReadList) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *WireguardGatewayReadList) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *WireguardGatewayReadList) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayReadList) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *WireguardGatewayReadList) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *WireguardGatewayReadList) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *WireguardGatewayReadList) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayReadList) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *WireguardGatewayReadList) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *WireguardGatewayReadList) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *WireguardGatewayReadList) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []WireguardGatewayRead will be returned +func (o *WireguardGatewayReadList) GetItems() *[]WireguardGatewayRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *WireguardGatewayReadList) GetItemsOk() (*[]WireguardGatewayRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *WireguardGatewayReadList) SetItems(v []WireguardGatewayRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *WireguardGatewayReadList) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *WireguardGatewayReadList) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *WireguardGatewayReadList) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *WireguardGatewayReadList) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *WireguardGatewayReadList) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *WireguardGatewayReadList) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *WireguardGatewayReadList) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *WireguardGatewayReadList) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *WireguardGatewayReadList) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *WireguardGatewayReadList) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *WireguardGatewayReadList) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *WireguardGatewayReadList) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *WireguardGatewayReadList) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o WireguardGatewayReadList) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardGatewayReadList struct { + value *WireguardGatewayReadList + isSet bool +} + +func (v NullableWireguardGatewayReadList) Get() *WireguardGatewayReadList { + return v.value +} + +func (v *NullableWireguardGatewayReadList) Set(val *WireguardGatewayReadList) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardGatewayReadList) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardGatewayReadList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardGatewayReadList(val *WireguardGatewayReadList) *NullableWireguardGatewayReadList { + return &NullableWireguardGatewayReadList{value: val, isSet: true} +} + +func (v NullableWireguardGatewayReadList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardGatewayReadList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read_list_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read_list_all_of.go new file mode 100644 index 000000000..8f2063105 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_gateway_read_list_all_of.go @@ -0,0 +1,259 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardGatewayReadListAllOf struct for WireguardGatewayReadListAllOf +type WireguardGatewayReadListAllOf struct { + // ID of the list of WireguardGateway resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of WireguardGateway resources. + Href *string `json:"href"` + // The list of WireguardGateway resources. + Items *[]WireguardGatewayRead `json:"items,omitempty"` +} + +// NewWireguardGatewayReadListAllOf instantiates a new WireguardGatewayReadListAllOf 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 NewWireguardGatewayReadListAllOf(id string, type_ string, href string) *WireguardGatewayReadListAllOf { + this := WireguardGatewayReadListAllOf{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + + return &this +} + +// NewWireguardGatewayReadListAllOfWithDefaults instantiates a new WireguardGatewayReadListAllOf 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 NewWireguardGatewayReadListAllOfWithDefaults() *WireguardGatewayReadListAllOf { + this := WireguardGatewayReadListAllOf{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayReadListAllOf) GetId() *string { + if o == nil { + return nil + } + + 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 *WireguardGatewayReadListAllOf) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *WireguardGatewayReadListAllOf) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *WireguardGatewayReadListAllOf) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayReadListAllOf) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *WireguardGatewayReadListAllOf) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *WireguardGatewayReadListAllOf) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *WireguardGatewayReadListAllOf) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardGatewayReadListAllOf) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *WireguardGatewayReadListAllOf) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *WireguardGatewayReadListAllOf) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *WireguardGatewayReadListAllOf) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []WireguardGatewayRead will be returned +func (o *WireguardGatewayReadListAllOf) GetItems() *[]WireguardGatewayRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *WireguardGatewayReadListAllOf) GetItemsOk() (*[]WireguardGatewayRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *WireguardGatewayReadListAllOf) SetItems(v []WireguardGatewayRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *WireguardGatewayReadListAllOf) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +func (o WireguardGatewayReadListAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardGatewayReadListAllOf struct { + value *WireguardGatewayReadListAllOf + isSet bool +} + +func (v NullableWireguardGatewayReadListAllOf) Get() *WireguardGatewayReadListAllOf { + return v.value +} + +func (v *NullableWireguardGatewayReadListAllOf) Set(val *WireguardGatewayReadListAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardGatewayReadListAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardGatewayReadListAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardGatewayReadListAllOf(val *WireguardGatewayReadListAllOf) *NullableWireguardGatewayReadListAllOf { + return &NullableWireguardGatewayReadListAllOf{value: val, isSet: true} +} + +func (v NullableWireguardGatewayReadListAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardGatewayReadListAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer.go new file mode 100644 index 000000000..a652c9985 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer.go @@ -0,0 +1,302 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardPeer Properties with all data needed to create a new WireGuard Gateway Peer.\\ __Note__: there is a limit of 20 peers per WireGuard Gateway. +type WireguardPeer struct { + // The human readable name of your WireguardGateway Peer. + Name *string `json:"name"` + // Human readable description of the WireguardGateway Peer. + Description *string `json:"description,omitempty"` + Endpoint *WireguardEndpoint `json:"endpoint,omitempty"` + // The subnet CIDRs that are allowed to connect to the WireGuard Gateway. Specify \"a.b.c.d/32\" for an individual IP address. Specify \"0.0.0.0/0\" or \"::/0\" for all addresses. + AllowedIPs *[]string `json:"allowedIPs"` + // WireGuard public key of the connecting peer + PublicKey *string `json:"publicKey"` +} + +// NewWireguardPeer instantiates a new WireguardPeer 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 NewWireguardPeer(name string, allowedIPs []string, publicKey string) *WireguardPeer { + this := WireguardPeer{} + + this.Name = &name + this.AllowedIPs = &allowedIPs + this.PublicKey = &publicKey + + return &this +} + +// NewWireguardPeerWithDefaults instantiates a new WireguardPeer 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 NewWireguardPeerWithDefaults() *WireguardPeer { + this := WireguardPeer{} + return &this +} + +// GetName returns the Name field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeer) GetName() *string { + if o == nil { + return nil + } + + return o.Name + +} + +// GetNameOk returns a tuple with the Name 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 *WireguardPeer) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Name, true +} + +// SetName sets field value +func (o *WireguardPeer) SetName(v string) { + + o.Name = &v + +} + +// HasName returns a boolean if a field has been set. +func (o *WireguardPeer) HasName() bool { + if o != nil && o.Name != nil { + return true + } + + return false +} + +// GetDescription returns the Description field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeer) GetDescription() *string { + if o == nil { + return nil + } + + return o.Description + +} + +// GetDescriptionOk returns a tuple with the Description 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 *WireguardPeer) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Description, true +} + +// SetDescription sets field value +func (o *WireguardPeer) SetDescription(v string) { + + o.Description = &v + +} + +// HasDescription returns a boolean if a field has been set. +func (o *WireguardPeer) HasDescription() bool { + if o != nil && o.Description != nil { + return true + } + + return false +} + +// GetEndpoint returns the Endpoint field value +// If the value is explicit nil, the zero value for WireguardEndpoint will be returned +func (o *WireguardPeer) GetEndpoint() *WireguardEndpoint { + if o == nil { + return nil + } + + return o.Endpoint + +} + +// GetEndpointOk returns a tuple with the Endpoint 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 *WireguardPeer) GetEndpointOk() (*WireguardEndpoint, bool) { + if o == nil { + return nil, false + } + + return o.Endpoint, true +} + +// SetEndpoint sets field value +func (o *WireguardPeer) SetEndpoint(v WireguardEndpoint) { + + o.Endpoint = &v + +} + +// HasEndpoint returns a boolean if a field has been set. +func (o *WireguardPeer) HasEndpoint() bool { + if o != nil && o.Endpoint != nil { + return true + } + + return false +} + +// GetAllowedIPs returns the AllowedIPs field value +// If the value is explicit nil, the zero value for []string will be returned +func (o *WireguardPeer) GetAllowedIPs() *[]string { + if o == nil { + return nil + } + + return o.AllowedIPs + +} + +// GetAllowedIPsOk returns a tuple with the AllowedIPs 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 *WireguardPeer) GetAllowedIPsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + + return o.AllowedIPs, true +} + +// SetAllowedIPs sets field value +func (o *WireguardPeer) SetAllowedIPs(v []string) { + + o.AllowedIPs = &v + +} + +// HasAllowedIPs returns a boolean if a field has been set. +func (o *WireguardPeer) HasAllowedIPs() bool { + if o != nil && o.AllowedIPs != nil { + return true + } + + return false +} + +// GetPublicKey returns the PublicKey field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeer) GetPublicKey() *string { + if o == nil { + return nil + } + + return o.PublicKey + +} + +// GetPublicKeyOk returns a tuple with the PublicKey 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 *WireguardPeer) GetPublicKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.PublicKey, true +} + +// SetPublicKey sets field value +func (o *WireguardPeer) SetPublicKey(v string) { + + o.PublicKey = &v + +} + +// HasPublicKey returns a boolean if a field has been set. +func (o *WireguardPeer) HasPublicKey() bool { + if o != nil && o.PublicKey != nil { + return true + } + + return false +} + +func (o WireguardPeer) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Name != nil { + toSerialize["name"] = o.Name + } + + if o.Description != nil { + toSerialize["description"] = o.Description + } + + if o.Endpoint != nil { + toSerialize["endpoint"] = o.Endpoint + } + + if o.AllowedIPs != nil { + toSerialize["allowedIPs"] = o.AllowedIPs + } + + if o.PublicKey != nil { + toSerialize["publicKey"] = o.PublicKey + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardPeer struct { + value *WireguardPeer + isSet bool +} + +func (v NullableWireguardPeer) Get() *WireguardPeer { + return v.value +} + +func (v *NullableWireguardPeer) Set(val *WireguardPeer) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardPeer) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardPeer) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardPeer(val *WireguardPeer) *NullableWireguardPeer { + return &NullableWireguardPeer{value: val, isSet: true} +} + +func (v NullableWireguardPeer) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardPeer) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_create.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_create.go new file mode 100644 index 000000000..5df9ba596 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_create.go @@ -0,0 +1,168 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardPeerCreate struct for WireguardPeerCreate +type WireguardPeerCreate struct { + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *WireguardPeer `json:"properties"` +} + +// NewWireguardPeerCreate instantiates a new WireguardPeerCreate 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 NewWireguardPeerCreate(properties WireguardPeer) *WireguardPeerCreate { + this := WireguardPeerCreate{} + + this.Properties = &properties + + return &this +} + +// NewWireguardPeerCreateWithDefaults instantiates a new WireguardPeerCreate 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 NewWireguardPeerCreateWithDefaults() *WireguardPeerCreate { + this := WireguardPeerCreate{} + return &this +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *WireguardPeerCreate) GetMetadata() *map[string]interface{} { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *WireguardPeerCreate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *WireguardPeerCreate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *WireguardPeerCreate) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for WireguardPeer will be returned +func (o *WireguardPeerCreate) GetProperties() *WireguardPeer { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *WireguardPeerCreate) GetPropertiesOk() (*WireguardPeer, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *WireguardPeerCreate) SetProperties(v WireguardPeer) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *WireguardPeerCreate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o WireguardPeerCreate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardPeerCreate struct { + value *WireguardPeerCreate + isSet bool +} + +func (v NullableWireguardPeerCreate) Get() *WireguardPeerCreate { + return v.value +} + +func (v *NullableWireguardPeerCreate) Set(val *WireguardPeerCreate) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardPeerCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardPeerCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardPeerCreate(val *WireguardPeerCreate) *NullableWireguardPeerCreate { + return &NullableWireguardPeerCreate{value: val, isSet: true} +} + +func (v NullableWireguardPeerCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardPeerCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_ensure.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_ensure.go new file mode 100644 index 000000000..bfe178212 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_ensure.go @@ -0,0 +1,213 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardPeerEnsure struct for WireguardPeerEnsure +type WireguardPeerEnsure struct { + // The ID (UUID) of the WireguardPeer. + Id *string `json:"id"` + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *WireguardPeer `json:"properties"` +} + +// NewWireguardPeerEnsure instantiates a new WireguardPeerEnsure 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 NewWireguardPeerEnsure(id string, properties WireguardPeer) *WireguardPeerEnsure { + this := WireguardPeerEnsure{} + + this.Id = &id + this.Properties = &properties + + return &this +} + +// NewWireguardPeerEnsureWithDefaults instantiates a new WireguardPeerEnsure 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 NewWireguardPeerEnsureWithDefaults() *WireguardPeerEnsure { + this := WireguardPeerEnsure{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerEnsure) GetId() *string { + if o == nil { + return nil + } + + 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 *WireguardPeerEnsure) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *WireguardPeerEnsure) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *WireguardPeerEnsure) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *WireguardPeerEnsure) GetMetadata() *map[string]interface{} { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *WireguardPeerEnsure) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *WireguardPeerEnsure) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *WireguardPeerEnsure) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for WireguardPeer will be returned +func (o *WireguardPeerEnsure) GetProperties() *WireguardPeer { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *WireguardPeerEnsure) GetPropertiesOk() (*WireguardPeer, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *WireguardPeerEnsure) SetProperties(v WireguardPeer) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *WireguardPeerEnsure) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o WireguardPeerEnsure) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardPeerEnsure struct { + value *WireguardPeerEnsure + isSet bool +} + +func (v NullableWireguardPeerEnsure) Get() *WireguardPeerEnsure { + return v.value +} + +func (v *NullableWireguardPeerEnsure) Set(val *WireguardPeerEnsure) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardPeerEnsure) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardPeerEnsure) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardPeerEnsure(val *WireguardPeerEnsure) *NullableWireguardPeerEnsure { + return &NullableWireguardPeerEnsure{value: val, isSet: true} +} + +func (v NullableWireguardPeerEnsure) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardPeerEnsure) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_metadata.go new file mode 100644 index 000000000..e2aa298d7 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_metadata.go @@ -0,0 +1,492 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// WireguardPeerMetadata WireGuard Peer Metadata +type WireguardPeerMetadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` + // The current status of the resource. The status can be: * `AVAILABLE` - resource exists and is healthy. * `PROVISIONING` - resource is being created or updated. * `DESTROYING` - delete command was issued, the resource is being deleted. * `FAILED`: - resource failed, details in `statusMessage`. + Status *string `json:"status"` + // The message of the failure if the status is `FAILED`. + StatusMessage *string `json:"statusMessage,omitempty"` +} + +// NewWireguardPeerMetadata instantiates a new WireguardPeerMetadata 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 NewWireguardPeerMetadata(status string) *WireguardPeerMetadata { + this := WireguardPeerMetadata{} + + this.Status = &status + + return &this +} + +// NewWireguardPeerMetadataWithDefaults instantiates a new WireguardPeerMetadata 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 NewWireguardPeerMetadataWithDefaults() *WireguardPeerMetadata { + this := WireguardPeerMetadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *WireguardPeerMetadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *WireguardPeerMetadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *WireguardPeerMetadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerMetadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *WireguardPeerMetadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *WireguardPeerMetadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerMetadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *WireguardPeerMetadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *WireguardPeerMetadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *WireguardPeerMetadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *WireguardPeerMetadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *WireguardPeerMetadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerMetadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *WireguardPeerMetadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *WireguardPeerMetadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerMetadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *WireguardPeerMetadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *WireguardPeerMetadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerMetadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *WireguardPeerMetadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *WireguardPeerMetadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +// GetStatus returns the Status field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerMetadata) GetStatus() *string { + if o == nil { + return nil + } + + return o.Status + +} + +// GetStatusOk returns a tuple with the Status 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 *WireguardPeerMetadata) GetStatusOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Status, true +} + +// SetStatus sets field value +func (o *WireguardPeerMetadata) SetStatus(v string) { + + o.Status = &v + +} + +// HasStatus returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasStatus() bool { + if o != nil && o.Status != nil { + return true + } + + return false +} + +// GetStatusMessage returns the StatusMessage field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerMetadata) GetStatusMessage() *string { + if o == nil { + return nil + } + + return o.StatusMessage + +} + +// GetStatusMessageOk returns a tuple with the StatusMessage 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 *WireguardPeerMetadata) GetStatusMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.StatusMessage, true +} + +// SetStatusMessage sets field value +func (o *WireguardPeerMetadata) SetStatusMessage(v string) { + + o.StatusMessage = &v + +} + +// HasStatusMessage returns a boolean if a field has been set. +func (o *WireguardPeerMetadata) HasStatusMessage() bool { + if o != nil && o.StatusMessage != nil { + return true + } + + return false +} + +func (o WireguardPeerMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + if o.Status != nil { + toSerialize["status"] = o.Status + } + + if o.StatusMessage != nil { + toSerialize["statusMessage"] = o.StatusMessage + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardPeerMetadata struct { + value *WireguardPeerMetadata + isSet bool +} + +func (v NullableWireguardPeerMetadata) Get() *WireguardPeerMetadata { + return v.value +} + +func (v *NullableWireguardPeerMetadata) Set(val *WireguardPeerMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardPeerMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardPeerMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardPeerMetadata(val *WireguardPeerMetadata) *NullableWireguardPeerMetadata { + return &NullableWireguardPeerMetadata{value: val, isSet: true} +} + +func (v NullableWireguardPeerMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardPeerMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read.go new file mode 100644 index 000000000..4207a12cf --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read.go @@ -0,0 +1,303 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardPeerRead struct for WireguardPeerRead +type WireguardPeerRead struct { + // The ID (UUID) of the WireguardPeer. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the WireguardPeer. + Href *string `json:"href"` + Metadata *WireguardPeerMetadata `json:"metadata"` + Properties *WireguardPeer `json:"properties"` +} + +// NewWireguardPeerRead instantiates a new WireguardPeerRead 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 NewWireguardPeerRead(id string, type_ string, href string, metadata WireguardPeerMetadata, properties WireguardPeer) *WireguardPeerRead { + this := WireguardPeerRead{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Metadata = &metadata + this.Properties = &properties + + return &this +} + +// NewWireguardPeerReadWithDefaults instantiates a new WireguardPeerRead 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 NewWireguardPeerReadWithDefaults() *WireguardPeerRead { + this := WireguardPeerRead{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerRead) GetId() *string { + if o == nil { + return nil + } + + 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 *WireguardPeerRead) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *WireguardPeerRead) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *WireguardPeerRead) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerRead) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *WireguardPeerRead) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *WireguardPeerRead) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *WireguardPeerRead) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerRead) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *WireguardPeerRead) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *WireguardPeerRead) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *WireguardPeerRead) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for WireguardPeerMetadata will be returned +func (o *WireguardPeerRead) GetMetadata() *WireguardPeerMetadata { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata 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 *WireguardPeerRead) GetMetadataOk() (*WireguardPeerMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *WireguardPeerRead) SetMetadata(v WireguardPeerMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *WireguardPeerRead) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for WireguardPeer will be returned +func (o *WireguardPeerRead) GetProperties() *WireguardPeer { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties 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 *WireguardPeerRead) GetPropertiesOk() (*WireguardPeer, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *WireguardPeerRead) SetProperties(v WireguardPeer) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *WireguardPeerRead) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o WireguardPeerRead) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardPeerRead struct { + value *WireguardPeerRead + isSet bool +} + +func (v NullableWireguardPeerRead) Get() *WireguardPeerRead { + return v.value +} + +func (v *NullableWireguardPeerRead) Set(val *WireguardPeerRead) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardPeerRead) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardPeerRead) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardPeerRead(val *WireguardPeerRead) *NullableWireguardPeerRead { + return &NullableWireguardPeerRead{value: val, isSet: true} +} + +func (v NullableWireguardPeerRead) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardPeerRead) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read_list.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read_list.go new file mode 100644 index 000000000..305c429de --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read_list.go @@ -0,0 +1,393 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardPeerReadList struct for WireguardPeerReadList +type WireguardPeerReadList struct { + // ID of the list of WireguardPeer resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of WireguardPeer resources. + Href *string `json:"href"` + // The list of WireguardPeer resources. + Items *[]WireguardPeerRead `json:"items,omitempty"` + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewWireguardPeerReadList instantiates a new WireguardPeerReadList 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 NewWireguardPeerReadList(id string, type_ string, href string, offset int32, limit int32, links Links) *WireguardPeerReadList { + this := WireguardPeerReadList{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewWireguardPeerReadListWithDefaults instantiates a new WireguardPeerReadList 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 NewWireguardPeerReadListWithDefaults() *WireguardPeerReadList { + this := WireguardPeerReadList{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerReadList) GetId() *string { + if o == nil { + return nil + } + + 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 *WireguardPeerReadList) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *WireguardPeerReadList) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *WireguardPeerReadList) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerReadList) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *WireguardPeerReadList) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *WireguardPeerReadList) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *WireguardPeerReadList) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerReadList) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *WireguardPeerReadList) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *WireguardPeerReadList) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *WireguardPeerReadList) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []WireguardPeerRead will be returned +func (o *WireguardPeerReadList) GetItems() *[]WireguardPeerRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *WireguardPeerReadList) GetItemsOk() (*[]WireguardPeerRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *WireguardPeerReadList) SetItems(v []WireguardPeerRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *WireguardPeerReadList) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *WireguardPeerReadList) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *WireguardPeerReadList) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *WireguardPeerReadList) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *WireguardPeerReadList) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *WireguardPeerReadList) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *WireguardPeerReadList) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *WireguardPeerReadList) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *WireguardPeerReadList) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *WireguardPeerReadList) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *WireguardPeerReadList) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *WireguardPeerReadList) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *WireguardPeerReadList) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o WireguardPeerReadList) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardPeerReadList struct { + value *WireguardPeerReadList + isSet bool +} + +func (v NullableWireguardPeerReadList) Get() *WireguardPeerReadList { + return v.value +} + +func (v *NullableWireguardPeerReadList) Set(val *WireguardPeerReadList) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardPeerReadList) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardPeerReadList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardPeerReadList(val *WireguardPeerReadList) *NullableWireguardPeerReadList { + return &NullableWireguardPeerReadList{value: val, isSet: true} +} + +func (v NullableWireguardPeerReadList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardPeerReadList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read_list_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read_list_all_of.go new file mode 100644 index 000000000..83b5dc208 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/model_wireguard_peer_read_list_all_of.go @@ -0,0 +1,259 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// WireguardPeerReadListAllOf struct for WireguardPeerReadListAllOf +type WireguardPeerReadListAllOf struct { + // ID of the list of WireguardPeer resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of WireguardPeer resources. + Href *string `json:"href"` + // The list of WireguardPeer resources. + Items *[]WireguardPeerRead `json:"items,omitempty"` +} + +// NewWireguardPeerReadListAllOf instantiates a new WireguardPeerReadListAllOf 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 NewWireguardPeerReadListAllOf(id string, type_ string, href string) *WireguardPeerReadListAllOf { + this := WireguardPeerReadListAllOf{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + + return &this +} + +// NewWireguardPeerReadListAllOfWithDefaults instantiates a new WireguardPeerReadListAllOf 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 NewWireguardPeerReadListAllOfWithDefaults() *WireguardPeerReadListAllOf { + this := WireguardPeerReadListAllOf{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerReadListAllOf) GetId() *string { + if o == nil { + return nil + } + + 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 *WireguardPeerReadListAllOf) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *WireguardPeerReadListAllOf) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *WireguardPeerReadListAllOf) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerReadListAllOf) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *WireguardPeerReadListAllOf) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *WireguardPeerReadListAllOf) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *WireguardPeerReadListAllOf) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *WireguardPeerReadListAllOf) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *WireguardPeerReadListAllOf) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *WireguardPeerReadListAllOf) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *WireguardPeerReadListAllOf) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []WireguardPeerRead will be returned +func (o *WireguardPeerReadListAllOf) GetItems() *[]WireguardPeerRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *WireguardPeerReadListAllOf) GetItemsOk() (*[]WireguardPeerRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *WireguardPeerReadListAllOf) SetItems(v []WireguardPeerRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *WireguardPeerReadListAllOf) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +func (o WireguardPeerReadListAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + return json.Marshal(toSerialize) +} + +type NullableWireguardPeerReadListAllOf struct { + value *WireguardPeerReadListAllOf + isSet bool +} + +func (v NullableWireguardPeerReadListAllOf) Get() *WireguardPeerReadListAllOf { + return v.value +} + +func (v *NullableWireguardPeerReadListAllOf) Set(val *WireguardPeerReadListAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableWireguardPeerReadListAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableWireguardPeerReadListAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWireguardPeerReadListAllOf(val *WireguardPeerReadListAllOf) *NullableWireguardPeerReadListAllOf { + return &NullableWireguardPeerReadListAllOf{value: val, isSet: true} +} + +func (v NullableWireguardPeerReadListAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWireguardPeerReadListAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/response.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/response.go new file mode 100644 index 000000000..be906221f --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/response.go @@ -0,0 +1,74 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "log" + "net/http" + "time" +) + +// 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"` + // RequestTime is the time duration from the moment the APIClient sends + // the HTTP request to the moment it receives an HTTP response. + RequestTime time.Duration `json:"duration,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 +} + +// HttpNotFound - returns true if a 404 status code was returned +// returns false for nil APIResponse values +func (resp *APIResponse) HttpNotFound() bool { + if resp != nil && resp.Response != nil && resp.StatusCode == http.StatusNotFound { + return true + } + return false +} + +// LogInfo - logs APIResponse values like RequestTime, Operation and StatusCode +// does not print anything for nil APIResponse values +func (resp *APIResponse) LogInfo() { + if resp != nil { + log.Printf("[DEBUG] Request time : %s for operation : %s", + resp.RequestTime, resp.Operation) + if resp.Response != nil { + log.Printf("[DEBUG] response status code : %d\n", resp.StatusCode) + } + } +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/sonar-project.properties b/vendor/github.com/ionos-cloud/sdk-go-vpn/sonar-project.properties new file mode 100644 index 000000000..918d2d327 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=ionos-cloud_sdk-template +sonar.organization=ionos-cloud + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=sdk-template +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 diff --git a/vendor/github.com/ionos-cloud/sdk-go-vpn/utils.go b/vendor/github.com/ionos-cloud/sdk-go-vpn/utils.go new file mode 100644 index 000000000..636847649 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-vpn/utils.go @@ -0,0 +1,777 @@ +/* + * VPN Gateways + * + * POC Docs for VPN gateway as service + * + * API version: 0.0.1 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "reflect" + "time" +) + +// ToPtr - returns a pointer to the given value. +func ToPtr[T any](v T) *T { + return &v +} + +// ToValue - returns the value of the pointer passed in +func ToValue[T any](ptr *T) T { + return *ptr +} + +// ToValueDefault - returns the value of the pointer passed in, or the default type value if the pointer is nil +func ToValueDefault[T any](ptr *T) T { + var defaultVal T + if ptr == nil { + return defaultVal + } + return *ptr +} + +func SliceToValueDefault[T any](ptrSlice *[]T) []T { + return append([]T{}, *ptrSlice...) +} + +// PtrBool - returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt - returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 - returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 - returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 - returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 - returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString - returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime - returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +// ToBool - returns the value of the bool pointer passed in +func ToBool(ptr *bool) bool { + return *ptr +} + +// ToBoolDefault - returns the value of the bool pointer passed in, or false if the pointer is nil +func ToBoolDefault(ptr *bool) bool { + var defaultVal bool + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToBoolSlice - returns a bool slice of the pointer passed in +func ToBoolSlice(ptrSlice *[]bool) []bool { + valSlice := make([]bool, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToByte - returns the value of the byte pointer passed in +func ToByte(ptr *byte) byte { + return *ptr +} + +// ToByteDefault - returns the value of the byte pointer passed in, or 0 if the pointer is nil +func ToByteDefault(ptr *byte) byte { + var defaultVal byte + if ptr == nil { + return defaultVal + } + + return *ptr +} + +// ToByteSlice - returns a byte slice of the pointer passed in +func ToByteSlice(ptrSlice *[]byte) []byte { + valSlice := make([]byte, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToString - returns the value of the string pointer passed in +func ToString(ptr *string) string { + return *ptr +} + +// ToStringDefault - returns the value of the string pointer passed in, or "" if the pointer is nil +func ToStringDefault(ptr *string) string { + var defaultVal string + if ptr == nil { + return defaultVal + } + + return *ptr +} + +// ToStringSlice - returns a string slice of the pointer passed in +func ToStringSlice(ptrSlice *[]string) []string { + valSlice := make([]string, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt - returns the value of the int pointer passed in +func ToInt(ptr *int) int { + return *ptr +} + +// ToIntDefault - returns the value of the int pointer passed in, or 0 if the pointer is nil +func ToIntDefault(ptr *int) int { + var defaultVal int + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToIntSlice - returns a int slice of the pointer passed in +func ToIntSlice(ptrSlice *[]int) []int { + valSlice := make([]int, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt8 - returns the value of the int8 pointer passed in +func ToInt8(ptr *int8) int8 { + return *ptr +} + +// ToInt8Default - returns the value of the int8 pointer passed in, or 0 if the pointer is nil +func ToInt8Default(ptr *int8) int8 { + var defaultVal int8 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToInt8Slice - returns a int8 slice of the pointer passed in +func ToInt8Slice(ptrSlice *[]int8) []int8 { + valSlice := make([]int8, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt16 - returns the value of the int16 pointer passed in +func ToInt16(ptr *int16) int16 { + return *ptr +} + +// ToInt16Default - returns the value of the int16 pointer passed in, or 0 if the pointer is nil +func ToInt16Default(ptr *int16) int16 { + var defaultVal int16 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToInt16Slice - returns a int16 slice of the pointer passed in +func ToInt16Slice(ptrSlice *[]int16) []int16 { + valSlice := make([]int16, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt32 - returns the value of the int32 pointer passed in +func ToInt32(ptr *int32) int32 { + return *ptr +} + +// ToInt32Default - returns the value of the int32 pointer passed in, or 0 if the pointer is nil +func ToInt32Default(ptr *int32) int32 { + var defaultVal int32 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToInt32Slice - returns a int32 slice of the pointer passed in +func ToInt32Slice(ptrSlice *[]int32) []int32 { + valSlice := make([]int32, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt64 - returns the value of the int64 pointer passed in +func ToInt64(ptr *int64) int64 { + return *ptr +} + +// ToInt64Default - returns the value of the int64 pointer passed in, or 0 if the pointer is nil +func ToInt64Default(ptr *int64) int64 { + var defaultVal int64 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToInt64Slice - returns a int64 slice of the pointer passed in +func ToInt64Slice(ptrSlice *[]int64) []int64 { + valSlice := make([]int64, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint - returns the value of the uint pointer passed in +func ToUint(ptr *uint) uint { + return *ptr +} + +// ToUintDefault - returns the value of the uint pointer passed in, or 0 if the pointer is nil +func ToUintDefault(ptr *uint) uint { + var defaultVal uint + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUintSlice - returns a uint slice of the pointer passed in +func ToUintSlice(ptrSlice *[]uint) []uint { + valSlice := make([]uint, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint8 -returns the value of the uint8 pointer passed in +func ToUint8(ptr *uint8) uint8 { + return *ptr +} + +// ToUint8Default - returns the value of the uint8 pointer passed in, or 0 if the pointer is nil +func ToUint8Default(ptr *uint8) uint8 { + var defaultVal uint8 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUint8Slice - returns a uint8 slice of the pointer passed in +func ToUint8Slice(ptrSlice *[]uint8) []uint8 { + valSlice := make([]uint8, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint16 - returns the value of the uint16 pointer passed in +func ToUint16(ptr *uint16) uint16 { + return *ptr +} + +// ToUint16Default - returns the value of the uint16 pointer passed in, or 0 if the pointer is nil +func ToUint16Default(ptr *uint16) uint16 { + var defaultVal uint16 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUint16Slice - returns a uint16 slice of the pointer passed in +func ToUint16Slice(ptrSlice *[]uint16) []uint16 { + valSlice := make([]uint16, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint32 - returns the value of the uint32 pointer passed in +func ToUint32(ptr *uint32) uint32 { + return *ptr +} + +// ToUint32Default - returns the value of the uint32 pointer passed in, or 0 if the pointer is nil +func ToUint32Default(ptr *uint32) uint32 { + var defaultVal uint32 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUint32Slice - returns a uint32 slice of the pointer passed in +func ToUint32Slice(ptrSlice *[]uint32) []uint32 { + valSlice := make([]uint32, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint64 - returns the value of the uint64 pointer passed in +func ToUint64(ptr *uint64) uint64 { + return *ptr +} + +// ToUint64Default - returns the value of the uint64 pointer passed in, or 0 if the pointer is nil +func ToUint64Default(ptr *uint64) uint64 { + var defaultVal uint64 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUint64Slice - returns a uint63 slice of the pointer passed in +func ToUint64Slice(ptrSlice *[]uint64) []uint64 { + valSlice := make([]uint64, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToFloat32 - returns the value of the float32 pointer passed in +func ToFloat32(ptr *float32) float32 { + return *ptr +} + +// ToFloat32Default - returns the value of the float32 pointer passed in, or 0 if the pointer is nil +func ToFloat32Default(ptr *float32) float32 { + var defaultVal float32 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToFloat32Slice - returns a float32 slice of the pointer passed in +func ToFloat32Slice(ptrSlice *[]float32) []float32 { + valSlice := make([]float32, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToFloat64 - returns the value of the float64 pointer passed in +func ToFloat64(ptr *float64) float64 { + return *ptr +} + +// ToFloat64Default - returns the value of the float64 pointer passed in, or 0 if the pointer is nil +func ToFloat64Default(ptr *float64) float64 { + var defaultVal float64 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToFloat64Slice - returns a float64 slice of the pointer passed in +func ToFloat64Slice(ptrSlice *[]float64) []float64 { + valSlice := make([]float64, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToTime - returns the value of the Time pointer passed in +func ToTime(ptr *time.Time) time.Time { + return *ptr +} + +// ToTimeDefault - returns the value of the Time pointer passed in, or 0001-01-01 00:00:00 +0000 UTC if the pointer is nil +func ToTimeDefault(ptr *time.Time) time.Time { + var defaultVal time.Time + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToTimeSlice - returns a Time slice of the pointer passed in +func ToTimeSlice(ptrSlice *[]time.Time) []time.Time { + valSlice := make([]time.Time, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +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) +} + +type IonosTime struct { + time.Time +} + +func (t *IonosTime) UnmarshalJSON(data []byte) error { + str := string(data) + if strlen(str) == 0 { + t = nil + return nil + } + if str[0] == '"' { + str = str[1:] + } + if str[len(str)-1] == '"' { + str = str[:len(str)-1] + } + tt, err := time.Parse(time.RFC3339, str) + if err != nil { + return err + } + *t = IonosTime{tt} + return nil +} + +// 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 +} diff --git a/vendor/modules.txt b/vendor/modules.txt index ba6f8def7..369cbe509 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -96,6 +96,9 @@ github.com/ionos-cloud/sdk-go-logging # github.com/ionos-cloud/sdk-go-vm-autoscaling v1.0.1 ## explicit; go 1.18 github.com/ionos-cloud/sdk-go-vm-autoscaling +# github.com/ionos-cloud/sdk-go-vpn v1.0.1 +## explicit; go 1.18 +github.com/ionos-cloud/sdk-go-vpn # github.com/ionos-cloud/sdk-go/v6 v6.1.11 ## explicit; go 1.19 github.com/ionos-cloud/sdk-go/v6