Documentation ¶
Overview ¶
Example (PerformServerOperations) ¶
Example_performServerOperations creates a postgresql server, updates it, add firewall rules and configurations and at the end it deletes it.
serverName = strings.ToLower(serverName) ctx := context.Background() defer resources.Cleanup(ctx) if _, err := resources.CreateGroup(ctx, groupName); err != nil { util.LogAndPanic(err) } util.PrintAndLog("resource group created") // Create the server. if _, err := CreateServer(ctx, groupName, serverName, dbLogin, dbPassword); err != nil { util.LogAndPanic(fmt.Errorf("cannot create postgresql server: %+v", err)) } util.PrintAndLog("postgresql server created") // Update the server's storage capacity field. if _, err := UpdateServerStorageCapacity(ctx, groupName, serverName, 1048576); err != nil { util.LogAndPanic(fmt.Errorf("cannot update postgresql server: %+v", err)) } util.PrintAndLog("postgresql server's storage capacity updated") if _, err := CreateOrUpdateFirewallRule(ctx, groupName, serverName, "FirewallRuleName", "0.0.0.0", "0.0.0.0"); err != nil { util.LogAndPanic(err) } util.PrintAndLog("firewall rule set created") if _, err := CreateOrUpdateFirewallRule(ctx, groupName, serverName, "FirewallRuleName", "0.0.0.0", "1.1.1.1"); err != nil { util.LogAndPanic(err) } util.PrintAndLog("firewall rule updated") var configuration flexibleservers.Configuration configuration, err := GetConfiguration(ctx, groupName, serverName, "max_replication_slots") if err != nil { util.LogAndPanic(err) } util.PrintAndLog("got the max_replication_slots configuration") // Update the configuration Value. configuration.ConfigurationProperties.Value = to.StringPtr("20") configuration.ConfigurationProperties.Source = to.StringPtr("user-override") if _, err := UpdateConfiguration(ctx, groupName, serverName, "max_replication_slots", configuration); err != nil { util.LogAndPanic(err) } util.PrintAndLog("max_replication_slots configuration updated") // Finally delete the server. if _, err := DeleteServer(ctx, groupName, serverName); err != nil { util.LogAndPanic(err) } util.PrintAndLog("postgresql server deleted")
Output: resource group created postgresql server created postgresql server's storage capacity updated firewall rule set created firewall rule updated got the max_replication_slots configuration max_replication_slots configuration updated postgresql server deleted
Index ¶
- func CreateOrUpdateFirewallRule(ctx context.Context, ...) (rule flexibleservers.FirewallRule, err error)
- func CreateServer(ctx context.Context, resourceGroup, serverName, dbLogin, dbPassword string) (server flexibleservers.Server, err error)
- func DeleteServer(ctx context.Context, resourceGroup, serverName string) (resp autorest.Response, err error)
- func GetConfiguration(ctx context.Context, resourceGroup, serverName, configurationName string) (flexibleservers.Configuration, error)
- func UpdateConfiguration(ctx context.Context, resourceGroup, serverName string, ...) (updatedConfig flexibleservers.Configuration, err error)
- func UpdateServerStorageCapacity(ctx context.Context, resourceGroup, serverName string, storageCapacity int32) (server flexibleservers.Server, err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateOrUpdateFirewallRule ¶
func CreateOrUpdateFirewallRule(ctx context.Context, resourceGroup, serverName, firewallRuleName, startIPAddr, endIPAddr string) (rule flexibleservers.FirewallRule, err error)
CreateOrUpdateFirewallRule given the firewallname and new properties it updates the firewall rule.
func CreateServer ¶
func CreateServer(ctx context.Context, resourceGroup, serverName, dbLogin, dbPassword string) (server flexibleservers.Server, err error)
CreateServer creates a new PostgreSQL Server
func DeleteServer ¶
func DeleteServer(ctx context.Context, resourceGroup, serverName string) (resp autorest.Response, err error)
DeleteServer deletes the PostgreSQL server.
func GetConfiguration ¶
func GetConfiguration(ctx context.Context, resourceGroup, serverName, configurationName string) (flexibleservers.Configuration, error)
GetConfiguration given the server name and configuration name it returns the configuration.
func UpdateConfiguration ¶
func UpdateConfiguration(ctx context.Context, resourceGroup, serverName string, configurationName string, configuration flexibleservers.Configuration) (updatedConfig flexibleservers.Configuration, err error)
UpdateConfiguration given the name of the configuation and the configuration object it updates the configuration for the given server.
func UpdateServerStorageCapacity ¶
func UpdateServerStorageCapacity(ctx context.Context, resourceGroup, serverName string, storageCapacity int32) (server flexibleservers.Server, err error)
UpdateServerStorageCapacity given the server name and the new storage capacity it updates the server's storage capacity.
Types ¶
This section is empty.