mysql.go raw

   1  package linodego
   2  
   3  import (
   4  	"context"
   5  	"encoding/json"
   6  	"time"
   7  
   8  	"github.com/linode/linodego/internal/parseabletime"
   9  )
  10  
  11  type MySQLDatabaseTarget string
  12  
  13  type MySQLDatabaseMaintenanceWindow = DatabaseMaintenanceWindow
  14  
  15  const (
  16  	MySQLDatabaseTargetPrimary   MySQLDatabaseTarget = "primary"
  17  	MySQLDatabaseTargetSecondary MySQLDatabaseTarget = "secondary"
  18  )
  19  
  20  // A MySQLDatabase is an instance of Linode MySQL Managed Databases
  21  type MySQLDatabase struct {
  22  	ID          int              `json:"id"`
  23  	Status      DatabaseStatus   `json:"status"`
  24  	Label       string           `json:"label"`
  25  	Hosts       DatabaseHost     `json:"hosts"`
  26  	Region      string           `json:"region"`
  27  	Type        string           `json:"type"`
  28  	Engine      string           `json:"engine"`
  29  	Version     string           `json:"version"`
  30  	ClusterSize int              `json:"cluster_size"`
  31  	Platform    DatabasePlatform `json:"platform"`
  32  
  33  	// Members has dynamic keys so it is a map
  34  	Members map[string]DatabaseMemberType `json:"members"`
  35  
  36  	// Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2.
  37  	ReplicationType string `json:"replication_type"`
  38  	// Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
  39  	SSLConnection bool `json:"ssl_connection"`
  40  	// Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2.
  41  	Encrypted bool `json:"encrypted"`
  42  
  43  	AllowList         []string                  `json:"allow_list"`
  44  	InstanceURI       string                    `json:"instance_uri"`
  45  	Created           *time.Time                `json:"-"`
  46  	Updated           *time.Time                `json:"-"`
  47  	Updates           DatabaseMaintenanceWindow `json:"updates"`
  48  	Fork              *DatabaseFork             `json:"fork"`
  49  	OldestRestoreTime *time.Time                `json:"-"`
  50  	UsedDiskSizeGB    int                       `json:"used_disk_size_gb"`
  51  	TotalDiskSizeGB   int                       `json:"total_disk_size_gb"`
  52  	Port              int                       `json:"port"`
  53  
  54  	EngineConfig   MySQLDatabaseEngineConfig `json:"engine_config"`
  55  	PrivateNetwork *DatabasePrivateNetwork   `json:"private_network,omitempty"`
  56  }
  57  
  58  type MySQLDatabaseEngineConfig struct {
  59  	MySQL                 *MySQLDatabaseEngineConfigMySQL `json:"mysql,omitempty"`
  60  	BinlogRetentionPeriod *int                            `json:"binlog_retention_period,omitempty"`
  61  }
  62  
  63  type MySQLDatabaseEngineConfigMySQL struct {
  64  	ConnectTimeout               *int     `json:"connect_timeout,omitempty"`
  65  	DefaultTimeZone              *string  `json:"default_time_zone,omitempty"`
  66  	GroupConcatMaxLen            *float64 `json:"group_concat_max_len,omitempty"`
  67  	InformationSchemaStatsExpiry *int     `json:"information_schema_stats_expiry,omitempty"`
  68  	InnoDBChangeBufferMaxSize    *int     `json:"innodb_change_buffer_max_size,omitempty"`
  69  	InnoDBFlushNeighbors         *int     `json:"innodb_flush_neighbors,omitempty"`
  70  	InnoDBFTMinTokenSize         *int     `json:"innodb_ft_min_token_size,omitempty"`
  71  	InnoDBFTServerStopwordTable  **string `json:"innodb_ft_server_stopword_table,omitempty"`
  72  	InnoDBLockWaitTimeout        *int     `json:"innodb_lock_wait_timeout,omitempty"`
  73  	InnoDBLogBufferSize          *int     `json:"innodb_log_buffer_size,omitempty"`
  74  	InnoDBOnlineAlterLogMaxSize  *int     `json:"innodb_online_alter_log_max_size,omitempty"`
  75  	InnoDBReadIOThreads          *int     `json:"innodb_read_io_threads,omitempty"`
  76  	InnoDBRollbackOnTimeout      *bool    `json:"innodb_rollback_on_timeout,omitempty"`
  77  	InnoDBThreadConcurrency      *int     `json:"innodb_thread_concurrency,omitempty"`
  78  	InnoDBWriteIOThreads         *int     `json:"innodb_write_io_threads,omitempty"`
  79  	InteractiveTimeout           *int     `json:"interactive_timeout,omitempty"`
  80  	InternalTmpMemStorageEngine  *string  `json:"internal_tmp_mem_storage_engine,omitempty"`
  81  	MaxAllowedPacket             *int     `json:"max_allowed_packet,omitempty"`
  82  	MaxHeapTableSize             *int     `json:"max_heap_table_size,omitempty"`
  83  	NetBufferLength              *int     `json:"net_buffer_length,omitempty"`
  84  	NetReadTimeout               *int     `json:"net_read_timeout,omitempty"`
  85  	NetWriteTimeout              *int     `json:"net_write_timeout,omitempty"`
  86  	SortBufferSize               *int     `json:"sort_buffer_size,omitempty"`
  87  	SQLMode                      *string  `json:"sql_mode,omitempty"`
  88  	SQLRequirePrimaryKey         *bool    `json:"sql_require_primary_key,omitempty"`
  89  	TmpTableSize                 *int     `json:"tmp_table_size,omitempty"`
  90  	WaitTimeout                  *int     `json:"wait_timeout,omitempty"`
  91  }
  92  
  93  type MySQLDatabaseConfigInfo struct {
  94  	MySQL                 MySQLDatabaseConfigInfoMySQL                 `json:"mysql"`
  95  	BinlogRetentionPeriod MySQLDatabaseConfigInfoBinlogRetentionPeriod `json:"binlog_retention_period"`
  96  }
  97  
  98  type MySQLDatabaseConfigInfoMySQL struct {
  99  	ConnectTimeout               ConnectTimeout               `json:"connect_timeout"`
 100  	DefaultTimeZone              DefaultTimeZone              `json:"default_time_zone"`
 101  	GroupConcatMaxLen            GroupConcatMaxLen            `json:"group_concat_max_len"`
 102  	InformationSchemaStatsExpiry InformationSchemaStatsExpiry `json:"information_schema_stats_expiry"`
 103  	InnoDBChangeBufferMaxSize    InnoDBChangeBufferMaxSize    `json:"innodb_change_buffer_max_size"`
 104  	InnoDBFlushNeighbors         InnoDBFlushNeighbors         `json:"innodb_flush_neighbors"`
 105  	InnoDBFTMinTokenSize         InnoDBFTMinTokenSize         `json:"innodb_ft_min_token_size"`
 106  	InnoDBFTServerStopwordTable  InnoDBFTServerStopwordTable  `json:"innodb_ft_server_stopword_table"`
 107  	InnoDBLockWaitTimeout        InnoDBLockWaitTimeout        `json:"innodb_lock_wait_timeout"`
 108  	InnoDBLogBufferSize          InnoDBLogBufferSize          `json:"innodb_log_buffer_size"`
 109  	InnoDBOnlineAlterLogMaxSize  InnoDBOnlineAlterLogMaxSize  `json:"innodb_online_alter_log_max_size"`
 110  	InnoDBReadIOThreads          InnoDBReadIOThreads          `json:"innodb_read_io_threads"`
 111  	InnoDBRollbackOnTimeout      InnoDBRollbackOnTimeout      `json:"innodb_rollback_on_timeout"`
 112  	InnoDBThreadConcurrency      InnoDBThreadConcurrency      `json:"innodb_thread_concurrency"`
 113  	InnoDBWriteIOThreads         InnoDBWriteIOThreads         `json:"innodb_write_io_threads"`
 114  	InteractiveTimeout           InteractiveTimeout           `json:"interactive_timeout"`
 115  	InternalTmpMemStorageEngine  InternalTmpMemStorageEngine  `json:"internal_tmp_mem_storage_engine"`
 116  	MaxAllowedPacket             MaxAllowedPacket             `json:"max_allowed_packet"`
 117  	MaxHeapTableSize             MaxHeapTableSize             `json:"max_heap_table_size"`
 118  	NetBufferLength              NetBufferLength              `json:"net_buffer_length"`
 119  	NetReadTimeout               NetReadTimeout               `json:"net_read_timeout"`
 120  	NetWriteTimeout              NetWriteTimeout              `json:"net_write_timeout"`
 121  	SortBufferSize               SortBufferSize               `json:"sort_buffer_size"`
 122  	SQLMode                      SQLMode                      `json:"sql_mode"`
 123  	SQLRequirePrimaryKey         SQLRequirePrimaryKey         `json:"sql_require_primary_key"`
 124  	TmpTableSize                 TmpTableSize                 `json:"tmp_table_size"`
 125  	WaitTimeout                  WaitTimeout                  `json:"wait_timeout"`
 126  }
 127  
 128  type ConnectTimeout struct {
 129  	Description     string `json:"description"`
 130  	Example         int    `json:"example"`
 131  	Maximum         int    `json:"maximum"`
 132  	Minimum         int    `json:"minimum"`
 133  	RequiresRestart bool   `json:"requires_restart"`
 134  	Type            string `json:"type"`
 135  }
 136  
 137  type DefaultTimeZone struct {
 138  	Description     string `json:"description"`
 139  	Example         string `json:"example"`
 140  	MaxLength       int    `json:"maxLength"`
 141  	MinLength       int    `json:"minLength"`
 142  	Pattern         string `json:"pattern"`
 143  	RequiresRestart bool   `json:"requires_restart"`
 144  	Type            string `json:"type"`
 145  }
 146  
 147  type GroupConcatMaxLen struct {
 148  	Description     string  `json:"description"`
 149  	Example         float64 `json:"example"`
 150  	Maximum         float64 `json:"maximum"`
 151  	Minimum         float64 `json:"minimum"`
 152  	RequiresRestart bool    `json:"requires_restart"`
 153  	Type            string  `json:"type"`
 154  }
 155  
 156  type InformationSchemaStatsExpiry struct {
 157  	Description     string `json:"description"`
 158  	Example         int    `json:"example"`
 159  	Maximum         int    `json:"maximum"`
 160  	Minimum         int    `json:"minimum"`
 161  	RequiresRestart bool   `json:"requires_restart"`
 162  	Type            string `json:"type"`
 163  }
 164  
 165  type InnoDBChangeBufferMaxSize struct {
 166  	Description     string `json:"description"`
 167  	Example         int    `json:"example"`
 168  	Maximum         int    `json:"maximum"`
 169  	Minimum         int    `json:"minimum"`
 170  	RequiresRestart bool   `json:"requires_restart"`
 171  	Type            string `json:"type"`
 172  }
 173  
 174  type InnoDBFlushNeighbors struct {
 175  	Description     string `json:"description"`
 176  	Example         int    `json:"example"`
 177  	Maximum         int    `json:"maximum"`
 178  	Minimum         int    `json:"minimum"`
 179  	RequiresRestart bool   `json:"requires_restart"`
 180  	Type            string `json:"type"`
 181  }
 182  
 183  type InnoDBFTMinTokenSize struct {
 184  	Description     string `json:"description"`
 185  	Example         int    `json:"example"`
 186  	Maximum         int    `json:"maximum"`
 187  	Minimum         int    `json:"minimum"`
 188  	RequiresRestart bool   `json:"requires_restart"`
 189  	Type            string `json:"type"`
 190  }
 191  
 192  type InnoDBFTServerStopwordTable struct {
 193  	Description     string   `json:"description"`
 194  	Example         string   `json:"example"`
 195  	MaxLength       int      `json:"maxLength"`
 196  	Pattern         string   `json:"pattern"`
 197  	RequiresRestart bool     `json:"requires_restart"`
 198  	Type            []string `json:"type"`
 199  }
 200  
 201  type InnoDBLockWaitTimeout struct {
 202  	Description     string `json:"description"`
 203  	Example         int    `json:"example"`
 204  	Maximum         int    `json:"maximum"`
 205  	Minimum         int    `json:"minimum"`
 206  	RequiresRestart bool   `json:"requires_restart"`
 207  	Type            string `json:"type"`
 208  }
 209  
 210  type InnoDBLogBufferSize struct {
 211  	Description     string `json:"description"`
 212  	Example         int    `json:"example"`
 213  	Maximum         int    `json:"maximum"`
 214  	Minimum         int    `json:"minimum"`
 215  	RequiresRestart bool   `json:"requires_restart"`
 216  	Type            string `json:"type"`
 217  }
 218  
 219  type InnoDBOnlineAlterLogMaxSize struct {
 220  	Description     string `json:"description"`
 221  	Example         int    `json:"example"`
 222  	Maximum         int    `json:"maximum"`
 223  	Minimum         int    `json:"minimum"`
 224  	RequiresRestart bool   `json:"requires_restart"`
 225  	Type            string `json:"type"`
 226  }
 227  
 228  type InnoDBReadIOThreads struct {
 229  	Description     string `json:"description"`
 230  	Example         int    `json:"example"`
 231  	Maximum         int    `json:"maximum"`
 232  	Minimum         int    `json:"minimum"`
 233  	RequiresRestart bool   `json:"requires_restart"`
 234  	Type            string `json:"type"`
 235  }
 236  
 237  type InnoDBRollbackOnTimeout struct {
 238  	Description     string `json:"description"`
 239  	Example         bool   `json:"example"`
 240  	RequiresRestart bool   `json:"requires_restart"`
 241  	Type            string `json:"type"`
 242  }
 243  
 244  type InnoDBThreadConcurrency struct {
 245  	Description     string `json:"description"`
 246  	Example         int    `json:"example"`
 247  	Maximum         int    `json:"maximum"`
 248  	Minimum         int    `json:"minimum"`
 249  	RequiresRestart bool   `json:"requires_restart"`
 250  	Type            string `json:"type"`
 251  }
 252  
 253  type InnoDBWriteIOThreads struct {
 254  	Description     string `json:"description"`
 255  	Example         int    `json:"example"`
 256  	Maximum         int    `json:"maximum"`
 257  	Minimum         int    `json:"minimum"`
 258  	RequiresRestart bool   `json:"requires_restart"`
 259  	Type            string `json:"type"`
 260  }
 261  
 262  type InteractiveTimeout struct {
 263  	Description     string `json:"description"`
 264  	Example         int    `json:"example"`
 265  	Maximum         int    `json:"maximum"`
 266  	Minimum         int    `json:"minimum"`
 267  	RequiresRestart bool   `json:"requires_restart"`
 268  	Type            string `json:"type"`
 269  }
 270  
 271  type InternalTmpMemStorageEngine struct {
 272  	Description     string   `json:"description"`
 273  	Enum            []string `json:"enum"`
 274  	Example         string   `json:"example"`
 275  	RequiresRestart bool     `json:"requires_restart"`
 276  	Type            string   `json:"type"`
 277  }
 278  
 279  type MaxAllowedPacket struct {
 280  	Description     string `json:"description"`
 281  	Example         int    `json:"example"`
 282  	Maximum         int    `json:"maximum"`
 283  	Minimum         int    `json:"minimum"`
 284  	RequiresRestart bool   `json:"requires_restart"`
 285  	Type            string `json:"type"`
 286  }
 287  
 288  type MaxHeapTableSize struct {
 289  	Description     string `json:"description"`
 290  	Example         int    `json:"example"`
 291  	Maximum         int    `json:"maximum"`
 292  	Minimum         int    `json:"minimum"`
 293  	RequiresRestart bool   `json:"requires_restart"`
 294  	Type            string `json:"type"`
 295  }
 296  
 297  type NetBufferLength struct {
 298  	Description     string `json:"description"`
 299  	Example         int    `json:"example"`
 300  	Maximum         int    `json:"maximum"`
 301  	Minimum         int    `json:"minimum"`
 302  	RequiresRestart bool   `json:"requires_restart"`
 303  	Type            string `json:"type"`
 304  }
 305  
 306  type NetReadTimeout struct {
 307  	Description     string `json:"description"`
 308  	Example         int    `json:"example"`
 309  	Maximum         int    `json:"maximum"`
 310  	Minimum         int    `json:"minimum"`
 311  	RequiresRestart bool   `json:"requires_restart"`
 312  	Type            string `json:"type"`
 313  }
 314  
 315  type NetWriteTimeout struct {
 316  	Description     string `json:"description"`
 317  	Example         int    `json:"example"`
 318  	Maximum         int    `json:"maximum"`
 319  	Minimum         int    `json:"minimum"`
 320  	RequiresRestart bool   `json:"requires_restart"`
 321  	Type            string `json:"type"`
 322  }
 323  
 324  type SortBufferSize struct {
 325  	Description     string `json:"description"`
 326  	Example         int    `json:"example"`
 327  	Maximum         int    `json:"maximum"`
 328  	Minimum         int    `json:"minimum"`
 329  	RequiresRestart bool   `json:"requires_restart"`
 330  	Type            string `json:"type"`
 331  }
 332  
 333  type SQLMode struct {
 334  	Description     string `json:"description"`
 335  	Example         string `json:"example"`
 336  	MaxLength       int    `json:"maxLength"`
 337  	Pattern         string `json:"pattern"`
 338  	RequiresRestart bool   `json:"requires_restart"`
 339  	Type            string `json:"type"`
 340  }
 341  
 342  type SQLRequirePrimaryKey struct {
 343  	Description     string `json:"description"`
 344  	Example         bool   `json:"example"`
 345  	RequiresRestart bool   `json:"requires_restart"`
 346  	Type            string `json:"type"`
 347  }
 348  
 349  type TmpTableSize struct {
 350  	Description     string `json:"description"`
 351  	Example         int    `json:"example"`
 352  	Maximum         int    `json:"maximum"`
 353  	Minimum         int    `json:"minimum"`
 354  	RequiresRestart bool   `json:"requires_restart"`
 355  	Type            string `json:"type"`
 356  }
 357  
 358  type WaitTimeout struct {
 359  	Description     string `json:"description"`
 360  	Example         int    `json:"example"`
 361  	Maximum         int    `json:"maximum"`
 362  	Minimum         int    `json:"minimum"`
 363  	RequiresRestart bool   `json:"requires_restart"`
 364  	Type            string `json:"type"`
 365  }
 366  
 367  type MySQLDatabaseConfigInfoBinlogRetentionPeriod struct {
 368  	Description     string `json:"description"`
 369  	Example         int    `json:"example"`
 370  	Maximum         int    `json:"maximum"`
 371  	Minimum         int    `json:"minimum"`
 372  	RequiresRestart bool   `json:"requires_restart"`
 373  	Type            string `json:"type"`
 374  }
 375  
 376  func (d *MySQLDatabase) UnmarshalJSON(b []byte) error {
 377  	type Mask MySQLDatabase
 378  
 379  	p := struct {
 380  		*Mask
 381  
 382  		Created           *parseabletime.ParseableTime `json:"created"`
 383  		Updated           *parseabletime.ParseableTime `json:"updated"`
 384  		OldestRestoreTime *parseabletime.ParseableTime `json:"oldest_restore_time"`
 385  	}{
 386  		Mask: (*Mask)(d),
 387  	}
 388  
 389  	if err := json.Unmarshal(b, &p); err != nil {
 390  		return err
 391  	}
 392  
 393  	d.Created = (*time.Time)(p.Created)
 394  	d.Updated = (*time.Time)(p.Updated)
 395  	d.OldestRestoreTime = (*time.Time)(p.OldestRestoreTime)
 396  
 397  	return nil
 398  }
 399  
 400  // MySQLCreateOptions fields are used when creating a new MySQL Database
 401  type MySQLCreateOptions struct {
 402  	Label       string   `json:"label"`
 403  	Region      string   `json:"region"`
 404  	Type        string   `json:"type"`
 405  	Engine      string   `json:"engine"`
 406  	AllowList   []string `json:"allow_list,omitempty"`
 407  	ClusterSize int      `json:"cluster_size,omitempty"`
 408  
 409  	// Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2.
 410  	ReplicationType string `json:"replication_type,omitempty"`
 411  	// Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2.
 412  	Encrypted bool `json:"encrypted,omitempty"`
 413  	// Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
 414  	SSLConnection bool `json:"ssl_connection,omitempty"`
 415  
 416  	Fork           *DatabaseFork              `json:"fork,omitempty"`
 417  	EngineConfig   *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
 418  	PrivateNetwork *DatabasePrivateNetwork    `json:"private_network,omitempty"`
 419  }
 420  
 421  // MySQLUpdateOptions fields are used when altering the existing MySQL Database
 422  type MySQLUpdateOptions struct {
 423  	Label          string                     `json:"label,omitempty"`
 424  	AllowList      *[]string                  `json:"allow_list,omitempty"`
 425  	Updates        *DatabaseMaintenanceWindow `json:"updates,omitempty"`
 426  	Type           string                     `json:"type,omitempty"`
 427  	ClusterSize    int                        `json:"cluster_size,omitempty"`
 428  	Version        string                     `json:"version,omitempty"`
 429  	EngineConfig   *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
 430  	PrivateNetwork **DatabasePrivateNetwork   `json:"private_network,omitempty"`
 431  }
 432  
 433  // MySQLDatabaseBackup is information for interacting with a backup for the existing MySQL Database
 434  
 435  // Deprecated: MySQLDatabaseBackup is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
 436  // In DBaaS V2, databases can be backed up via database forking.
 437  type MySQLDatabaseBackup struct {
 438  	ID      int        `json:"id"`
 439  	Label   string     `json:"label"`
 440  	Type    string     `json:"type"`
 441  	Created *time.Time `json:"-"`
 442  }
 443  
 444  // MySQLBackupCreateOptions are options used for CreateMySQLDatabaseBackup(...)
 445  //
 446  // Deprecated: MySQLBackupCreateOptions is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
 447  // In DBaaS V2, databases can be backed up via database forking.
 448  type MySQLBackupCreateOptions struct {
 449  	Label  string              `json:"label"`
 450  	Target MySQLDatabaseTarget `json:"target"`
 451  }
 452  
 453  func (d *MySQLDatabaseBackup) UnmarshalJSON(b []byte) error {
 454  	type Mask MySQLDatabaseBackup
 455  
 456  	p := struct {
 457  		*Mask
 458  
 459  		Created *parseabletime.ParseableTime `json:"created"`
 460  	}{
 461  		Mask: (*Mask)(d),
 462  	}
 463  
 464  	if err := json.Unmarshal(b, &p); err != nil {
 465  		return err
 466  	}
 467  
 468  	d.Created = (*time.Time)(p.Created)
 469  
 470  	return nil
 471  }
 472  
 473  // MySQLDatabaseCredential is the Root Credentials to access the Linode Managed Database
 474  type MySQLDatabaseCredential struct {
 475  	Username string `json:"username"`
 476  	Password string `json:"password"`
 477  }
 478  
 479  // MySQLDatabaseSSL is the SSL Certificate to access the Linode Managed MySQL Database
 480  type MySQLDatabaseSSL struct {
 481  	CACertificate []byte `json:"ca_certificate"`
 482  }
 483  
 484  // ListMySQLDatabases lists all MySQL Databases associated with the account
 485  func (c *Client) ListMySQLDatabases(ctx context.Context, opts *ListOptions) ([]MySQLDatabase, error) {
 486  	return getPaginatedResults[MySQLDatabase](ctx, c, "databases/mysql/instances", opts)
 487  }
 488  
 489  // ListMySQLDatabaseBackups lists all MySQL Database Backups associated with the given MySQL Database
 490  //
 491  // Deprecated: ListMySQLDatabaseBackups is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
 492  // In DBaaS V2, databases can be backed up via database forking.
 493  func (c *Client) ListMySQLDatabaseBackups(ctx context.Context, databaseID int, opts *ListOptions) ([]MySQLDatabaseBackup, error) {
 494  	return getPaginatedResults[MySQLDatabaseBackup](ctx, c, formatAPIPath("databases/mysql/instances/%d/backups", databaseID), opts)
 495  }
 496  
 497  // GetMySQLDatabase returns a single MySQL Database matching the id
 498  func (c *Client) GetMySQLDatabase(ctx context.Context, databaseID int) (*MySQLDatabase, error) {
 499  	e := formatAPIPath("databases/mysql/instances/%d", databaseID)
 500  	return doGETRequest[MySQLDatabase](ctx, c, e)
 501  }
 502  
 503  // CreateMySQLDatabase creates a new MySQL Database using the createOpts as configuration, returns the new MySQL Database
 504  func (c *Client) CreateMySQLDatabase(ctx context.Context, opts MySQLCreateOptions) (*MySQLDatabase, error) {
 505  	return doPOSTRequest[MySQLDatabase](ctx, c, "databases/mysql/instances", opts)
 506  }
 507  
 508  // DeleteMySQLDatabase deletes an existing MySQL Database with the given id
 509  func (c *Client) DeleteMySQLDatabase(ctx context.Context, databaseID int) error {
 510  	e := formatAPIPath("databases/mysql/instances/%d", databaseID)
 511  	return doDELETERequest(ctx, c, e)
 512  }
 513  
 514  // UpdateMySQLDatabase updates the given MySQL Database with the provided opts, returns the MySQLDatabase with the new settings
 515  func (c *Client) UpdateMySQLDatabase(ctx context.Context, databaseID int, opts MySQLUpdateOptions) (*MySQLDatabase, error) {
 516  	e := formatAPIPath("databases/mysql/instances/%d", databaseID)
 517  	return doPUTRequest[MySQLDatabase](ctx, c, e, opts)
 518  }
 519  
 520  // GetMySQLDatabaseSSL returns the SSL Certificate for the given MySQL Database
 521  func (c *Client) GetMySQLDatabaseSSL(ctx context.Context, databaseID int) (*MySQLDatabaseSSL, error) {
 522  	e := formatAPIPath("databases/mysql/instances/%d/ssl", databaseID)
 523  	return doGETRequest[MySQLDatabaseSSL](ctx, c, e)
 524  }
 525  
 526  // GetMySQLDatabaseCredentials returns the Root Credentials for the given MySQL Database
 527  func (c *Client) GetMySQLDatabaseCredentials(ctx context.Context, databaseID int) (*MySQLDatabaseCredential, error) {
 528  	e := formatAPIPath("databases/mysql/instances/%d/credentials", databaseID)
 529  	return doGETRequest[MySQLDatabaseCredential](ctx, c, e)
 530  }
 531  
 532  // ResetMySQLDatabaseCredentials returns the Root Credentials for the given MySQL Database (may take a few seconds to work)
 533  func (c *Client) ResetMySQLDatabaseCredentials(ctx context.Context, databaseID int) error {
 534  	e := formatAPIPath("databases/mysql/instances/%d/credentials/reset", databaseID)
 535  	return doPOSTRequestNoRequestResponseBody(ctx, c, e)
 536  }
 537  
 538  // GetMySQLDatabaseBackup returns a specific MySQL Database Backup with the given ids
 539  //
 540  // Deprecated: GetMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
 541  // In DBaaS V2, databases can be backed up via database forking.
 542  func (c *Client) GetMySQLDatabaseBackup(ctx context.Context, databaseID int, backupID int) (*MySQLDatabaseBackup, error) {
 543  	e := formatAPIPath("databases/mysql/instances/%d/backups/%d", databaseID, backupID)
 544  	return doGETRequest[MySQLDatabaseBackup](ctx, c, e)
 545  }
 546  
 547  // RestoreMySQLDatabaseBackup returns the given MySQL Database with the given Backup
 548  //
 549  // Deprecated: RestoreMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
 550  // In DBaaS V2, databases can be backed up via database forking.
 551  func (c *Client) RestoreMySQLDatabaseBackup(ctx context.Context, databaseID int, backupID int) error {
 552  	e := formatAPIPath("databases/mysql/instances/%d/backups/%d/restore", databaseID, backupID)
 553  	return doPOSTRequestNoRequestResponseBody(ctx, c, e)
 554  }
 555  
 556  // CreateMySQLDatabaseBackup creates a snapshot for the given MySQL database
 557  //
 558  // Deprecated: CreateMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
 559  // In DBaaS V2, databases can be backed up via database forking.
 560  func (c *Client) CreateMySQLDatabaseBackup(ctx context.Context, databaseID int, opts MySQLBackupCreateOptions) error {
 561  	e := formatAPIPath("databases/mysql/instances/%d/backups", databaseID)
 562  	return doPOSTRequestNoResponseBody(ctx, c, e, opts)
 563  }
 564  
 565  // PatchMySQLDatabase applies security patches and updates to the underlying operating system of the Managed MySQL Database
 566  func (c *Client) PatchMySQLDatabase(ctx context.Context, databaseID int) error {
 567  	e := formatAPIPath("databases/mysql/instances/%d/patch", databaseID)
 568  	return doPOSTRequestNoRequestResponseBody(ctx, c, e)
 569  }
 570  
 571  // SuspendMySQLDatabase suspends a MySQL Managed Database, releasing idle resources and keeping only necessary data.
 572  // All service data is lost if there are no backups available.
 573  func (c *Client) SuspendMySQLDatabase(ctx context.Context, databaseID int) error {
 574  	e := formatAPIPath("databases/mysql/instances/%d/suspend", databaseID)
 575  	return doPOSTRequestNoRequestResponseBody(ctx, c, e)
 576  }
 577  
 578  // ResumeMySQLDatabase resumes a suspended MySQL Managed Database
 579  func (c *Client) ResumeMySQLDatabase(ctx context.Context, databaseID int) error {
 580  	e := formatAPIPath("databases/mysql/instances/%d/resume", databaseID)
 581  	return doPOSTRequestNoRequestResponseBody(ctx, c, e)
 582  }
 583  
 584  // GetMySQLDatabaseConfig returns a detailed list of all the configuration options for MySQL Databases
 585  func (c *Client) GetMySQLDatabaseConfig(ctx context.Context) (*MySQLDatabaseConfigInfo, error) {
 586  	return doGETRequest[MySQLDatabaseConfigInfo](ctx, c, "databases/mysql/config")
 587  }
 588