diff --git a/CHANGELOG.md b/CHANGELOG.md index dcc9a30c6..506fd78e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [v6.8.0] +- Added support for CDN operations + ## [v6.7.8] (October 2024) ### Added diff --git a/commands/cdn/cdn.go b/commands/cdn/cdn.go new file mode 100644 index 000000000..8e7ed19be --- /dev/null +++ b/commands/cdn/cdn.go @@ -0,0 +1,19 @@ +package cdn + +import ( + "github.com/ionos-cloud/ionosctl/v6/commands/cdn/distribution" + "github.com/ionos-cloud/ionosctl/v6/internal/core" + "github.com/spf13/cobra" +) + +func Command() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "cdn", + Short: "The sub-commands of the 'cdn' resource help manage CDN distributions", + TraverseChildren: true, + }, + } + cmd.AddCommand(distribution.Command()) + return cmd +} diff --git a/commands/cdn/completer/completer.go b/commands/cdn/completer/completer.go new file mode 100644 index 000000000..98d7eab1e --- /dev/null +++ b/commands/cdn/completer/completer.go @@ -0,0 +1,37 @@ +package completer + +import ( + "context" + "github.com/ionos-cloud/ionosctl/v6/internal/client" + "github.com/ionos-cloud/ionosctl/v6/pkg/functional" + cdn "github.com/ionos-cloud/sdk-go-cdn" +) + +// DistributionsProperty returns a list of properties of all distributions matching the given filters +func DistributionsProperty[V any](f func(cdn.Distribution) V, fs ...Filter) []V { + recs, err := Distributions(fs...) + if err != nil { + return nil + } + return functional.Map(*recs.Items, f) +} + +// Distributions returns all distributions matching the given filters +func Distributions(fs ...Filter) (cdn.Distributions, error) { + req := client.Must().CDNClient.DistributionsApi.DistributionsGet(context.Background()) + for _, f := range fs { + var err error + req, err = f(req) + if err != nil { + return cdn.Distributions{}, err + } + } + + ls, _, err := req.Execute() + if err != nil { + return cdn.Distributions{}, err + } + return ls, nil +} + +type Filter func(request cdn.ApiDistributionsGetRequest) (cdn.ApiDistributionsGetRequest, error) diff --git a/commands/cdn/distribution/create.go b/commands/cdn/distribution/create.go new file mode 100644 index 000000000..3be7b0618 --- /dev/null +++ b/commands/cdn/distribution/create.go @@ -0,0 +1,150 @@ +package distribution + +import ( + "context" + "encoding/json" + "fmt" + "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/pkg/pointer" + "github.com/ionos-cloud/ionosctl/v6/pkg/uuidgen" + cdn "github.com/ionos-cloud/sdk-go-cdn" + "github.com/spf13/viper" + "os" +) + +func Create() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "cdn", + Resource: "distribution", + Verb: "create", + Aliases: []string{"c", "post"}, + ShortDesc: "Create a CDN distribution. Wiki: https://docs.ionos.com/cloud/network-services/cdn/dcd-how-tos/create-cdn-distribution", + Example: "ionosctl cdn ds create --domain foo-bar.com --certificate-id id --routing-rules rules.json", + PreCmdRun: func(c *core.PreCommandConfig) error { + if err := core.CheckRequiredFlagsSets(c.Command, c.NS, + []string{constants.FlagCDNDistributionDomain, constants.FlagCDNDistributionRoutingRules}, + []string{constants.FlagCDNDistributionRoutingRulesExample}); err != nil { + return err + } + + return nil + }, + CmdRun: func(c *core.CommandConfig) error { + if viper.GetBool(core.GetFlagName(c.NS, constants.FlagCDNDistributionRoutingRulesExample)) { + fmt.Fprintf(c.Command.Command.OutOrStdout(), RoutingRuleExample) + return nil + } + + input := &cdn.DistributionProperties{} + if err := setPropertiesFromFlags(c, input); err != nil { + return err + } + + id := uuidgen.Must() + res, _, err := client.Must().CDNClient.DistributionsApi.DistributionsPut(context.Background(), id). + DistributionUpdate(cdn.DistributionUpdate{ + Id: &id, + Properties: input, + }).Execute() + if err != nil { + return err + } + + return printDistribution(c, res) + }, + InitClient: true, + }) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + return addDistributionCreateFlags(cmd) +} + +func addDistributionCreateFlags(cmd *core.Command) *core.Command { + cmd.AddStringFlag(constants.FlagCDNDistributionDomain, "", "", "The domain of the distribution") + cmd.AddStringFlag(constants.FlagCDNDistributionCertificateID, "", "", "The ID of the certificate") + cmd.AddStringFlag(constants.FlagCDNDistributionRoutingRules, "", "", "The routing rules of the distribution. JSON string or file path of routing rules") + cmd.AddBoolFlag(constants.FlagCDNDistributionRoutingRulesExample, "", false, "Print an example of routing rules") + return cmd +} + +func setPropertiesFromFlags(c *core.CommandConfig, p *cdn.DistributionProperties) error { + if fn := core.GetFlagName(c.NS, constants.FlagCDNDistributionDomain); viper.IsSet(fn) { + p.Domain = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagCDNDistributionCertificateID); viper.IsSet(fn) { + p.CertificateId = pointer.From(viper.GetString(fn)) + } + + if fn := core.GetFlagName(c.NS, constants.FlagCDNDistributionRoutingRules); viper.IsSet(fn) { + rr := viper.GetString(fn) + data, err := getRoutingRulesData(rr) + if err != nil { + return fmt.Errorf("error reading routing rules file: %s", err) + } + + rules, err := getRoutingRulesFromJSON(data) + if err != nil { + return fmt.Errorf("error parsing routing rules: %s", err) + } + p.RoutingRules = rules + } + + return nil +} + +func getRoutingRulesFromJSON(data []byte) (*[]cdn.RoutingRule, error) { + var rr []cdn.RoutingRule + err := json.Unmarshal(data, &rr) + if err != nil { + return nil, err + } + return &rr, nil +} + +func getRoutingRulesData(input string) ([]byte, error) { + switch _, err := os.Stat(input); { + case err == nil: + return os.ReadFile(input) + case os.IsNotExist(err): + return []byte(input), nil + default: + return nil, err + } +} + +const RoutingRuleExample = ` +[ + { + "prefix": "/api", + "scheme": "http/https", + "upstream": { + "caching": true, + "geoRestrictions": { + "allowList": ["CN", "RU"] + }, + "host": "clitest.example.com", + "rateLimitClass": "R500", + "sniMode": "distribution", + "waf": true + } + }, + { + "prefix": "/api2", + "scheme": "http/https", + "upstream": { + "caching": false, + "geoRestrictions": { + "blockList": ["CN", "RU"] + }, + "host": "server2.example.com", + "rateLimitClass": "R10", + "sniMode": "origin", + "waf": false + } + } +] +` diff --git a/commands/cdn/distribution/delete.go b/commands/cdn/distribution/delete.go new file mode 100644 index 000000000..e89dc495a --- /dev/null +++ b/commands/cdn/distribution/delete.go @@ -0,0 +1,62 @@ +package distribution + +import ( + "context" + "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/pkg/confirm" + cdn "github.com/ionos-cloud/sdk-go-cdn" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "github.com/ionos-cloud/ionosctl/v6/internal/core" +) + +func Delete() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "cdn", + Resource: "distribution", + Verb: "delete", + Aliases: []string{"del", "d"}, + ShortDesc: "Delete a distribution", + Example: `ionosctl cdn ds delete --distribution-id ID`, + PreCmdRun: func(c *core.PreCommandConfig) error { + if err := core.CheckRequiredFlags(c.Command, c.NS, constants.FlagCDNDistributionID); err != nil { + return err + } + + return nil + }, + CmdRun: func(c *core.CommandConfig) error { + distributionID := viper.GetString(core.GetFlagName(c.NS, constants.FlagCDNDistributionID)) + d, _, err := client.Must().CDNClient.DistributionsApi.DistributionsFindById(context.Background(), distributionID).Execute() + if err != nil { + return fmt.Errorf("distribution not found: %w", err) + } + + yes := confirm.FAsk(c.Command.Command.InOrStdin(), fmt.Sprintf("Are you sure you want to delete distribution %s for domain %s", *d.Id, *d.Properties.Domain), + viper.GetBool(constants.ArgForce)) + if !yes { + return fmt.Errorf("user cancelled deletion") + } + + _, err = client.Must().CDNClient.DistributionsApi.DistributionsDelete(context.Background(), *d.Id).Execute() + return err + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagCDNDistributionID, constants.FlagIdShort, "", "The ID of the distribution you want to retrieve", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagCDNDistributionID, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return completer.DistributionsProperty(func(r cdn.Distribution) string { + return *r.Id + }), cobra.ShellCompDirectiveNoFileComp + }) + + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return cmd +} diff --git a/commands/cdn/distribution/distribution.go b/commands/cdn/distribution/distribution.go new file mode 100644 index 000000000..74862cba7 --- /dev/null +++ b/commands/cdn/distribution/distribution.go @@ -0,0 +1,37 @@ +package distribution + +import ( + "github.com/ionos-cloud/ionosctl/v6/commands/cdn/distribution/routingrules" + "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", "Domain", "CertificateId", "State"} + defaultCols = []string{"Id", "Domain", "CertificateId", "State"} +) + +func Command() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "distribution", + Short: "The sub-commands of 'ionosctl cdn distribution' allow you to manage CDN distributions", + Aliases: []string{"ds"}, + 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(List()) + cmd.AddCommand(FindByID()) + cmd.AddCommand(Delete()) + cmd.AddCommand(Create()) + cmd.AddCommand(Update()) + cmd.AddCommand(routingrules.Root()) + return cmd +} diff --git a/commands/cdn/distribution/get.go b/commands/cdn/distribution/get.go new file mode 100644 index 000000000..47b29f7c3 --- /dev/null +++ b/commands/cdn/distribution/get.go @@ -0,0 +1,64 @@ +package distribution + +import ( + "context" + "fmt" + "github.com/ionos-cloud/ionosctl/v6/commands/cdn/completer" + cdn "github.com/ionos-cloud/sdk-go-cdn" + "github.com/spf13/cobra" + + "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 FindByID() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "cdn", + Resource: "distribution", + Verb: "get", + Aliases: []string{"g"}, + ShortDesc: "Retrieve a distribution", + Example: "ionosctl cdn ds get --distribution-id ID", + PreCmdRun: func(c *core.PreCommandConfig) error { + if err := core.CheckRequiredFlags(c.Command, c.NS, constants.FlagCDNDistributionID); err != nil { + return err + } + + return nil + }, + CmdRun: func(c *core.CommandConfig) error { + distributionID := viper.GetString(core.GetFlagName(c.NS, constants.FlagCDNDistributionID)) + r, _, err := client.Must().CDNClient.DistributionsApi.DistributionsFindById(context.Background(), + distributionID, + ).Execute() + if err != nil { + return err + } + + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutput("", jsonpaths.CDNDistribution, r, + tabheaders.GetHeadersAllDefault(defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + InitClient: true, + }) + cmd.AddStringFlag(constants.FlagCDNDistributionID, constants.FlagIdShort, "", "The ID of the distribution you want to retrieve", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagCDNDistributionID, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return completer.DistributionsProperty(func(r cdn.Distribution) string { + return *r.Id + }), cobra.ShellCompDirectiveNoFileComp + }) + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + return cmd +} diff --git a/commands/cdn/distribution/list.go b/commands/cdn/distribution/list.go new file mode 100644 index 000000000..e500797d9 --- /dev/null +++ b/commands/cdn/distribution/list.go @@ -0,0 +1,92 @@ +package distribution + +import ( + "context" + "fmt" + "github.com/ionos-cloud/ionosctl/v6/commands/cdn/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" + "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" + cdn "github.com/ionos-cloud/sdk-go-cdn" + "github.com/spf13/viper" +) + +func List() *core.Command { + cmd := core.NewCommand( + context.Background(), nil, core.CommandBuilder{ + Namespace: "cdn", + Resource: "distribution", + Verb: "list", + Aliases: []string{"ls"}, + ShortDesc: "Retrieve all distributions using pagination and optional filters", + Example: `ionosctl cdn ds list`, + PreCmdRun: func(c *core.PreCommandConfig) error { + return nil + }, + CmdRun: func(c *core.CommandConfig) error { + return listDistributions(c) + }, + InitClient: true, + }, + ) + + cmd.AddStringFlag(constants.FlagCDNDistributionFilterDomain, "", "", "Filter used to fetch only the records that contain specified domain.") + cmd.AddSetFlag(constants.FlagCDNDistributionFilterState, "", "", []string{"AVAILABLE", "BUSY", "FAILED", "UNKNOWN"}, "Filter used to fetch only the records that contain specified state.") + cmd.AddInt32Flag(constants.FlagOffset, "", 0, "The first element (of the total list of elements) to include in the response. Use together with limit for pagination") + cmd.AddInt32Flag(constants.FlagMaxResults, "", 0, constants.DescMaxResults) + + cmd.Command.PersistentFlags().StringSlice( + constants.ArgCols, nil, + fmt.Sprintf( + "Set of columns to be printed on output \nAvailable columns: %v", + allCols, + ), + ) + + return cmd +} + +func listDistributions(c *core.CommandConfig) error { + ls, err := completer.Distributions( + func(req cdn.ApiDistributionsGetRequest) (cdn.ApiDistributionsGetRequest, error) { + if fn := core.GetFlagName(c.NS, constants.FlagCDNDistributionFilterState); viper.IsSet(fn) { + req = req.FilterState(viper.GetString(fn)) + } + if fn := core.GetFlagName(c.NS, constants.FlagCDNDistributionFilterDomain); viper.IsSet(fn) { + req = req.FilterDomain(viper.GetString(fn)) + } + 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 cdn distributions: %w", err) + } + + items, ok := ls.GetItemsOk() + if !ok || items == nil { + return fmt.Errorf("could not retrieve distributions") + } + + convertedItems, err := json2table.ConvertJSONToTable("", jsonpaths.CDNDistribution, *items) + 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, convertedItems, tabheaders.GetHeaders(allCols, defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil +} diff --git a/commands/cdn/distribution/routingrules/routing_rules.go b/commands/cdn/distribution/routingrules/routing_rules.go new file mode 100644 index 000000000..d2c09acf3 --- /dev/null +++ b/commands/cdn/distribution/routingrules/routing_rules.go @@ -0,0 +1,90 @@ +package routingrules + +import ( + "context" + "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" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table" + "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" + cdn "github.com/ionos-cloud/sdk-go-cdn" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +var ( + allRoutingRulesColumns = []string{"Scheme", "Prefix", "Host", "Caching", "Waf", "RateLimitClass", "SniMode", "GeoRestrictionsAllowList", "GeoRestrictionsBlockList"} + defaultRoutingRulesColumns = []string{"Scheme", "Prefix", "Host", "RateLimitClass", "SniMode"} +) + +func Root() *core.Command { + cmd := &core.Command{ + Command: &cobra.Command{ + Use: "routingrules", + Aliases: []string{"rr"}, + Short: "Commands related to distribution routing rules", + TraverseChildren: true, + }, + } + + cmd.AddCommand(GetDistributionRoutingRules()) + return cmd +} + +func GetDistributionRoutingRules() *core.Command { + cmd := core.NewCommand(context.Background(), nil, core.CommandBuilder{ + Namespace: "cdn", + Resource: "routingrules", + Verb: "get", + Aliases: []string{"g"}, + ShortDesc: "Retrieve a distribution routing rules", + Example: "ionosctl cdn ds rr get --distribution-id ID", + PreCmdRun: func(c *core.PreCommandConfig) error { + if err := core.CheckRequiredFlags(c.Command, c.NS, constants.FlagCDNDistributionID); err != nil { + return err + } + + return nil + }, + CmdRun: func(c *core.CommandConfig) error { + distributionID := viper.GetString(core.GetFlagName(c.NS, constants.FlagCDNDistributionID)) + r, _, err := client.Must().CDNClient.DistributionsApi.DistributionsFindById(context.Background(), + distributionID).Execute() + if err != nil { + return err + } + + if r.Properties.RoutingRules == nil { + return nil + } + + convertedItems, err := json2table.ConvertJSONToTable("", jsonpaths.CDNRoutingRule, *r.Properties.RoutingRules) + 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(*r.Properties.RoutingRules, convertedItems, tabheaders.GetHeaders(allRoutingRulesColumns, defaultRoutingRulesColumns, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil + }, + InitClient: true, + }) + cmd.AddStringFlag(constants.FlagCDNDistributionID, constants.FlagIdShort, "", "The ID of the distribution you want to retrieve", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagCDNDistributionID, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return completer.DistributionsProperty(func(r cdn.Distribution) string { + return *r.Id + }), cobra.ShellCompDirectiveNoFileComp + }) + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + return cmd +} diff --git a/commands/cdn/distribution/update.go b/commands/cdn/distribution/update.go new file mode 100644 index 000000000..f2ff4305f --- /dev/null +++ b/commands/cdn/distribution/update.go @@ -0,0 +1,90 @@ +package distribution + +import ( + "context" + "fmt" + "github.com/ionos-cloud/ionosctl/v6/commands/cdn/completer" + "github.com/spf13/cobra" + + "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/jsonpaths" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter" + "github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders" + cdn "github.com/ionos-cloud/sdk-go-cdn" + "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: "cdn", + Resource: "distribution", + Verb: "update", + Aliases: []string{"u"}, + ShortDesc: "Partially modify a distribution's properties. This command uses a combination of GET and PUT to simulate a PATCH operation", + Example: "ionosctl cdn ds update --distribution-id", + PreCmdRun: func(c *core.PreCommandConfig) error { + if err := core.CheckRequiredFlags(c.Command, c.NS, constants.FlagCDNDistributionID); err != nil { + return err + } + + return nil + }, + CmdRun: func(c *core.CommandConfig) error { + distributionId := viper.GetString(core.GetFlagName(c.NS, constants.FlagCDNDistributionID)) + r, _, err := client.Must().CDNClient.DistributionsApi.DistributionsFindById(context.Background(), distributionId).Execute() + if err != nil { + return fmt.Errorf("failed finding distribution: %w", err) + } + + updated, err := updateDistribution(c, r) + if err != nil { + return err + } + + return printDistribution(c, updated) + }, + InitClient: true, + }) + + cmd.AddStringFlag(constants.FlagCDNDistributionID, constants.FlagIdShort, "", "The ID of the CDN distribution", core.RequiredFlagOption()) + _ = cmd.Command.RegisterFlagCompletionFunc(constants.FlagCDNDistributionID, func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return completer.DistributionsProperty(func(r cdn.Distribution) string { + return *r.Id + }), cobra.ShellCompDirectiveNoFileComp + }) + cmd.Command.SilenceUsage = true + cmd.Command.Flags().SortFlags = false + + return addDistributionCreateFlags(cmd) +} + +func updateDistribution(c *core.CommandConfig, d cdn.Distribution) (cdn.Distribution, error) { + input := d.Properties + err := setPropertiesFromFlags(c, input) + if err != nil { + return cdn.Distribution{}, err + } + + rNew, _, err := client.Must().CDNClient.DistributionsApi.DistributionsPut(context.Background(), *d.Id). + DistributionUpdate(cdn.DistributionUpdate{Id: d.Id, Properties: input}).Execute() + if err != nil { + return cdn.Distribution{}, err + } + + return rNew, nil +} + +func printDistribution(c *core.CommandConfig, d cdn.Distribution) error { + cols, _ := c.Command.Command.Flags().GetStringSlice(constants.ArgCols) + out, err := jsontabwriter.GenerateOutput("", jsonpaths.CDNDistribution, d, + tabheaders.GetHeadersAllDefault(defaultCols, cols)) + if err != nil { + return err + } + + fmt.Fprintf(c.Command.Command.OutOrStdout(), out) + return nil +} diff --git a/commands/root.go b/commands/root.go index 282be519b..686090116 100644 --- a/commands/root.go +++ b/commands/root.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "github.com/ionos-cloud/ionosctl/v6/commands/cdn" "os" "strings" @@ -249,6 +250,9 @@ func addCommands() { logging_service.LoggingServiceCmd(), constants.DefaultLoggingServiceApiURL, ), ) + + // CDN + rootCmd.AddCommand(cdn.Command()) } const ( diff --git a/docs/subcommands/CDN/distribution/create.md b/docs/subcommands/CDN/distribution/create.md new file mode 100644 index 000000000..82dab51ad --- /dev/null +++ b/docs/subcommands/CDN/distribution/create.md @@ -0,0 +1,55 @@ +--- +description: "Create a CDN distribution. Wiki: https://docs.ionos.com/cloud/network-services/cdn/dcd-how-tos/create-cdn-distribution" +--- + +# CdnDistributionCreate + +## Usage + +```text +ionosctl cdn distribution create [flags] +``` + +## Aliases + +For `distribution` command: + +```text +[ds] +``` + +For `create` command: + +```text +[c post] +``` + +## Description + +Create a CDN distribution. Wiki: https://docs.ionos.com/cloud/network-services/cdn/dcd-how-tos/create-cdn-distribution + +## Options + +```text + -u, --api-url string Override default host url (default "https://api.ionos.com") + --certificate-id string The ID of the certificate + --cols strings Set of columns to be printed on output + Available columns: [Id Domain CertificateId State] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --domain string The domain of the distribution + -f, --force Force command to execute without user input + -h, --help Print usage + --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 + --routing-rules string The routing rules of the distribution. JSON string or file path of routing rules + --routing-rules-example Print an example of routing rules + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl cdn ds create --domain foo-bar.com --certificate-id id --routing-rules rules.json +``` + diff --git a/docs/subcommands/CDN/distribution/delete.md b/docs/subcommands/CDN/distribution/delete.md new file mode 100644 index 000000000..daca358b1 --- /dev/null +++ b/docs/subcommands/CDN/distribution/delete.md @@ -0,0 +1,52 @@ +--- +description: "Delete a distribution" +--- + +# CdnDistributionDelete + +## Usage + +```text +ionosctl cdn distribution delete [flags] +``` + +## Aliases + +For `distribution` command: + +```text +[ds] +``` + +For `delete` command: + +```text +[del d] +``` + +## Description + +Delete a distribution + +## Options + +```text + -u, --api-url string Override default host url (default "https://api.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [Id Domain CertificateId State] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -i, --distribution-id string The ID of the distribution you want to retrieve (required) + -f, --force Force command to execute without user input + -h, --help Print usage + --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 cdn ds delete --distribution-id ID +``` + diff --git a/docs/subcommands/CDN/distribution/get.md b/docs/subcommands/CDN/distribution/get.md new file mode 100644 index 000000000..30cbb9050 --- /dev/null +++ b/docs/subcommands/CDN/distribution/get.md @@ -0,0 +1,52 @@ +--- +description: "Retrieve a distribution" +--- + +# CdnDistributionGet + +## Usage + +```text +ionosctl cdn distribution get [flags] +``` + +## Aliases + +For `distribution` command: + +```text +[ds] +``` + +For `get` command: + +```text +[g] +``` + +## Description + +Retrieve a distribution + +## Options + +```text + -u, --api-url string Override default host url (default "https://api.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [Id Domain CertificateId State] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -i, --distribution-id string The ID of the distribution you want to retrieve (required) + -f, --force Force command to execute without user input + -h, --help Print usage + --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 cdn ds get --distribution-id ID +``` + diff --git a/docs/subcommands/CDN/distribution/list.md b/docs/subcommands/CDN/distribution/list.md new file mode 100644 index 000000000..ac174844b --- /dev/null +++ b/docs/subcommands/CDN/distribution/list.md @@ -0,0 +1,55 @@ +--- +description: "Retrieve all distributions using pagination and optional filters" +--- + +# CdnDistributionList + +## Usage + +```text +ionosctl cdn distribution list [flags] +``` + +## Aliases + +For `distribution` command: + +```text +[ds] +``` + +For `list` command: + +```text +[ls] +``` + +## Description + +Retrieve all distributions using pagination and optional filters + +## Options + +```text + -u, --api-url string Override default host url (default "https://api.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [Id Domain CertificateId State] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + --domain string Filter used to fetch only the records that contain specified domain. + -f, --force Force command to execute without user input + -h, --help Print usage + --max-results int32 The maximum number of elements to return + --no-headers Don't print table headers when table output is used + --offset int32 The first element (of the total list of elements) to include in the response. Use together with limit for pagination + -o, --output string Desired output format [text|json|api-json] (default "text") + -q, --quiet Quiet output + --state string Filter used to fetch only the records that contain specified state.. Can be one of: AVAILABLE, BUSY, FAILED, UNKNOWN + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl cdn ds list +``` + diff --git a/docs/subcommands/CDN/distribution/routingrules/get.md b/docs/subcommands/CDN/distribution/routingrules/get.md new file mode 100644 index 000000000..d286c7661 --- /dev/null +++ b/docs/subcommands/CDN/distribution/routingrules/get.md @@ -0,0 +1,58 @@ +--- +description: "Retrieve a distribution routing rules" +--- + +# CdnDistributionRoutingrulesGet + +## Usage + +```text +ionosctl cdn distribution routingrules get [flags] +``` + +## Aliases + +For `distribution` command: + +```text +[ds] +``` + +For `routingrules` command: + +```text +[rr] +``` + +For `get` command: + +```text +[g] +``` + +## Description + +Retrieve a distribution routing rules + +## Options + +```text + -u, --api-url string Override default host url (default "https://api.ionos.com") + --cols strings Set of columns to be printed on output + Available columns: [Id Domain CertificateId State] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -i, --distribution-id string The ID of the distribution you want to retrieve (required) + -f, --force Force command to execute without user input + -h, --help Print usage + --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 cdn ds rr get --distribution-id ID +``` + diff --git a/docs/subcommands/CDN/distribution/update.md b/docs/subcommands/CDN/distribution/update.md new file mode 100644 index 000000000..56733097e --- /dev/null +++ b/docs/subcommands/CDN/distribution/update.md @@ -0,0 +1,56 @@ +--- +description: "Partially modify a distribution's properties. This command uses a combination of GET and PUT to simulate a PATCH operation" +--- + +# CdnDistributionUpdate + +## Usage + +```text +ionosctl cdn distribution update [flags] +``` + +## Aliases + +For `distribution` command: + +```text +[ds] +``` + +For `update` command: + +```text +[u] +``` + +## Description + +Partially modify a distribution's properties. This command uses a combination of GET and PUT to simulate a PATCH operation + +## Options + +```text + -u, --api-url string Override default host url (default "https://api.ionos.com") + --certificate-id string The ID of the certificate + --cols strings Set of columns to be printed on output + Available columns: [Id Domain CertificateId State] + -c, --config string Configuration file used for authentication (default "$XDG_CONFIG_HOME/ionosctl/config.json") + -i, --distribution-id string The ID of the CDN distribution (required) + --domain string The domain of the distribution + -f, --force Force command to execute without user input + -h, --help Print usage + --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 + --routing-rules string The routing rules of the distribution. JSON string or file path of routing rules + --routing-rules-example Print an example of routing rules + -v, --verbose Print step-by-step process when running command +``` + +## Examples + +```text +ionosctl cdn ds update --distribution-id +``` + diff --git a/docs/summary.md b/docs/summary.md index b8f97bb80..7252e9f94 100644 --- a/docs/summary.md +++ b/docs/summary.md @@ -34,6 +34,15 @@ * [get](subcommands%2FAuthentication%2Ftoken%2Fget.md) * [list](subcommands%2FAuthentication%2Ftoken%2Flist.md) * [parse](subcommands%2FAuthentication%2Ftoken%2Fparse.md) +* CDN + * distribution + * [create](subcommands%2FCDN%2Fdistribution%2Fcreate.md) + * [delete](subcommands%2FCDN%2Fdistribution%2Fdelete.md) + * [get](subcommands%2FCDN%2Fdistribution%2Fget.md) + * [list](subcommands%2FCDN%2Fdistribution%2Flist.md) + * routingrules + * [get](subcommands%2FCDN%2Fdistribution%2Froutingrules%2Fget.md) + * [update](subcommands%2FCDN%2Fdistribution%2Fupdate.md) * CLI Setup * [location](subcommands%2FCLI%20Setup%2Flocation.md) * [login](subcommands%2FCLI%20Setup%2Flogin.md) diff --git a/go.mod b/go.mod index 7e756e9da..c9555dcf4 100644 --- a/go.mod +++ b/go.mod @@ -40,6 +40,7 @@ require ( require ( github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4 + github.com/ionos-cloud/sdk-go-cdn v1.1.0 github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.0.0 ) @@ -75,7 +76,7 @@ require ( github.com/spf13/cast v1.5.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect - golang.org/x/oauth2 v0.20.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 4cb7df4ee..eeb357ab5 100644 --- a/go.sum +++ b/go.sum @@ -246,6 +246,8 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/ionos-cloud/sdk-go-auth v1.0.6 h1:N7XQ8JLKM9OS1DDlDCIN3Nk4RV4MuNvHFd50evuWgSM= github.com/ionos-cloud/sdk-go-auth v1.0.6/go.mod h1:4MuUIZbnQjgNalEB9LUzIuBTI1keqgA7EpJsjEvMAls= +github.com/ionos-cloud/sdk-go-cdn v1.1.0 h1:bwtrey2m1mElQV9TlhzR39mC6IMeWF2P5ztd6cmRKfw= +github.com/ionos-cloud/sdk-go-cdn v1.1.0/go.mod h1:W2XZ5CYhKROyvtLaz3VgTKe+nXI1+NZD1gE/YliHUeU= github.com/ionos-cloud/sdk-go-cert-manager v1.0.1 h1:QGnenRREavvU0ZrXvY4hmCMXRyvmKj5jaXsFX9Apfd0= github.com/ionos-cloud/sdk-go-cert-manager v1.0.1/go.mod h1:EYDegkY6fUSkx0BL0GpNMpKvp33AId2vTZL44YLPreA= github.com/ionos-cloud/sdk-go-container-registry v1.1.0 h1:H92gzx9oj0vvbozbXwn2RLNEw7++1Ns3Kl9PGrh5Waw= @@ -578,8 +580,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/internal/client/model.go b/internal/client/model.go index 6a26a6b23..b46ac7228 100644 --- a/internal/client/model.go +++ b/internal/client/model.go @@ -2,6 +2,7 @@ package client import ( "fmt" + cdn "github.com/ionos-cloud/sdk-go-cdn" "github.com/ionos-cloud/ionosctl/v6/internal/constants" sdkgoauth "github.com/ionos-cloud/sdk-go-auth" @@ -71,6 +72,7 @@ type Client struct { PostgresClient *postgres.APIClient MongoClient *mongo.APIClient MariaClient *maria.APIClient + CDNClient *cdn.APIClient } func appendUserAgent(userAgent string) string { @@ -113,6 +115,9 @@ func newClient(name, pwd, token, hostUrl string, usedLayer *Layer) *Client { mariaConfig := maria.NewConfiguration(name, pwd, token, hostUrl) mariaConfig.UserAgent = appendUserAgent(mariaConfig.UserAgent) + cdnConfig := cdn.NewConfiguration(name, pwd, token, hostUrl) + cdnConfig.UserAgent = appendUserAgent(cdnConfig.UserAgent) + return &Client{ CloudClient: cloudv6.NewAPIClient(clientConfig), AuthClient: sdkgoauth.NewAPIClient(authConfig), @@ -126,6 +131,7 @@ func newClient(name, pwd, token, hostUrl string, usedLayer *Layer) *Client { PostgresClient: postgres.NewAPIClient(postgresConfig), MongoClient: mongo.NewAPIClient(mongoConfig), MariaClient: maria.NewAPIClient(mariaConfig), + CDNClient: cdn.NewAPIClient(cdnConfig), usedLayer: usedLayer, } diff --git a/internal/constants/constants.go b/internal/constants/constants.go index aa94709d6..3accd89d7 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -78,6 +78,14 @@ Within each layer, a token takes precedence over a username and password combina FlagLoggingPipelineLogType = "log-type" FlagLoggingPipelineLogRetentionTime = "log-retention-time" + FlagCDNDistributionFilterDomain = "domain" + FlagCDNDistributionFilterState = "state" + FlagCDNDistributionID = "distribution-id" + FlagCDNDistributionDomain = "domain" + FlagCDNDistributionCertificateID = "certificate-id" + FlagCDNDistributionRoutingRules = "routing-rules" + FlagCDNDistributionRoutingRulesExample = "routing-rules-example" + FlagGroupId = "group-id" FlagServerId = "server-id" FlagActionId = "action-id" diff --git a/internal/core/doc/doc.go b/internal/core/doc/doc.go index 155cffed5..d91c76ad2 100644 --- a/internal/core/doc/doc.go +++ b/internal/core/doc/doc.go @@ -36,6 +36,7 @@ var nonComputeNamespaces = map[string]string{ "k8s": "Managed-Kubernetes", "user": "User-Management", "dns": "DNS", + "cdn": "CDN", "config": "CLI Setup", "vm-autoscaling": "VM Autoscaling", "logging-service": "Logging-Service", diff --git a/internal/printer/json2table/jsonpaths/cdn.go b/internal/printer/json2table/jsonpaths/cdn.go new file mode 100644 index 000000000..b27fcd88c --- /dev/null +++ b/internal/printer/json2table/jsonpaths/cdn.go @@ -0,0 +1,20 @@ +package jsonpaths + +var CDNDistribution = map[string]string{ + "Id": "id", + "Domain": "properties.domain", + "CertificateId": "properties.certificateId", + "State": "metadata.state", +} + +var CDNRoutingRule = map[string]string{ + "Scheme": "scheme", + "Prefix": "prefix", + "Host": "upstream.host", + "Caching": "upstream.caching", + "Waf": "upstream.waf", + "SniMode": "upstream.sniMode", + "GeoRestrictionsAllowList": "upstream.geoRestrictions.allowList", + "GeoRestrictionsBlockList": "upstream.geoRestrictions.blockList", + "RateLimitClass": "upstream.rateLimitClass", +} diff --git a/test/bats/cdn/cdn.bats b/test/bats/cdn/cdn.bats new file mode 100755 index 000000000..09e109d6b --- /dev/null +++ b/test/bats/cdn/cdn.bats @@ -0,0 +1,128 @@ +#!/usr/bin/env bats + +# tags: cdn + +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' + + +setup_file() { + export IONOS_TOKEN=$(ionosctl token generate) + mkdir -p /tmp/bats_test +} + +@test "Create cdn distribution" { + RULES='[ + { + "prefix": "/api", + "scheme": "http/https", + "upstream": { + "caching": true, + "geoRestrictions": { + "allowList": ["CN", "RU"] + }, + "host": "clitest.example.com", + "rateLimitClass": "R500", + "sniMode": "distribution", + "waf": true + } + }, + { + "prefix": "/api2", + "scheme": "http/https", + "upstream": { + "caching": false, + "geoRestrictions": { + "blockList": ["CN", "RU"] + }, + "host": "server2.example.com", + "rateLimitClass": "R10", + "sniMode": "origin", + "waf": false + } + } + ]' + run ionosctl cdn ds create --domain site.$(randStr 6).com --certificate-id 24e82787-a60e-4f18-8764-856bafc378b4 --routing-rules "$RULES" -o json 2> /dev/null + assert_success + + distribution_id=$(echo "$output" | jq -r '.id') + assert_regex "$distribution_id" "$uuid_v4_regex" + + echo "created cdn distribution $distribution_id" + echo "$distribution_id" > /tmp/bats_test/distribution_id +} + +@test "List and retrieve cdn distribution by ID" { + run ionosctl cdn ds list -o json 2> /dev/null + assert_success + + distribution_id=$(cat /tmp/bats_test/distribution_id) + run ionosctl cdn ds get --distribution-id "${distribution_id}" -o json 2> /dev/null + assert_success +} + +@test "Update CDN distribution" { + RULES_UPDATED=' + [ + { + "prefix": "/api", + "scheme": "http/https", + "upstream": { + "caching": true, + "geoRestrictions": { + "allowList": [ + "CN", + "RU" + ] + }, + "host": "clitest.example.com", + "rateLimitClass": "R500", + "sniMode": "distribution", + "waf": true + } + }, + { + "prefix": "/api2", + "scheme": "http/https", + "upstream": { + "caching": false, + "geoRestrictions": { + "blockList": [ + "CN", + "RU" + ] + }, + "host": "server2.example.com", + "rateLimitClass": "R10", + "sniMode": "origin", + "waf": false + } + } + ]' + distribution_id=$(cat /tmp/bats_test/distribution_id) + run ionosctl cdn ds update --distribution-id "${distribution_id}" --routing-rules "$RULES_UPDATED" -o json 2> /dev/null + assert_success +} + +@test "Get routing rules for CDN distribution" { + distribution_id=$(cat /tmp/bats_test/distribution_id) + run ionosctl cdn ds rr get --distribution-id "${distribution_id}" -o json 2> /dev/null + assert_success + + record_count=$(echo "$output" | jq '.items' | jq length) + assert [ "$record_count" -eq 2 ] +} + +teardown_file() { + distribution_id=$(cat /tmp/bats_test/distribution_id) + + echo "cleaning up cdn distribution $distribution_id" + run ionosctl cdn ds delete --distribution-id "$distribution_id" -f + + run ionosctl token delete --token "$IONOS_TOKEN" -f + unset IONOS_TOKEN + + rm -rf /tmp/bats_test +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/.gitbook.yaml b/vendor/github.com/ionos-cloud/sdk-go-cdn/.gitbook.yaml new file mode 100644 index 000000000..6c8fbd82b --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/.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-cdn/.gitignore b/vendor/github.com/ionos-cloud/sdk-go-cdn/.gitignore new file mode 100644 index 000000000..daf913b1b --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/.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-cdn/.travis.yml b/vendor/github.com/ionos-cloud/sdk-go-cdn/.travis.yml new file mode 100644 index 000000000..f5cb2ce9a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/.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-cdn/LICENSE b/vendor/github.com/ionos-cloud/sdk-go-cdn/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/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-cdn/README.md b/vendor/github.com/ionos-cloud/sdk-go-cdn/README.md new file mode 100644 index 000000000..f361fb309 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/README.md @@ -0,0 +1,127 @@ +# Go API client for ionoscloud + +This API manages CDN distributions. + + +## 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: 1.2.0 +- Package version: 1.1.0 +- Build package: org.openapitools.codegen.languages.GoClientCodegen + +## 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-cdn" +``` + +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://cdn.de-fra.ionos.com* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*DistributionsApi* | [**DistributionsDelete**](docs/api/DistributionsApi.md#distributionsdelete) | **Delete** /distributions/{distributionId} | Delete Distribution +*DistributionsApi* | [**DistributionsFindById**](docs/api/DistributionsApi.md#distributionsfindbyid) | **Get** /distributions/{distributionId} | Retrieve Distribution +*DistributionsApi* | [**DistributionsGet**](docs/api/DistributionsApi.md#distributionsget) | **Get** /distributions | Retrieve all Distributions +*DistributionsApi* | [**DistributionsPost**](docs/api/DistributionsApi.md#distributionspost) | **Post** /distributions | Create Distribution +*DistributionsApi* | [**DistributionsPut**](docs/api/DistributionsApi.md#distributionsput) | **Put** /distributions/{distributionId} | Ensure Distribution + + +## Documentation For Models + + - [Distribution](docs/models/Distribution.md) + - [DistributionCreate](docs/models/DistributionCreate.md) + - [DistributionMetadata](docs/models/DistributionMetadata.md) + - [DistributionProperties](docs/models/DistributionProperties.md) + - [DistributionUpdate](docs/models/DistributionUpdate.md) + - [Distributions](docs/models/Distributions.md) + - [DistributionsAllOf](docs/models/DistributionsAllOf.md) + - [Error](docs/models/Error.md) + - [ErrorMessages](docs/models/ErrorMessages.md) + - [IpAddresses](docs/models/IpAddresses.md) + - [Links](docs/models/Links.md) + - [Metadata](docs/models/Metadata.md) + - [Pagination](docs/models/Pagination.md) + - [ResourceState](docs/models/ResourceState.md) + - [RoutingRule](docs/models/RoutingRule.md) + - [Upstream](docs/models/Upstream.md) + - [UpstreamGeoRestrictions](docs/models/UpstreamGeoRestrictions.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 + + + diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/api_distributions.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/api_distributions.go new file mode 100644 index 000000000..8353f1247 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/api_distributions.go @@ -0,0 +1,1033 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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 +) + +// DistributionsApiService DistributionsApi service +type DistributionsApiService service + +type ApiDistributionsDeleteRequest struct { + ctx _context.Context + ApiService *DistributionsApiService + distributionId string +} + +func (r ApiDistributionsDeleteRequest) Execute() (*APIResponse, error) { + return r.ApiService.DistributionsDeleteExecute(r) +} + +/* + * DistributionsDelete Delete Distribution + * Deletes the specified Distribution. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param distributionId The ID (UUID) of the Distribution. + * @return ApiDistributionsDeleteRequest + */ +func (a *DistributionsApiService) DistributionsDelete(ctx _context.Context, distributionId string) ApiDistributionsDeleteRequest { + return ApiDistributionsDeleteRequest{ + ApiService: a, + ctx: ctx, + distributionId: distributionId, + } +} + +/* + * Execute executes the request + */ +func (a *DistributionsApiService) DistributionsDeleteExecute(r ApiDistributionsDeleteRequest) (*APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DistributionsApiService.DistributionsDelete") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/distributions/{distributionId}" + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", _neturl.PathEscape(parameterToString(r.distributionId, "")), -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: "DistributionsDelete", + } + + 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 ApiDistributionsFindByIdRequest struct { + ctx _context.Context + ApiService *DistributionsApiService + distributionId string +} + +func (r ApiDistributionsFindByIdRequest) Execute() (Distribution, *APIResponse, error) { + return r.ApiService.DistributionsFindByIdExecute(r) +} + +/* + * DistributionsFindById Retrieve Distribution + * Returns the Distribution by ID. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param distributionId The ID (UUID) of the Distribution. + * @return ApiDistributionsFindByIdRequest + */ +func (a *DistributionsApiService) DistributionsFindById(ctx _context.Context, distributionId string) ApiDistributionsFindByIdRequest { + return ApiDistributionsFindByIdRequest{ + ApiService: a, + ctx: ctx, + distributionId: distributionId, + } +} + +/* + * Execute executes the request + * @return Distribution + */ +func (a *DistributionsApiService) DistributionsFindByIdExecute(r ApiDistributionsFindByIdRequest) (Distribution, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Distribution + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DistributionsApiService.DistributionsFindById") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/distributions/{distributionId}" + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", _neturl.PathEscape(parameterToString(r.distributionId, "")), -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: "DistributionsFindById", + } + + 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 ApiDistributionsGetRequest struct { + ctx _context.Context + ApiService *DistributionsApiService + offset *int32 + limit *int32 + filterDomain *string + filterState *string +} + +func (r ApiDistributionsGetRequest) Offset(offset int32) ApiDistributionsGetRequest { + r.offset = &offset + return r +} +func (r ApiDistributionsGetRequest) Limit(limit int32) ApiDistributionsGetRequest { + r.limit = &limit + return r +} +func (r ApiDistributionsGetRequest) FilterDomain(filterDomain string) ApiDistributionsGetRequest { + r.filterDomain = &filterDomain + return r +} +func (r ApiDistributionsGetRequest) FilterState(filterState string) ApiDistributionsGetRequest { + r.filterState = &filterState + return r +} + +func (r ApiDistributionsGetRequest) Execute() (Distributions, *APIResponse, error) { + return r.ApiService.DistributionsGetExecute(r) +} + +/* + - DistributionsGet Retrieve all Distributions + - This endpoint enables retrieving all Distributions using + +pagination and optional filters. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @return ApiDistributionsGetRequest +*/ +func (a *DistributionsApiService) DistributionsGet(ctx _context.Context) ApiDistributionsGetRequest { + return ApiDistributionsGetRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return Distributions + */ +func (a *DistributionsApiService) DistributionsGetExecute(r ApiDistributionsGetRequest) (Distributions, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Distributions + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DistributionsApiService.DistributionsGet") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/distributions" + + 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, "")) + } + if r.filterDomain != nil { + localVarQueryParams.Add("filter.domain", parameterToString(*r.filterDomain, "")) + } + if r.filterState != nil { + localVarQueryParams.Add("filter.state", parameterToString(*r.filterState, "")) + } + // 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: "DistributionsGet", + } + + 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 ApiDistributionsPostRequest struct { + ctx _context.Context + ApiService *DistributionsApiService + distributionCreate *DistributionCreate +} + +func (r ApiDistributionsPostRequest) DistributionCreate(distributionCreate DistributionCreate) ApiDistributionsPostRequest { + r.distributionCreate = &distributionCreate + return r +} + +func (r ApiDistributionsPostRequest) Execute() (Distribution, *APIResponse, error) { + return r.ApiService.DistributionsPostExecute(r) +} + +/* + - DistributionsPost Create Distribution + - Creates a new Distribution. + +The full Distribution 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 ApiDistributionsPostRequest +*/ +func (a *DistributionsApiService) DistributionsPost(ctx _context.Context) ApiDistributionsPostRequest { + return ApiDistributionsPostRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return Distribution + */ +func (a *DistributionsApiService) DistributionsPostExecute(r ApiDistributionsPostRequest) (Distribution, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Distribution + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DistributionsApiService.DistributionsPost") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/distributions" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.distributionCreate == nil { + return localVarReturnValue, nil, reportError("distributionCreate 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.distributionCreate + 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: "DistributionsPost", + } + + 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 ApiDistributionsPutRequest struct { + ctx _context.Context + ApiService *DistributionsApiService + distributionId string + distributionUpdate *DistributionUpdate +} + +func (r ApiDistributionsPutRequest) DistributionUpdate(distributionUpdate DistributionUpdate) ApiDistributionsPutRequest { + r.distributionUpdate = &distributionUpdate + return r +} + +func (r ApiDistributionsPutRequest) Execute() (Distribution, *APIResponse, error) { + return r.ApiService.DistributionsPutExecute(r) +} + +/* + - DistributionsPut Ensure Distribution + - Ensures that the Distribution with the provided ID is created or modified. + +The full Distribution needs to be provided to ensure +(either update or create) the Distribution. 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 distributionId The ID (UUID) of the Distribution. + - @return ApiDistributionsPutRequest +*/ +func (a *DistributionsApiService) DistributionsPut(ctx _context.Context, distributionId string) ApiDistributionsPutRequest { + return ApiDistributionsPutRequest{ + ApiService: a, + ctx: ctx, + distributionId: distributionId, + } +} + +/* + * Execute executes the request + * @return Distribution + */ +func (a *DistributionsApiService) DistributionsPutExecute(r ApiDistributionsPutRequest) (Distribution, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Distribution + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DistributionsApiService.DistributionsPut") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/distributions/{distributionId}" + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", _neturl.PathEscape(parameterToString(r.distributionId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.distributionUpdate == nil { + return localVarReturnValue, nil, reportError("distributionUpdate 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.distributionUpdate + 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: "DistributionsPut", + } + + 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-cdn/client.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/client.go new file mode 100644 index 000000000..486021954 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/client.go @@ -0,0 +1,742 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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 = "1.1.0" +) + +// APIClient manages communication with the IONOS Cloud - CDN Distribution API API v1.2.0 +// 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 + + DistributionsApi *DistributionsApiService +} + +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.DistributionsApi = (*DistributionsApiService)(&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-cdn/configuration.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/configuration.go new file mode 100644 index 000000000..a7b7d4b33 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/configuration.go @@ -0,0 +1,292 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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://cdn.de-fra.ionos.com" + DefaultIonosBasePath = "" + defaultMaxRetries = 3 + defaultWaitTime = time.Duration(100) * time.Millisecond + defaultMaxWaitTime = time.Duration(2000) * time.Millisecond +) + +var ( + IonosServerUrls = []string{ + "https://cdn.de-fra.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-cdn/v1.1.0", + Debug: false, + Username: username, + Password: password, + Token: token, + MaxRetries: defaultMaxRetries, + MaxWaitTime: defaultMaxWaitTime, + WaitTime: defaultWaitTime, + Logger: NewDefaultLogger(), + LogLevel: getLogLevelFromEnv(), + Servers: ServerConfigurations{ + { + URL: getServerUrl(hostUrl), + Description: "Frankfurt", + }, + }, + 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-cdn/logger.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/logger.go new file mode 100644 index 000000000..a6cbe7df3 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/logger.go @@ -0,0 +1,80 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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-cdn/model_distribution.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution.go new file mode 100644 index 000000000..b2596f37c --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution.go @@ -0,0 +1,302 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Distribution struct for Distribution +type Distribution struct { + // The ID (UUID) of the Distribution. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the Distribution. + Href *string `json:"href"` + Metadata *DistributionMetadata `json:"metadata"` + Properties *DistributionProperties `json:"properties"` +} + +// NewDistribution instantiates a new Distribution 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 NewDistribution(id string, type_ string, href string, metadata DistributionMetadata, properties DistributionProperties) *Distribution { + this := Distribution{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Metadata = &metadata + this.Properties = &properties + + return &this +} + +// NewDistributionWithDefaults instantiates a new Distribution 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 NewDistributionWithDefaults() *Distribution { + this := Distribution{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Distribution) 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 *Distribution) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *Distribution) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *Distribution) 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 *Distribution) 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 *Distribution) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *Distribution) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *Distribution) 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 *Distribution) 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 *Distribution) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *Distribution) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *Distribution) 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 DistributionMetadata will be returned +func (o *Distribution) GetMetadata() *DistributionMetadata { + 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 *Distribution) GetMetadataOk() (*DistributionMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *Distribution) SetMetadata(v DistributionMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *Distribution) 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 DistributionProperties will be returned +func (o *Distribution) GetProperties() *DistributionProperties { + 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 *Distribution) GetPropertiesOk() (*DistributionProperties, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *Distribution) SetProperties(v DistributionProperties) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *Distribution) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o Distribution) 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 NullableDistribution struct { + value *Distribution + isSet bool +} + +func (v NullableDistribution) Get() *Distribution { + return v.value +} + +func (v *NullableDistribution) Set(val *Distribution) { + v.value = val + v.isSet = true +} + +func (v NullableDistribution) IsSet() bool { + return v.isSet +} + +func (v *NullableDistribution) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistribution(val *Distribution) *NullableDistribution { + return &NullableDistribution{value: val, isSet: true} +} + +func (v NullableDistribution) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistribution) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_create.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_create.go new file mode 100644 index 000000000..19a92e039 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_create.go @@ -0,0 +1,167 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// DistributionCreate struct for DistributionCreate +type DistributionCreate struct { + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *DistributionProperties `json:"properties"` +} + +// NewDistributionCreate instantiates a new DistributionCreate 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 NewDistributionCreate(properties DistributionProperties) *DistributionCreate { + this := DistributionCreate{} + + this.Properties = &properties + + return &this +} + +// NewDistributionCreateWithDefaults instantiates a new DistributionCreate 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 NewDistributionCreateWithDefaults() *DistributionCreate { + this := DistributionCreate{} + 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 *DistributionCreate) 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 *DistributionCreate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *DistributionCreate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *DistributionCreate) 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 DistributionProperties will be returned +func (o *DistributionCreate) GetProperties() *DistributionProperties { + 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 *DistributionCreate) GetPropertiesOk() (*DistributionProperties, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *DistributionCreate) SetProperties(v DistributionProperties) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *DistributionCreate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o DistributionCreate) 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 NullableDistributionCreate struct { + value *DistributionCreate + isSet bool +} + +func (v NullableDistributionCreate) Get() *DistributionCreate { + return v.value +} + +func (v *NullableDistributionCreate) Set(val *DistributionCreate) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionCreate(val *DistributionCreate) *NullableDistributionCreate { + return &NullableDistributionCreate{value: val, isSet: true} +} + +func (v NullableDistributionCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_metadata.go new file mode 100644 index 000000000..a50ace154 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_metadata.go @@ -0,0 +1,579 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// DistributionMetadata struct for DistributionMetadata +type DistributionMetadata 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"` + // IP of the distribution. It has to be included on the domain DNS Zone as A record. + PublicEndpointIpv4 *string `json:"publicEndpointIpv4,omitempty"` + // IP of the distribution, it has to be included on the domain DNS Zone as AAAA record. + PublicEndpointIpv6 *string `json:"publicEndpointIpv6,omitempty"` + // Represents one of the possible states of the resource. + State *string `json:"state"` + // A human readable message describing the current state. In case of an error, the message will contain a detailed error message. + Message *string `json:"message,omitempty"` +} + +// NewDistributionMetadata instantiates a new DistributionMetadata 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 NewDistributionMetadata(state string) *DistributionMetadata { + this := DistributionMetadata{} + + this.State = &state + + return &this +} + +// NewDistributionMetadataWithDefaults instantiates a new DistributionMetadata 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 NewDistributionMetadataWithDefaults() *DistributionMetadata { + this := DistributionMetadata{} + 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 *DistributionMetadata) 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 *DistributionMetadata) 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 *DistributionMetadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *DistributionMetadata) 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 *DistributionMetadata) 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 *DistributionMetadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *DistributionMetadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *DistributionMetadata) 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 *DistributionMetadata) 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 *DistributionMetadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *DistributionMetadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *DistributionMetadata) 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 *DistributionMetadata) 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 *DistributionMetadata) 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 *DistributionMetadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *DistributionMetadata) 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 *DistributionMetadata) 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 *DistributionMetadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *DistributionMetadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *DistributionMetadata) 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 *DistributionMetadata) 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 *DistributionMetadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *DistributionMetadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *DistributionMetadata) 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 *DistributionMetadata) 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 *DistributionMetadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *DistributionMetadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *DistributionMetadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +// GetPublicEndpointIpv4 returns the PublicEndpointIpv4 field value +// If the value is explicit nil, the zero value for string will be returned +func (o *DistributionMetadata) GetPublicEndpointIpv4() *string { + if o == nil { + return nil + } + + return o.PublicEndpointIpv4 + +} + +// GetPublicEndpointIpv4Ok returns a tuple with the PublicEndpointIpv4 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 *DistributionMetadata) GetPublicEndpointIpv4Ok() (*string, bool) { + if o == nil { + return nil, false + } + + return o.PublicEndpointIpv4, true +} + +// SetPublicEndpointIpv4 sets field value +func (o *DistributionMetadata) SetPublicEndpointIpv4(v string) { + + o.PublicEndpointIpv4 = &v + +} + +// HasPublicEndpointIpv4 returns a boolean if a field has been set. +func (o *DistributionMetadata) HasPublicEndpointIpv4() bool { + if o != nil && o.PublicEndpointIpv4 != nil { + return true + } + + return false +} + +// GetPublicEndpointIpv6 returns the PublicEndpointIpv6 field value +// If the value is explicit nil, the zero value for string will be returned +func (o *DistributionMetadata) GetPublicEndpointIpv6() *string { + if o == nil { + return nil + } + + return o.PublicEndpointIpv6 + +} + +// GetPublicEndpointIpv6Ok returns a tuple with the PublicEndpointIpv6 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 *DistributionMetadata) GetPublicEndpointIpv6Ok() (*string, bool) { + if o == nil { + return nil, false + } + + return o.PublicEndpointIpv6, true +} + +// SetPublicEndpointIpv6 sets field value +func (o *DistributionMetadata) SetPublicEndpointIpv6(v string) { + + o.PublicEndpointIpv6 = &v + +} + +// HasPublicEndpointIpv6 returns a boolean if a field has been set. +func (o *DistributionMetadata) HasPublicEndpointIpv6() bool { + if o != nil && o.PublicEndpointIpv6 != nil { + return true + } + + return false +} + +// GetState returns the State field value +// If the value is explicit nil, the zero value for string will be returned +func (o *DistributionMetadata) GetState() *string { + if o == nil { + return nil + } + + return o.State + +} + +// GetStateOk returns a tuple with the State 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 *DistributionMetadata) GetStateOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.State, true +} + +// SetState sets field value +func (o *DistributionMetadata) SetState(v string) { + + o.State = &v + +} + +// HasState returns a boolean if a field has been set. +func (o *DistributionMetadata) HasState() bool { + if o != nil && o.State != 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 *DistributionMetadata) 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 *DistributionMetadata) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Message, true +} + +// SetMessage sets field value +func (o *DistributionMetadata) SetMessage(v string) { + + o.Message = &v + +} + +// HasMessage returns a boolean if a field has been set. +func (o *DistributionMetadata) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +func (o DistributionMetadata) 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.PublicEndpointIpv4 != nil { + toSerialize["publicEndpointIpv4"] = o.PublicEndpointIpv4 + } + + if o.PublicEndpointIpv6 != nil { + toSerialize["publicEndpointIpv6"] = o.PublicEndpointIpv6 + } + + if o.State != nil { + toSerialize["state"] = o.State + } + + if o.Message != nil { + toSerialize["message"] = o.Message + } + + return json.Marshal(toSerialize) +} + +type NullableDistributionMetadata struct { + value *DistributionMetadata + isSet bool +} + +func (v NullableDistributionMetadata) Get() *DistributionMetadata { + return v.value +} + +func (v *NullableDistributionMetadata) Set(val *DistributionMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionMetadata(val *DistributionMetadata) *NullableDistributionMetadata { + return &NullableDistributionMetadata{value: val, isSet: true} +} + +func (v NullableDistributionMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_properties.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_properties.go new file mode 100644 index 000000000..16f27a7e2 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_properties.go @@ -0,0 +1,213 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// DistributionProperties A CDN distribution resource. +type DistributionProperties struct { + // The domain of the distribution. + Domain *string `json:"domain"` + // The ID of the certificate to use for the distribution. + CertificateId *string `json:"certificateId,omitempty"` + // The routing rules for the distribution. + RoutingRules *[]RoutingRule `json:"routingRules"` +} + +// NewDistributionProperties instantiates a new DistributionProperties 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 NewDistributionProperties(domain string, routingRules []RoutingRule) *DistributionProperties { + this := DistributionProperties{} + + this.Domain = &domain + this.RoutingRules = &routingRules + + return &this +} + +// NewDistributionPropertiesWithDefaults instantiates a new DistributionProperties 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 NewDistributionPropertiesWithDefaults() *DistributionProperties { + this := DistributionProperties{} + return &this +} + +// GetDomain returns the Domain field value +// If the value is explicit nil, the zero value for string will be returned +func (o *DistributionProperties) GetDomain() *string { + if o == nil { + return nil + } + + return o.Domain + +} + +// GetDomainOk returns a tuple with the Domain 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 *DistributionProperties) GetDomainOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Domain, true +} + +// SetDomain sets field value +func (o *DistributionProperties) SetDomain(v string) { + + o.Domain = &v + +} + +// HasDomain returns a boolean if a field has been set. +func (o *DistributionProperties) HasDomain() bool { + if o != nil && o.Domain != nil { + return true + } + + return false +} + +// GetCertificateId returns the CertificateId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *DistributionProperties) GetCertificateId() *string { + if o == nil { + return nil + } + + return o.CertificateId + +} + +// GetCertificateIdOk returns a tuple with the CertificateId 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 *DistributionProperties) GetCertificateIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CertificateId, true +} + +// SetCertificateId sets field value +func (o *DistributionProperties) SetCertificateId(v string) { + + o.CertificateId = &v + +} + +// HasCertificateId returns a boolean if a field has been set. +func (o *DistributionProperties) HasCertificateId() bool { + if o != nil && o.CertificateId != nil { + return true + } + + return false +} + +// GetRoutingRules returns the RoutingRules field value +// If the value is explicit nil, the zero value for []RoutingRule will be returned +func (o *DistributionProperties) GetRoutingRules() *[]RoutingRule { + if o == nil { + return nil + } + + return o.RoutingRules + +} + +// GetRoutingRulesOk returns a tuple with the RoutingRules 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 *DistributionProperties) GetRoutingRulesOk() (*[]RoutingRule, bool) { + if o == nil { + return nil, false + } + + return o.RoutingRules, true +} + +// SetRoutingRules sets field value +func (o *DistributionProperties) SetRoutingRules(v []RoutingRule) { + + o.RoutingRules = &v + +} + +// HasRoutingRules returns a boolean if a field has been set. +func (o *DistributionProperties) HasRoutingRules() bool { + if o != nil && o.RoutingRules != nil { + return true + } + + return false +} + +func (o DistributionProperties) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Domain != nil { + toSerialize["domain"] = o.Domain + } + + if o.CertificateId != nil { + toSerialize["certificateId"] = o.CertificateId + } + + if o.RoutingRules != nil { + toSerialize["routingRules"] = o.RoutingRules + } + + return json.Marshal(toSerialize) +} + +type NullableDistributionProperties struct { + value *DistributionProperties + isSet bool +} + +func (v NullableDistributionProperties) Get() *DistributionProperties { + return v.value +} + +func (v *NullableDistributionProperties) Set(val *DistributionProperties) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionProperties) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionProperties) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionProperties(val *DistributionProperties) *NullableDistributionProperties { + return &NullableDistributionProperties{value: val, isSet: true} +} + +func (v NullableDistributionProperties) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionProperties) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_update.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_update.go new file mode 100644 index 000000000..847ef767c --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distribution_update.go @@ -0,0 +1,212 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// DistributionUpdate struct for DistributionUpdate +type DistributionUpdate struct { + // The ID (UUID) of the Distribution. + Id *string `json:"id"` + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *DistributionProperties `json:"properties"` +} + +// NewDistributionUpdate instantiates a new DistributionUpdate 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 NewDistributionUpdate(id string, properties DistributionProperties) *DistributionUpdate { + this := DistributionUpdate{} + + this.Id = &id + this.Properties = &properties + + return &this +} + +// NewDistributionUpdateWithDefaults instantiates a new DistributionUpdate 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 NewDistributionUpdateWithDefaults() *DistributionUpdate { + this := DistributionUpdate{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *DistributionUpdate) 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 *DistributionUpdate) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *DistributionUpdate) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *DistributionUpdate) 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 *DistributionUpdate) 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 *DistributionUpdate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *DistributionUpdate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *DistributionUpdate) 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 DistributionProperties will be returned +func (o *DistributionUpdate) GetProperties() *DistributionProperties { + 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 *DistributionUpdate) GetPropertiesOk() (*DistributionProperties, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *DistributionUpdate) SetProperties(v DistributionProperties) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *DistributionUpdate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o DistributionUpdate) 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 NullableDistributionUpdate struct { + value *DistributionUpdate + isSet bool +} + +func (v NullableDistributionUpdate) Get() *DistributionUpdate { + return v.value +} + +func (v *NullableDistributionUpdate) Set(val *DistributionUpdate) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionUpdate) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionUpdate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionUpdate(val *DistributionUpdate) *NullableDistributionUpdate { + return &NullableDistributionUpdate{value: val, isSet: true} +} + +func (v NullableDistributionUpdate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionUpdate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distributions.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distributions.go new file mode 100644 index 000000000..4ce8ac3e9 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distributions.go @@ -0,0 +1,392 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Distributions struct for Distributions +type Distributions struct { + // ID of the list of Distribution resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of Distribution resources. + Href *string `json:"href"` + // The list of Distribution resources. + Items *[]Distribution `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"` +} + +// NewDistributions instantiates a new Distributions 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 NewDistributions(id string, type_ string, href string, offset int32, limit int32, links Links) *Distributions { + this := Distributions{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewDistributionsWithDefaults instantiates a new Distributions 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 NewDistributionsWithDefaults() *Distributions { + this := Distributions{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Distributions) 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 *Distributions) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *Distributions) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *Distributions) 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 *Distributions) 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 *Distributions) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *Distributions) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *Distributions) 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 *Distributions) 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 *Distributions) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *Distributions) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *Distributions) 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 []Distribution will be returned +func (o *Distributions) GetItems() *[]Distribution { + 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 *Distributions) GetItemsOk() (*[]Distribution, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *Distributions) SetItems(v []Distribution) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *Distributions) 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 *Distributions) 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 *Distributions) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *Distributions) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *Distributions) 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 *Distributions) 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 *Distributions) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *Distributions) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *Distributions) 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 *Distributions) 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 *Distributions) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *Distributions) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *Distributions) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o Distributions) 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 NullableDistributions struct { + value *Distributions + isSet bool +} + +func (v NullableDistributions) Get() *Distributions { + return v.value +} + +func (v *NullableDistributions) Set(val *Distributions) { + v.value = val + v.isSet = true +} + +func (v NullableDistributions) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributions) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributions(val *Distributions) *NullableDistributions { + return &NullableDistributions{value: val, isSet: true} +} + +func (v NullableDistributions) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributions) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distributions_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distributions_all_of.go new file mode 100644 index 000000000..6d9dd5517 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_distributions_all_of.go @@ -0,0 +1,258 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// DistributionsAllOf struct for DistributionsAllOf +type DistributionsAllOf struct { + // ID of the list of Distribution resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of Distribution resources. + Href *string `json:"href"` + // The list of Distribution resources. + Items *[]Distribution `json:"items,omitempty"` +} + +// NewDistributionsAllOf instantiates a new DistributionsAllOf 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 NewDistributionsAllOf(id string, type_ string, href string) *DistributionsAllOf { + this := DistributionsAllOf{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + + return &this +} + +// NewDistributionsAllOfWithDefaults instantiates a new DistributionsAllOf 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 NewDistributionsAllOfWithDefaults() *DistributionsAllOf { + this := DistributionsAllOf{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *DistributionsAllOf) 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 *DistributionsAllOf) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *DistributionsAllOf) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *DistributionsAllOf) 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 *DistributionsAllOf) 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 *DistributionsAllOf) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *DistributionsAllOf) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *DistributionsAllOf) 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 *DistributionsAllOf) 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 *DistributionsAllOf) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *DistributionsAllOf) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *DistributionsAllOf) 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 []Distribution will be returned +func (o *DistributionsAllOf) GetItems() *[]Distribution { + 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 *DistributionsAllOf) GetItemsOk() (*[]Distribution, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *DistributionsAllOf) SetItems(v []Distribution) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *DistributionsAllOf) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +func (o DistributionsAllOf) 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 NullableDistributionsAllOf struct { + value *DistributionsAllOf + isSet bool +} + +func (v NullableDistributionsAllOf) Get() *DistributionsAllOf { + return v.value +} + +func (v *NullableDistributionsAllOf) Set(val *DistributionsAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionsAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionsAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionsAllOf(val *DistributionsAllOf) *NullableDistributionsAllOf { + return &NullableDistributionsAllOf{value: val, isSet: true} +} + +func (v NullableDistributionsAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionsAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_error.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_error.go new file mode 100644 index 000000000..9dd190aff --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_error.go @@ -0,0 +1,166 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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-cdn/model_error_messages.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_error_messages.go new file mode 100644 index 000000000..bc32d0378 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_error_messages.go @@ -0,0 +1,166 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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-cdn/model_ip_addresses.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_ip_addresses.go new file mode 100644 index 000000000..03e21b75e --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_ip_addresses.go @@ -0,0 +1,166 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// IpAddresses The IP addresses of the distribution. Note that the IP addresses will be included in the response only when the CDN distribution is in the 'AVAILABLE' state. +type IpAddresses struct { + // IP of the distribution. It has to be included on the domain DNS Zone as A record. + PublicEndpointIpv4 *string `json:"publicEndpointIpv4,omitempty"` + // IP of the distribution, it has to be included on the domain DNS Zone as AAAA record. + PublicEndpointIpv6 *string `json:"publicEndpointIpv6,omitempty"` +} + +// NewIpAddresses instantiates a new IpAddresses 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 NewIpAddresses() *IpAddresses { + this := IpAddresses{} + + return &this +} + +// NewIpAddressesWithDefaults instantiates a new IpAddresses 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 NewIpAddressesWithDefaults() *IpAddresses { + this := IpAddresses{} + return &this +} + +// GetPublicEndpointIpv4 returns the PublicEndpointIpv4 field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IpAddresses) GetPublicEndpointIpv4() *string { + if o == nil { + return nil + } + + return o.PublicEndpointIpv4 + +} + +// GetPublicEndpointIpv4Ok returns a tuple with the PublicEndpointIpv4 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 *IpAddresses) GetPublicEndpointIpv4Ok() (*string, bool) { + if o == nil { + return nil, false + } + + return o.PublicEndpointIpv4, true +} + +// SetPublicEndpointIpv4 sets field value +func (o *IpAddresses) SetPublicEndpointIpv4(v string) { + + o.PublicEndpointIpv4 = &v + +} + +// HasPublicEndpointIpv4 returns a boolean if a field has been set. +func (o *IpAddresses) HasPublicEndpointIpv4() bool { + if o != nil && o.PublicEndpointIpv4 != nil { + return true + } + + return false +} + +// GetPublicEndpointIpv6 returns the PublicEndpointIpv6 field value +// If the value is explicit nil, the zero value for string will be returned +func (o *IpAddresses) GetPublicEndpointIpv6() *string { + if o == nil { + return nil + } + + return o.PublicEndpointIpv6 + +} + +// GetPublicEndpointIpv6Ok returns a tuple with the PublicEndpointIpv6 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 *IpAddresses) GetPublicEndpointIpv6Ok() (*string, bool) { + if o == nil { + return nil, false + } + + return o.PublicEndpointIpv6, true +} + +// SetPublicEndpointIpv6 sets field value +func (o *IpAddresses) SetPublicEndpointIpv6(v string) { + + o.PublicEndpointIpv6 = &v + +} + +// HasPublicEndpointIpv6 returns a boolean if a field has been set. +func (o *IpAddresses) HasPublicEndpointIpv6() bool { + if o != nil && o.PublicEndpointIpv6 != nil { + return true + } + + return false +} + +func (o IpAddresses) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.PublicEndpointIpv4 != nil { + toSerialize["publicEndpointIpv4"] = o.PublicEndpointIpv4 + } + + if o.PublicEndpointIpv6 != nil { + toSerialize["publicEndpointIpv6"] = o.PublicEndpointIpv6 + } + + return json.Marshal(toSerialize) +} + +type NullableIpAddresses struct { + value *IpAddresses + isSet bool +} + +func (v NullableIpAddresses) Get() *IpAddresses { + return v.value +} + +func (v *NullableIpAddresses) Set(val *IpAddresses) { + v.value = val + v.isSet = true +} + +func (v NullableIpAddresses) IsSet() bool { + return v.isSet +} + +func (v *NullableIpAddresses) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIpAddresses(val *IpAddresses) *NullableIpAddresses { + return &NullableIpAddresses{value: val, isSet: true} +} + +func (v NullableIpAddresses) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIpAddresses) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_links.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_links.go new file mode 100644 index 000000000..b24975534 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_links.go @@ -0,0 +1,210 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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-cdn/model_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_metadata.go new file mode 100644 index 000000000..d3d74a019 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_metadata.go @@ -0,0 +1,401 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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-cdn/model_pagination.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_pagination.go new file mode 100644 index 000000000..26193c7cf --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_pagination.go @@ -0,0 +1,213 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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-cdn/model_resource_state.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_resource_state.go new file mode 100644 index 000000000..060c12987 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_resource_state.go @@ -0,0 +1,168 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ResourceState The current status of the resource. +type ResourceState struct { + // Represents one of the possible states of the resource. + State *string `json:"state"` + // A human readable message describing the current state. In case of an error, the message will contain a detailed error message. + Message *string `json:"message,omitempty"` +} + +// NewResourceState instantiates a new ResourceState 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 NewResourceState(state string) *ResourceState { + this := ResourceState{} + + this.State = &state + + return &this +} + +// NewResourceStateWithDefaults instantiates a new ResourceState 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 NewResourceStateWithDefaults() *ResourceState { + this := ResourceState{} + return &this +} + +// GetState returns the State field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ResourceState) GetState() *string { + if o == nil { + return nil + } + + return o.State + +} + +// GetStateOk returns a tuple with the State 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 *ResourceState) GetStateOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.State, true +} + +// SetState sets field value +func (o *ResourceState) SetState(v string) { + + o.State = &v + +} + +// HasState returns a boolean if a field has been set. +func (o *ResourceState) HasState() bool { + if o != nil && o.State != 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 *ResourceState) 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 *ResourceState) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Message, true +} + +// SetMessage sets field value +func (o *ResourceState) SetMessage(v string) { + + o.Message = &v + +} + +// HasMessage returns a boolean if a field has been set. +func (o *ResourceState) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +func (o ResourceState) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.State != nil { + toSerialize["state"] = o.State + } + + if o.Message != nil { + toSerialize["message"] = o.Message + } + + return json.Marshal(toSerialize) +} + +type NullableResourceState struct { + value *ResourceState + isSet bool +} + +func (v NullableResourceState) Get() *ResourceState { + return v.value +} + +func (v *NullableResourceState) Set(val *ResourceState) { + v.value = val + v.isSet = true +} + +func (v NullableResourceState) IsSet() bool { + return v.isSet +} + +func (v *NullableResourceState) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableResourceState(val *ResourceState) *NullableResourceState { + return &NullableResourceState{value: val, isSet: true} +} + +func (v NullableResourceState) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableResourceState) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_routing_rule.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_routing_rule.go new file mode 100644 index 000000000..df12cacce --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_routing_rule.go @@ -0,0 +1,213 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// RoutingRule struct for RoutingRule +type RoutingRule struct { + // The scheme of the routing rule. + Scheme *string `json:"scheme"` + // The prefix of the routing rule. + Prefix *string `json:"prefix"` + Upstream *Upstream `json:"upstream"` +} + +// NewRoutingRule instantiates a new RoutingRule 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 NewRoutingRule(scheme string, prefix string, upstream Upstream) *RoutingRule { + this := RoutingRule{} + + this.Scheme = &scheme + this.Prefix = &prefix + this.Upstream = &upstream + + return &this +} + +// NewRoutingRuleWithDefaults instantiates a new RoutingRule 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 NewRoutingRuleWithDefaults() *RoutingRule { + this := RoutingRule{} + return &this +} + +// GetScheme returns the Scheme field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RoutingRule) GetScheme() *string { + if o == nil { + return nil + } + + return o.Scheme + +} + +// GetSchemeOk returns a tuple with the Scheme 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 *RoutingRule) GetSchemeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Scheme, true +} + +// SetScheme sets field value +func (o *RoutingRule) SetScheme(v string) { + + o.Scheme = &v + +} + +// HasScheme returns a boolean if a field has been set. +func (o *RoutingRule) HasScheme() bool { + if o != nil && o.Scheme != nil { + return true + } + + return false +} + +// GetPrefix returns the Prefix field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RoutingRule) GetPrefix() *string { + if o == nil { + return nil + } + + return o.Prefix + +} + +// GetPrefixOk returns a tuple with the Prefix 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 *RoutingRule) GetPrefixOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Prefix, true +} + +// SetPrefix sets field value +func (o *RoutingRule) SetPrefix(v string) { + + o.Prefix = &v + +} + +// HasPrefix returns a boolean if a field has been set. +func (o *RoutingRule) HasPrefix() bool { + if o != nil && o.Prefix != nil { + return true + } + + return false +} + +// GetUpstream returns the Upstream field value +// If the value is explicit nil, the zero value for Upstream will be returned +func (o *RoutingRule) GetUpstream() *Upstream { + if o == nil { + return nil + } + + return o.Upstream + +} + +// GetUpstreamOk returns a tuple with the Upstream 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 *RoutingRule) GetUpstreamOk() (*Upstream, bool) { + if o == nil { + return nil, false + } + + return o.Upstream, true +} + +// SetUpstream sets field value +func (o *RoutingRule) SetUpstream(v Upstream) { + + o.Upstream = &v + +} + +// HasUpstream returns a boolean if a field has been set. +func (o *RoutingRule) HasUpstream() bool { + if o != nil && o.Upstream != nil { + return true + } + + return false +} + +func (o RoutingRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Scheme != nil { + toSerialize["scheme"] = o.Scheme + } + + if o.Prefix != nil { + toSerialize["prefix"] = o.Prefix + } + + if o.Upstream != nil { + toSerialize["upstream"] = o.Upstream + } + + return json.Marshal(toSerialize) +} + +type NullableRoutingRule struct { + value *RoutingRule + isSet bool +} + +func (v NullableRoutingRule) Get() *RoutingRule { + return v.value +} + +func (v *NullableRoutingRule) Set(val *RoutingRule) { + v.value = val + v.isSet = true +} + +func (v NullableRoutingRule) IsSet() bool { + return v.isSet +} + +func (v *NullableRoutingRule) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRoutingRule(val *RoutingRule) *NullableRoutingRule { + return &NullableRoutingRule{value: val, isSet: true} +} + +func (v NullableRoutingRule) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRoutingRule) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_upstream.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_upstream.go new file mode 100644 index 000000000..bdb7c4a45 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_upstream.go @@ -0,0 +1,347 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Upstream struct for Upstream +type Upstream struct { + // The upstream host that handles the requests if not already cached. This host will be protected by the WAF if the option is enabled. + Host *string `json:"host"` + // Enable or disable caching. If enabled, the CDN will cache the responses from the upstream host. Subsequent requests for the same resource will be served from the cache. + Caching *bool `json:"caching"` + // Enable or disable WAF to protect the upstream host. + Waf *bool `json:"waf"` + GeoRestrictions *UpstreamGeoRestrictions `json:"geoRestrictions,omitempty"` + // Rate limit class that will be applied to limit the number of incoming requests per IP. + RateLimitClass *string `json:"rateLimitClass"` + // The SNI (Server Name Indication) mode of the upstream host. It supports two modes: - distribution: for outgoing connections to the upstream host, the CDN requires the upstream host to present a valid certificate that matches the configured domain of the CDN distribution. - origin: for outgoing connections to the upstream host, the CDN requires the upstream host to present a valid certificate that matches the configured upstream/origin hostname. + SniMode *string `json:"sniMode"` +} + +// NewUpstream instantiates a new Upstream 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 NewUpstream(host string, caching bool, waf bool, rateLimitClass string, sniMode string) *Upstream { + this := Upstream{} + + this.Host = &host + this.Caching = &caching + this.Waf = &waf + this.RateLimitClass = &rateLimitClass + this.SniMode = &sniMode + + return &this +} + +// NewUpstreamWithDefaults instantiates a new Upstream 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 NewUpstreamWithDefaults() *Upstream { + this := Upstream{} + return &this +} + +// GetHost returns the Host field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Upstream) 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 *Upstream) GetHostOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Host, true +} + +// SetHost sets field value +func (o *Upstream) SetHost(v string) { + + o.Host = &v + +} + +// HasHost returns a boolean if a field has been set. +func (o *Upstream) HasHost() bool { + if o != nil && o.Host != nil { + return true + } + + return false +} + +// GetCaching returns the Caching field value +// If the value is explicit nil, the zero value for bool will be returned +func (o *Upstream) GetCaching() *bool { + if o == nil { + return nil + } + + return o.Caching + +} + +// GetCachingOk returns a tuple with the Caching 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 *Upstream) GetCachingOk() (*bool, bool) { + if o == nil { + return nil, false + } + + return o.Caching, true +} + +// SetCaching sets field value +func (o *Upstream) SetCaching(v bool) { + + o.Caching = &v + +} + +// HasCaching returns a boolean if a field has been set. +func (o *Upstream) HasCaching() bool { + if o != nil && o.Caching != nil { + return true + } + + return false +} + +// GetWaf returns the Waf field value +// If the value is explicit nil, the zero value for bool will be returned +func (o *Upstream) GetWaf() *bool { + if o == nil { + return nil + } + + return o.Waf + +} + +// GetWafOk returns a tuple with the Waf 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 *Upstream) GetWafOk() (*bool, bool) { + if o == nil { + return nil, false + } + + return o.Waf, true +} + +// SetWaf sets field value +func (o *Upstream) SetWaf(v bool) { + + o.Waf = &v + +} + +// HasWaf returns a boolean if a field has been set. +func (o *Upstream) HasWaf() bool { + if o != nil && o.Waf != nil { + return true + } + + return false +} + +// GetGeoRestrictions returns the GeoRestrictions field value +// If the value is explicit nil, the zero value for UpstreamGeoRestrictions will be returned +func (o *Upstream) GetGeoRestrictions() *UpstreamGeoRestrictions { + if o == nil { + return nil + } + + return o.GeoRestrictions + +} + +// GetGeoRestrictionsOk returns a tuple with the GeoRestrictions 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 *Upstream) GetGeoRestrictionsOk() (*UpstreamGeoRestrictions, bool) { + if o == nil { + return nil, false + } + + return o.GeoRestrictions, true +} + +// SetGeoRestrictions sets field value +func (o *Upstream) SetGeoRestrictions(v UpstreamGeoRestrictions) { + + o.GeoRestrictions = &v + +} + +// HasGeoRestrictions returns a boolean if a field has been set. +func (o *Upstream) HasGeoRestrictions() bool { + if o != nil && o.GeoRestrictions != nil { + return true + } + + return false +} + +// GetRateLimitClass returns the RateLimitClass field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Upstream) GetRateLimitClass() *string { + if o == nil { + return nil + } + + return o.RateLimitClass + +} + +// GetRateLimitClassOk returns a tuple with the RateLimitClass 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 *Upstream) GetRateLimitClassOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.RateLimitClass, true +} + +// SetRateLimitClass sets field value +func (o *Upstream) SetRateLimitClass(v string) { + + o.RateLimitClass = &v + +} + +// HasRateLimitClass returns a boolean if a field has been set. +func (o *Upstream) HasRateLimitClass() bool { + if o != nil && o.RateLimitClass != nil { + return true + } + + return false +} + +// GetSniMode returns the SniMode field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Upstream) GetSniMode() *string { + if o == nil { + return nil + } + + return o.SniMode + +} + +// GetSniModeOk returns a tuple with the SniMode 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 *Upstream) GetSniModeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.SniMode, true +} + +// SetSniMode sets field value +func (o *Upstream) SetSniMode(v string) { + + o.SniMode = &v + +} + +// HasSniMode returns a boolean if a field has been set. +func (o *Upstream) HasSniMode() bool { + if o != nil && o.SniMode != nil { + return true + } + + return false +} + +func (o Upstream) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Host != nil { + toSerialize["host"] = o.Host + } + + if o.Caching != nil { + toSerialize["caching"] = o.Caching + } + + if o.Waf != nil { + toSerialize["waf"] = o.Waf + } + + if o.GeoRestrictions != nil { + toSerialize["geoRestrictions"] = o.GeoRestrictions + } + + if o.RateLimitClass != nil { + toSerialize["rateLimitClass"] = o.RateLimitClass + } + + if o.SniMode != nil { + toSerialize["sniMode"] = o.SniMode + } + + return json.Marshal(toSerialize) +} + +type NullableUpstream struct { + value *Upstream + isSet bool +} + +func (v NullableUpstream) Get() *Upstream { + return v.value +} + +func (v *NullableUpstream) Set(val *Upstream) { + v.value = val + v.isSet = true +} + +func (v NullableUpstream) IsSet() bool { + return v.isSet +} + +func (v *NullableUpstream) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpstream(val *Upstream) *NullableUpstream { + return &NullableUpstream{value: val, isSet: true} +} + +func (v NullableUpstream) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpstream) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/model_upstream_geo_restrictions.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_upstream_geo_restrictions.go new file mode 100644 index 000000000..e58db4e2a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/model_upstream_geo_restrictions.go @@ -0,0 +1,166 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// UpstreamGeoRestrictions This field manages the list of countries that are allowed or blocked from accessing the resource from the upstream host based on their ISO 3166-1 alpha-2 codes. +type UpstreamGeoRestrictions struct { + // Country codes, the format should be based on ISO 3166-1 alpha-2 codes standard. Those codes are used to either blacklist or whitelist countries in geoIPBlock. + BlockList *[]string `json:"blockList,omitempty"` + // Country codes, the format should be based on ISO 3166-1 alpha-2 codes standard. Those codes are used to either blacklist or whitelist countries in geoIPBlock. + AllowList *[]string `json:"allowList,omitempty"` +} + +// NewUpstreamGeoRestrictions instantiates a new UpstreamGeoRestrictions 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 NewUpstreamGeoRestrictions() *UpstreamGeoRestrictions { + this := UpstreamGeoRestrictions{} + + return &this +} + +// NewUpstreamGeoRestrictionsWithDefaults instantiates a new UpstreamGeoRestrictions 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 NewUpstreamGeoRestrictionsWithDefaults() *UpstreamGeoRestrictions { + this := UpstreamGeoRestrictions{} + return &this +} + +// GetBlockList returns the BlockList field value +// If the value is explicit nil, the zero value for []string will be returned +func (o *UpstreamGeoRestrictions) GetBlockList() *[]string { + if o == nil { + return nil + } + + return o.BlockList + +} + +// GetBlockListOk returns a tuple with the BlockList 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 *UpstreamGeoRestrictions) GetBlockListOk() (*[]string, bool) { + if o == nil { + return nil, false + } + + return o.BlockList, true +} + +// SetBlockList sets field value +func (o *UpstreamGeoRestrictions) SetBlockList(v []string) { + + o.BlockList = &v + +} + +// HasBlockList returns a boolean if a field has been set. +func (o *UpstreamGeoRestrictions) HasBlockList() bool { + if o != nil && o.BlockList != nil { + return true + } + + return false +} + +// GetAllowList returns the AllowList field value +// If the value is explicit nil, the zero value for []string will be returned +func (o *UpstreamGeoRestrictions) GetAllowList() *[]string { + if o == nil { + return nil + } + + return o.AllowList + +} + +// GetAllowListOk returns a tuple with the AllowList 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 *UpstreamGeoRestrictions) GetAllowListOk() (*[]string, bool) { + if o == nil { + return nil, false + } + + return o.AllowList, true +} + +// SetAllowList sets field value +func (o *UpstreamGeoRestrictions) SetAllowList(v []string) { + + o.AllowList = &v + +} + +// HasAllowList returns a boolean if a field has been set. +func (o *UpstreamGeoRestrictions) HasAllowList() bool { + if o != nil && o.AllowList != nil { + return true + } + + return false +} + +func (o UpstreamGeoRestrictions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.BlockList != nil { + toSerialize["blockList"] = o.BlockList + } + + if o.AllowList != nil { + toSerialize["allowList"] = o.AllowList + } + + return json.Marshal(toSerialize) +} + +type NullableUpstreamGeoRestrictions struct { + value *UpstreamGeoRestrictions + isSet bool +} + +func (v NullableUpstreamGeoRestrictions) Get() *UpstreamGeoRestrictions { + return v.value +} + +func (v *NullableUpstreamGeoRestrictions) Set(val *UpstreamGeoRestrictions) { + v.value = val + v.isSet = true +} + +func (v NullableUpstreamGeoRestrictions) IsSet() bool { + return v.isSet +} + +func (v *NullableUpstreamGeoRestrictions) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpstreamGeoRestrictions(val *UpstreamGeoRestrictions) *NullableUpstreamGeoRestrictions { + return &NullableUpstreamGeoRestrictions{value: val, isSet: true} +} + +func (v NullableUpstreamGeoRestrictions) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpstreamGeoRestrictions) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-cdn/response.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/response.go new file mode 100644 index 000000000..b5a4a12d3 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/response.go @@ -0,0 +1,73 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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-cdn/sonar-project.properties b/vendor/github.com/ionos-cloud/sdk-go-cdn/sonar-project.properties new file mode 100644 index 000000000..bb699fe16 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=ionos-cloud_sdk-go-cdn +sonar.organization=ionos-cloud + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=sdk-go-cdn +#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-cdn/utils.go b/vendor/github.com/ionos-cloud/sdk-go-cdn/utils.go new file mode 100644 index 000000000..30d303f85 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-cdn/utils.go @@ -0,0 +1,776 @@ +/* + * IONOS Cloud - CDN Distribution API + * + * This API manages CDN distributions. + * + * API version: 1.2.0 + */ + +// 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 e26dcbec3..d2cf3a3f5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -63,6 +63,9 @@ github.com/inconshreveable/mousetrap # github.com/ionos-cloud/sdk-go-auth v1.0.6 ## explicit; go 1.19 github.com/ionos-cloud/sdk-go-auth +# github.com/ionos-cloud/sdk-go-cdn v1.1.0 +## explicit; go 1.18 +github.com/ionos-cloud/sdk-go-cdn # github.com/ionos-cloud/sdk-go-cert-manager v1.0.1 ## explicit; go 1.19 github.com/ionos-cloud/sdk-go-cert-manager @@ -198,7 +201,7 @@ golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/exp/constraints golang.org/x/exp/slices golang.org/x/exp/utf8string -# golang.org/x/oauth2 v0.20.0 +# golang.org/x/oauth2 v0.21.0 ## explicit; go 1.18 golang.org/x/oauth2 golang.org/x/oauth2/internal