deps: Actually update Riviera files

pull/6530/head
James Nugent 10 years ago
parent 2bfa8c9836
commit 747c8387d4

@ -16,11 +16,15 @@ type APIInfo struct {
URLPathFunc func() string
ResponseTypeFunc func() interface{}
RequestPropertiesFunc func() interface{}
HasBodyOverride bool
}
// HasBody returns true if the API Request should have a body. This is usually
// the case for PUT, PATCH or POST operations, but is not the case for GET operations.
// TODO(jen20): This may need revisiting at some point.
func (apiInfo APIInfo) HasBody() bool {
return apiInfo.Method == "POST" || apiInfo.Method == "PUT" || apiInfo.Method == "PATCH"
if apiInfo.HasBodyOverride == false {
return apiInfo.Method == "POST" || apiInfo.Method == "PUT" || apiInfo.Method == "PATCH"
}
return !(apiInfo.Method == "POST" || apiInfo.Method == "PUT" || apiInfo.Method == "PATCH")
}

@ -5,6 +5,7 @@ import (
"log"
"github.com/hashicorp/go-retryablehttp"
"net/http"
)
type Client struct {
@ -34,6 +35,10 @@ func NewClient(creds *AzureResourceManagerCredentials) (*Client, error) {
}, nil
}
func (c *Client) SetRequestLoggingHook(hook func (*log.Logger, *http.Request, int)) {
c.httpClient.RequestLogHook = hook
}
func (c *Client) SetLogger(newLogger *log.Logger) {
c.logger = newLogger
c.httpClient.Logger = newLogger

@ -11,6 +11,24 @@ func String(input string) *string {
return &input
}
// Int32 returns a pointer to the input int32. This is useful when initializing
// structures.
func Int32(input int32) *int32 {
return &input
}
// Int64 returns a pointer to the input int64. This is useful when initializing
// structures.
func Int64(input int64) *int64 {
return &input
}
// Bool returns a pointer to the input bool. This is useful when initializing
// structures.
func Bool(input bool) *bool {
return &input
}
// isSuccessCode returns true for 200-range numbers which usually denote
// that an HTTP request was successful
func isSuccessCode(statusCode int) bool {

@ -23,6 +23,12 @@ func sqlDatabaseDefaultURLPath(resourceGroupName, serverName, databaseName strin
}
}
func sqlDatabaseFailoverUnplanned(resourceGroupName, serverName, databaseName, linkID string) func() string {
return func() string {
return fmt.Sprintf("resourcegroups/%s/providers/%s/servers/%s/databases/%s/replicationLinks/%s/forceFailoverAllowDataLoss", resourceGroupName, apiProvider, serverName, databaseName, linkID)
}
}
func sqlServerFirewallDefaultURLPath(resourceGroupName, serverName, firewallRuleName string) func() string {
return func() string {
return fmt.Sprintf("resourceGroups/%s/providers/%s/servers/%s/firewallRules/%s", resourceGroupName, apiProvider, serverName, firewallRuleName)

@ -0,0 +1,22 @@
package sql
import "github.com/jen20/riviera/azure"
type FailoverDatabase struct {
DatabaseName string `json:"-"`
ServerName string `json:"-"`
ResourceGroupName string `json:"-"`
LinkID string `json:"-"`
}
func (s FailoverDatabase) APIInfo() azure.APIInfo {
return azure.APIInfo{
APIVersion: apiVersion,
Method: "POST",
URLPathFunc: sqlDatabaseFailoverUnplanned(s.ResourceGroupName, s.ServerName, s.DatabaseName, s.LinkID),
ResponseTypeFunc: func() interface{} {
return nil
},
HasBodyOverride: true,
}
}
Loading…
Cancel
Save