From 747c8387d4ffe09b9dde2021fa4f8bbf4209396e Mon Sep 17 00:00:00 2001 From: James Nugent Date: Fri, 6 May 2016 17:36:25 -0700 Subject: [PATCH] deps: Actually update Riviera files --- .../github.com/jen20/riviera/azure/apicall.go | 6 ++++- .../github.com/jen20/riviera/azure/client.go | 5 +++++ .../github.com/jen20/riviera/azure/utils.go | 18 +++++++++++++++ vendor/github.com/jen20/riviera/sql/api.go | 6 +++++ .../jen20/riviera/sql/failover_database.go | 22 +++++++++++++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 vendor/github.com/jen20/riviera/sql/failover_database.go diff --git a/vendor/github.com/jen20/riviera/azure/apicall.go b/vendor/github.com/jen20/riviera/azure/apicall.go index 0efad15923..dce9be9550 100644 --- a/vendor/github.com/jen20/riviera/azure/apicall.go +++ b/vendor/github.com/jen20/riviera/azure/apicall.go @@ -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") } diff --git a/vendor/github.com/jen20/riviera/azure/client.go b/vendor/github.com/jen20/riviera/azure/client.go index 8db91edc93..937760dc2d 100644 --- a/vendor/github.com/jen20/riviera/azure/client.go +++ b/vendor/github.com/jen20/riviera/azure/client.go @@ -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 diff --git a/vendor/github.com/jen20/riviera/azure/utils.go b/vendor/github.com/jen20/riviera/azure/utils.go index c2cfc0980c..a812a47558 100644 --- a/vendor/github.com/jen20/riviera/azure/utils.go +++ b/vendor/github.com/jen20/riviera/azure/utils.go @@ -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 { diff --git a/vendor/github.com/jen20/riviera/sql/api.go b/vendor/github.com/jen20/riviera/sql/api.go index c08ed85f0f..1d130d3218 100644 --- a/vendor/github.com/jen20/riviera/sql/api.go +++ b/vendor/github.com/jen20/riviera/sql/api.go @@ -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) diff --git a/vendor/github.com/jen20/riviera/sql/failover_database.go b/vendor/github.com/jen20/riviera/sql/failover_database.go new file mode 100644 index 0000000000..5234219795 --- /dev/null +++ b/vendor/github.com/jen20/riviera/sql/failover_database.go @@ -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, + } +}