From 41f3ad88bc84dc2c66f6f8c1c9ed302af31b271e Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 6 Apr 2018 10:56:29 +0200 Subject: [PATCH 1/6] Support for Redis Caches being hosted on an Internal Network --- azurerm/resource_arm_redis_cache.go | 60 +++++++-- azurerm/resource_arm_redis_cache_test.go | 150 +++++++++++++++++++++++ website/docs/r/redis_cache.html.markdown | 8 +- 3 files changed, 203 insertions(+), 15 deletions(-) diff --git a/azurerm/resource_arm_redis_cache.go b/azurerm/resource_arm_redis_cache.go index c5637226370f..4611b453b679 100644 --- a/azurerm/resource_arm_redis_cache.go +++ b/azurerm/resource_arm_redis_cache.go @@ -74,6 +74,17 @@ func resourceArmRedisCache() *schema.Resource { Optional: true, }, + "subnet_id": { + Type: schema.TypeString, + Optional: true, + }, + + "private_static_ip_address": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "redis_configuration": { Type: schema.TypeList, Required: true, @@ -211,12 +222,12 @@ func resourceArmRedisCacheCreate(d *schema.ResourceData, meta interface{}) error } parameters := redis.CreateParameters{ - Name: &name, - Location: &location, + Name: utils.String(name), + Location: utils.String(location), CreateProperties: &redis.CreateProperties{ - EnableNonSslPort: &enableNonSSLPort, + EnableNonSslPort: utils.Bool(enableNonSSLPort), Sku: &redis.Sku{ - Capacity: &capacity, + Capacity: utils.Int32(capacity), Family: family, Name: sku, }, @@ -230,6 +241,14 @@ func resourceArmRedisCacheCreate(d *schema.ResourceData, meta interface{}) error parameters.ShardCount = &shardCount } + if v, ok := d.GetOk("private_static_ip_address"); ok { + parameters.StaticIP = utils.String(v.(string)) + } + + if v, ok := d.GetOk("subnet_id"); ok { + parameters.SubnetID = utils.String(v.(string)) + } + future, err := client.Create(ctx, resGroup, name, parameters) if err != nil { return err @@ -292,9 +311,9 @@ func resourceArmRedisCacheUpdate(d *schema.ResourceData, meta interface{}) error parameters := redis.UpdateParameters{ UpdateProperties: &redis.UpdateProperties{ - EnableNonSslPort: &enableNonSSLPort, + EnableNonSslPort: utils.Bool(enableNonSSLPort), Sku: &redis.Sku{ - Capacity: &capacity, + Capacity: utils.Int32(capacity), Family: family, Name: sku, }, @@ -309,6 +328,18 @@ func resourceArmRedisCacheUpdate(d *schema.ResourceData, meta interface{}) error } } + if v, ok := d.GetOk("private_static_ip_address"); ok { + if d.HasChange("private_static_ip_address") { + parameters.StaticIP = utils.String(v.(string)) + } + } + + if v, ok := d.GetOk("subnet_id"); ok { + if d.HasChange("subnet_id") { + parameters.SubnetID = utils.String(v.(string)) + } + } + if d.HasChange("redis_configuration") { redisConfiguration := expandRedisConfiguration(d) parameters.RedisConfiguration = redisConfiguration @@ -406,19 +437,22 @@ func resourceArmRedisCacheRead(d *schema.ResourceData, meta interface{}) error { d.Set("location", azureRMNormalizeLocation(*location)) } - d.Set("ssl_port", resp.SslPort) - d.Set("hostname", resp.HostName) - d.Set("port", resp.Port) - d.Set("enable_non_ssl_port", resp.EnableNonSslPort) - if sku := resp.Sku; sku != nil { d.Set("capacity", sku.Capacity) d.Set("family", sku.Family) d.Set("sku_name", sku.Name) } - if resp.ShardCount != nil { - d.Set("shard_count", resp.ShardCount) + if props := resp.ResourceProperties; props != nil { + d.Set("ssl_port", props.SslPort) + d.Set("hostname", props.HostName) + d.Set("port", props.Port) + d.Set("enable_non_ssl_port", props.EnableNonSslPort) + if props.ShardCount != nil { + d.Set("shard_count", props.ShardCount) + } + d.Set("private_static_ip_address", props.StaticIP) + d.Set("subnet_id", props.SubnetID) } redisConfiguration := flattenRedisConfiguration(resp.RedisConfiguration) diff --git a/azurerm/resource_arm_redis_cache_test.go b/azurerm/resource_arm_redis_cache_test.go index 63c1f26e718d..fa13a231481b 100644 --- a/azurerm/resource_arm_redis_cache_test.go +++ b/azurerm/resource_arm_redis_cache_test.go @@ -318,6 +318,82 @@ func TestAccAzureRMRedisCache_PatchScheduleUpdated(t *testing.T) { }) } +func TestAccAzureRMRedisCache_InternalSubnet(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMRedisCache_internalSubnet(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMRedisCacheDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMRedisCacheExists("azurerm_redis_cache.test"), + ), + }, + }, + }) +} + +func TestAccAzureRMRedisCache_InternalSubnetStaticIP(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMRedisCache_internalSubnetStaticIP(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMRedisCacheDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMRedisCacheExists("azurerm_redis_cache.test"), + ), + }, + }, + }) +} + +func TestAccAzureRMRedisCache_InternalSubnetUpdate(t *testing.T) { + resourceName := "azurerm_redis_cache.test" + ri := acctest.RandInt() + location := testLocation() + + config := testAccAzureRMRedisCache_premium(ri, location) + updatedConfig := testAccAzureRMRedisCache_internalSubnet(ri, location) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMRedisCacheDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMRedisCacheExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "subnet_id", ""), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMRedisCacheExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "subnet_id"), + ), + }, + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMRedisCacheExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "subnet_id", ""), + ), + }, + }, + }) +} + func testCheckAzureRMRedisCacheExists(name string) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -635,3 +711,77 @@ resource "azurerm_redis_cache" "test" { } `, rInt, location, rString, rInt) } +func testAccAzureRMRedisCache_internalSubnet(ri int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestnw-%d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "testsubnet" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.1.0/24" +} + +resource "azurerm_redis_cache" "test" { + name = "acctestRedis-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + capacity = 1 + family = "P" + sku_name = "Premium" + enable_non_ssl_port = false + subnet_id = "${azurerm_subnet.test.id}" + redis_configuration { + maxclients = "256" + } +} +`, ri, location, ri, ri) +} + +func testAccAzureRMRedisCache_internalSubnetStaticIP(ri int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestnw-%d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "testsubnet" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.1.0/24" +} + +resource "azurerm_redis_cache" "test" { + name = "acctestRedis-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + capacity = 1 + family = "P" + sku_name = "Premium" + enable_non_ssl_port = false + subnet_id = "${azurerm_subnet.test.id}" + private_static_ip_address = "10.0.1.20" + redis_configuration { + maxclients = "256" + } +} +`, ri, location, ri, ri) +} diff --git a/website/docs/r/redis_cache.html.markdown b/website/docs/r/redis_cache.html.markdown index 7fb4d856cc1e..0e6efa655e2b 100644 --- a/website/docs/r/redis_cache.html.markdown +++ b/website/docs/r/redis_cache.html.markdown @@ -163,11 +163,15 @@ The pricing group for the Redis Family - either "C" or "P" at present. * `enable_non_ssl_port` - (Optional) Enable the non-SSL port (6789) - disabled by default. -* `shard_count` - (Optional) *Only available when using the Premium SKU* The number of Shards to create on the Redis Cluster. +* `patch_schedule` - (Optional) A list of `patch_schedule` blocks as defined below - only available for Premium SKU's. + +* `private_static_ip_address` - (Optional) The Static IP Address to assign to the Redis Cache when hosted inside the Virtual Network. * `redis_configuration` - (Required) A `redis_configuration` as defined below - with some limitations by SKU - defaults/details are shown below. -* `patch_schedule` - (Optional) A list of `patch_schedule` blocks as defined below - only available for Premium SKU's. +* `shard_count` - (Optional) *Only available when using the Premium SKU* The number of Shards to create on the Redis Cluster. + +* `subnet_id` - (Optional) The ID of the Subnet within which the Redis Cache should be deployed. --- From a34f5e12c4d46063d99693b9c95da867246bd1af Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 6 Apr 2018 14:14:08 +0200 Subject: [PATCH 2/6] Vendoring version `2018-03-01` of the Redis SDK --- .../mgmt/2016-04-01/redis/firewallrule.go | 256 ---- .../mgmt/2016-04-01/redis/firewallrules.go | 134 --- .../redis/client.go | 2 +- .../mgmt/2018-03-01/redis/firewallrules.go | 350 ++++++ .../mgmt/2018-03-01/redis/linkedserver.go | 352 ++++++ .../redis/models.go | 1067 ++++++++++++----- .../redis/operations.go | 2 +- .../redis/patchschedules.go | 15 +- .../{2016-04-01 => 2018-03-01}/redis/redis.go | 170 ++- .../redis/version.go | 2 +- vendor/vendor.json | 4 +- 11 files changed, 1627 insertions(+), 727 deletions(-) delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/firewallrule.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/firewallrules.go rename vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/{2016-04-01 => 2018-03-01}/redis/client.go (99%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/firewallrules.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/linkedserver.go rename vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/{2016-04-01 => 2018-03-01}/redis/models.go (67%) rename vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/{2016-04-01 => 2018-03-01}/redis/operations.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/{2016-04-01 => 2018-03-01}/redis/patchschedules.go (95%) rename vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/{2016-04-01 => 2018-03-01}/redis/redis.go (82%) rename vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/{2016-04-01 => 2018-03-01}/redis/version.go (94%) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/firewallrule.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/firewallrule.go deleted file mode 100644 index 67aadb354a5c..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/firewallrule.go +++ /dev/null @@ -1,256 +0,0 @@ -package redis - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// 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. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "net/http" -) - -// FirewallRuleClient is the REST API for Azure Redis Cache Service. -type FirewallRuleClient struct { - BaseClient -} - -// NewFirewallRuleClient creates an instance of the FirewallRuleClient client. -func NewFirewallRuleClient(subscriptionID string) FirewallRuleClient { - return NewFirewallRuleClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewFirewallRuleClientWithBaseURI creates an instance of the FirewallRuleClient client. -func NewFirewallRuleClientWithBaseURI(baseURI string, subscriptionID string) FirewallRuleClient { - return FirewallRuleClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate create or update a redis cache firewall rule -// -// resourceGroupName is the name of the resource group. cacheName is the name of the Redis cache. ruleName is the -// name of the firewall rule. parameters is parameters supplied to the create or update redis firewall rule -// operation. -func (client FirewallRuleClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, parameters FirewallRule) (result FirewallRule, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIP", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.FirewallRuleProperties.EndIP", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("redis.FirewallRuleClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, cacheName, ruleName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client FirewallRuleClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, parameters FirewallRule) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "cacheName": autorest.Encode("path", cacheName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "ruleName": autorest.Encode("path", ruleName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-04-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client FirewallRuleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client FirewallRuleClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a single firewall rule in a specified redis cache. -// -// resourceGroupName is the name of the resource group. cacheName is the name of the Redis cache. ruleName is the -// name of the firewall rule. -func (client FirewallRuleClient) Delete(ctx context.Context, resourceGroupName string, cacheName string, ruleName string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(ctx, resourceGroupName, cacheName, ruleName) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client FirewallRuleClient) DeletePreparer(ctx context.Context, resourceGroupName string, cacheName string, ruleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "cacheName": autorest.Encode("path", cacheName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "ruleName": autorest.Encode("path", ruleName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-04-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client FirewallRuleClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client FirewallRuleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets a single firewall rule in a specified redis cache. -// -// resourceGroupName is the name of the resource group. cacheName is the name of the Redis cache. ruleName is the -// name of the firewall rule. -func (client FirewallRuleClient) Get(ctx context.Context, resourceGroupName string, cacheName string, ruleName string) (result FirewallRule, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, cacheName, ruleName) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client FirewallRuleClient) GetPreparer(ctx context.Context, resourceGroupName string, cacheName string, ruleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "cacheName": autorest.Encode("path", cacheName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "ruleName": autorest.Encode("path", ruleName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-04-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client FirewallRuleClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client FirewallRuleClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/firewallrules.go deleted file mode 100644 index 45a38dac9723..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/firewallrules.go +++ /dev/null @@ -1,134 +0,0 @@ -package redis - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// 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. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// FirewallRulesClient is the REST API for Azure Redis Cache Service. -type FirewallRulesClient struct { - BaseClient -} - -// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. -func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { - return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient client. -func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { - return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List gets all firewall rules in the specified redis cache. -// -// resourceGroupName is the name of the resource group. cacheName is the name of the Redis cache. -func (client FirewallRulesClient) List(ctx context.Context, resourceGroupName string, cacheName string) (result FirewallRuleListResultPage, err error) { - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, cacheName) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.frlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "List", resp, "Failure sending request") - return - } - - result.frlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client FirewallRulesClient) ListPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "cacheName": autorest.Encode("path", cacheName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-04-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client FirewallRulesClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client FirewallRulesClient) ListResponder(resp *http.Response) (result FirewallRuleListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client FirewallRulesClient) listNextResults(lastResults FirewallRuleListResult) (result FirewallRuleListResult, err error) { - req, err := lastResults.firewallRuleListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client FirewallRulesClient) ListComplete(ctx context.Context, resourceGroupName string, cacheName string) (result FirewallRuleListResultIterator, err error) { - result.page, err = client.List(ctx, resourceGroupName, cacheName) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/client.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/client.go index 4f4d02fb0d09..a22618843a8d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/client.go @@ -1,4 +1,4 @@ -// Package redis implements the Azure ARM Redis service API version 2016-04-01. +// Package redis implements the Azure ARM Redis service API version 2018-03-01. // // REST API for Azure Redis Cache Service. package redis diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/firewallrules.go new file mode 100644 index 000000000000..6d215106efe3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/firewallrules.go @@ -0,0 +1,350 @@ +package redis + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// 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. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FirewallRulesClient is the REST API for Azure Redis Cache Service. +type FirewallRulesClient struct { + BaseClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a redis cache firewall rule +// +// resourceGroupName is the name of the resource group. cacheName is the name of the Redis cache. ruleName is the +// name of the firewall rule. parameters is parameters supplied to the create or update redis firewall rule +// operation. +func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, parameters FirewallRuleCreateParameters) (result FirewallRule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIP", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FirewallRuleProperties.EndIP", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("redis.FirewallRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, cacheName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, parameters FirewallRuleCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a single firewall rule in a specified redis cache. +// +// resourceGroupName is the name of the resource group. cacheName is the name of the Redis cache. ruleName is the +// name of the firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, cacheName string, ruleName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, cacheName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, cacheName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a single firewall rule in a specified redis cache. +// +// resourceGroupName is the name of the resource group. cacheName is the name of the Redis cache. ruleName is the +// name of the firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, cacheName string, ruleName string) (result FirewallRule, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, cacheName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, cacheName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByRedisResource gets all firewall rules in the specified redis cache. +// +// resourceGroupName is the name of the resource group. cacheName is the name of the Redis cache. +func (client FirewallRulesClient) ListByRedisResource(ctx context.Context, resourceGroupName string, cacheName string) (result FirewallRuleListResultPage, err error) { + result.fn = client.listByRedisResourceNextResults + req, err := client.ListByRedisResourcePreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "ListByRedisResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRedisResourceSender(req) + if err != nil { + result.frlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "ListByRedisResource", resp, "Failure sending request") + return + } + + result.frlr, err = client.ListByRedisResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "ListByRedisResource", resp, "Failure responding to request") + } + + return +} + +// ListByRedisResourcePreparer prepares the ListByRedisResource request. +func (client FirewallRulesClient) ListByRedisResourcePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRedisResourceSender sends the ListByRedisResource request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ListByRedisResourceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRedisResourceResponder handles the response to the ListByRedisResource request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByRedisResourceResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByRedisResourceNextResults retrieves the next set of results, if any. +func (client FirewallRulesClient) listByRedisResourceNextResults(lastResults FirewallRuleListResult) (result FirewallRuleListResult, err error) { + req, err := lastResults.firewallRuleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "listByRedisResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByRedisResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "listByRedisResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByRedisResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "listByRedisResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByRedisResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client FirewallRulesClient) ListByRedisResourceComplete(ctx context.Context, resourceGroupName string, cacheName string) (result FirewallRuleListResultIterator, err error) { + result.page, err = client.ListByRedisResource(ctx, resourceGroupName, cacheName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/linkedserver.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/linkedserver.go new file mode 100644 index 000000000000..3f5d7fd641c7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/linkedserver.go @@ -0,0 +1,352 @@ +package redis + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// 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. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// LinkedServerClient is the REST API for Azure Redis Cache Service. +type LinkedServerClient struct { + BaseClient +} + +// NewLinkedServerClient creates an instance of the LinkedServerClient client. +func NewLinkedServerClient(subscriptionID string) LinkedServerClient { + return NewLinkedServerClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLinkedServerClientWithBaseURI creates an instance of the LinkedServerClient client. +func NewLinkedServerClientWithBaseURI(baseURI string, subscriptionID string) LinkedServerClient { + return LinkedServerClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create adds a linked server to the Redis cache (requires Premium SKU). +// +// resourceGroupName is the name of the resource group. name is the name of the Redis cache. linkedServerName is +// the name of the linked server that is being added to the Redis cache. parameters is parameters supplied to the +// Create Linked server operation. +func (client LinkedServerClient) Create(ctx context.Context, resourceGroupName string, name string, linkedServerName string, parameters LinkedServerCreateParameters) (result LinkedServerCreateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LinkedServerCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LinkedServerCreateProperties.LinkedRedisCacheID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LinkedServerCreateProperties.LinkedRedisCacheLocation", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("redis.LinkedServerClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, name, linkedServerName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client LinkedServerClient) CreatePreparer(ctx context.Context, resourceGroupName string, name string, linkedServerName string, parameters LinkedServerCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "linkedServerName": autorest.Encode("path", linkedServerName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/linkedServers/{linkedServerName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedServerClient) CreateSender(req *http.Request) (future LinkedServerCreateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated)) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client LinkedServerClient) CreateResponder(resp *http.Response) (result LinkedServerWithProperties, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the linked server from a redis cache (requires Premium SKU). +// +// resourceGroupName is the name of the resource group. name is the name of the redis cache. linkedServerName is +// the name of the linked server that is being added to the Redis cache. +func (client LinkedServerClient) Delete(ctx context.Context, resourceGroupName string, name string, linkedServerName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, name, linkedServerName) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LinkedServerClient) DeletePreparer(ctx context.Context, resourceGroupName string, name string, linkedServerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "linkedServerName": autorest.Encode("path", linkedServerName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/linkedServers/{linkedServerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedServerClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LinkedServerClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the detailed information about a linked server of a redis cache (requires Premium SKU). +// +// resourceGroupName is the name of the resource group. name is the name of the redis cache. linkedServerName is +// the name of the linked server. +func (client LinkedServerClient) Get(ctx context.Context, resourceGroupName string, name string, linkedServerName string) (result LinkedServerWithProperties, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, name, linkedServerName) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LinkedServerClient) GetPreparer(ctx context.Context, resourceGroupName string, name string, linkedServerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "linkedServerName": autorest.Encode("path", linkedServerName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/linkedServers/{linkedServerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedServerClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LinkedServerClient) GetResponder(resp *http.Response) (result LinkedServerWithProperties, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the list of linked servers associated with this redis cache (requires Premium SKU). +// +// resourceGroupName is the name of the resource group. name is the name of the redis cache. +func (client LinkedServerClient) List(ctx context.Context, resourceGroupName string, name string) (result LinkedServerWithPropertiesListPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.lswpl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "List", resp, "Failure sending request") + return + } + + result.lswpl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LinkedServerClient) ListPreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/linkedServers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedServerClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LinkedServerClient) ListResponder(resp *http.Response) (result LinkedServerWithPropertiesList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client LinkedServerClient) listNextResults(lastResults LinkedServerWithPropertiesList) (result LinkedServerWithPropertiesList, err error) { + req, err := lastResults.linkedServerWithPropertiesListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "redis.LinkedServerClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redis.LinkedServerClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client LinkedServerClient) ListComplete(ctx context.Context, resourceGroupName string, name string) (result LinkedServerWithPropertiesListIterator, err error) { + result.page, err = client.List(ctx, resourceGroupName, name) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/models.go similarity index 67% rename from vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/models.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/models.go index 93b95e33918b..2b36a2bd83da 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/models.go @@ -21,6 +21,7 @@ import ( "encoding/json" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "net/http" ) @@ -69,6 +70,41 @@ func PossibleKeyTypeValues() []KeyType { return []KeyType{Primary, Secondary} } +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Disabled ... + Disabled ProvisioningState = "Disabled" + // Failed ... + Failed ProvisioningState = "Failed" + // Linking ... + Linking ProvisioningState = "Linking" + // Provisioning ... + Provisioning ProvisioningState = "Provisioning" + // RecoveringScaleFailure ... + RecoveringScaleFailure ProvisioningState = "RecoveringScaleFailure" + // Scaling ... + Scaling ProvisioningState = "Scaling" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Unlinking ... + Unlinking ProvisioningState = "Unlinking" + // Unprovisioning ... + Unprovisioning ProvisioningState = "Unprovisioning" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Creating, Deleting, Disabled, Failed, Linking, Provisioning, RecoveringScaleFailure, Scaling, Succeeded, Unlinking, Unprovisioning, Updating} +} + // RebootType enumerates the values for reboot type. type RebootType string @@ -86,6 +122,21 @@ func PossibleRebootTypeValues() []RebootType { return []RebootType{AllNodes, PrimaryNode, SecondaryNode} } +// ReplicationRole enumerates the values for replication role. +type ReplicationRole string + +const ( + // ReplicationRolePrimary ... + ReplicationRolePrimary ReplicationRole = "Primary" + // ReplicationRoleSecondary ... + ReplicationRoleSecondary ReplicationRole = "Secondary" +) + +// PossibleReplicationRoleValues returns an array of possible values for the ReplicationRole const type. +func PossibleReplicationRoleValues() []ReplicationRole { + return []ReplicationRole{ReplicationRolePrimary, ReplicationRoleSecondary} +} + // SkuFamily enumerates the values for sku family. type SkuFamily string @@ -118,6 +169,23 @@ func PossibleSkuNameValues() []SkuName { return []SkuName{Basic, Premium, Standard} } +// TLSVersion enumerates the values for tls version. +type TLSVersion string + +const ( + // OneFullStopOne ... + OneFullStopOne TLSVersion = "1.1" + // OneFullStopTwo ... + OneFullStopTwo TLSVersion = "1.2" + // OneFullStopZero ... + OneFullStopZero TLSVersion = "1.0" +) + +// PossibleTLSVersionValues returns an array of possible values for the TLSVersion const type. +func PossibleTLSVersionValues() []TLSVersion { + return []TLSVersion{OneFullStopOne, OneFullStopTwo, OneFullStopZero} +} + // AccessKeys redis cache access keys. type AccessKeys struct { autorest.Response `json:"-"` @@ -127,6 +195,49 @@ type AccessKeys struct { SecondaryKey *string `json:"secondaryKey,omitempty"` } +// CheckNameAvailabilityParameters parameters body to pass for name availability check. +type CheckNameAvailabilityParameters struct { + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// CommonProperties create/Update/Get common properties of the redis cache. +type CommonProperties struct { + // RedisConfiguration - All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value etc. + RedisConfiguration map[string]*string `json:"redisConfiguration"` + // EnableNonSslPort - Specifies whether the non-ssl Redis server port (6379) is enabled. + EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"` + // TenantSettings - A dictionary of tenant settings + TenantSettings map[string]*string `json:"tenantSettings"` + // ShardCount - The number of shards to be created on a Premium Cluster Cache. + ShardCount *int32 `json:"shardCount,omitempty"` + // MinimumTLSVersion - Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2'). Possible values include: 'OneFullStopZero', 'OneFullStopOne', 'OneFullStopTwo' + MinimumTLSVersion TLSVersion `json:"minimumTlsVersion,omitempty"` +} + +// MarshalJSON is the custom marshaler for CommonProperties. +func (cp CommonProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.RedisConfiguration != nil { + objectMap["redisConfiguration"] = cp.RedisConfiguration + } + if cp.EnableNonSslPort != nil { + objectMap["enableNonSslPort"] = cp.EnableNonSslPort + } + if cp.TenantSettings != nil { + objectMap["tenantSettings"] = cp.TenantSettings + } + if cp.ShardCount != nil { + objectMap["shardCount"] = cp.ShardCount + } + if cp.MinimumTLSVersion != "" { + objectMap["minimumTlsVersion"] = cp.MinimumTLSVersion + } + return json.Marshal(objectMap) +} + // CreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. type CreateFuture struct { azure.Future @@ -179,13 +290,9 @@ func (future CreateFuture) Result(client Client) (rt ResourceType, err error) { type CreateParameters struct { // CreateProperties - Redis cache properties. *CreateProperties `json:"properties,omitempty"` - // ID - Resource ID. - ID *string `json:"id,omitempty"` - // Name - Resource name. - Name *string `json:"name,omitempty"` - // Type - Resource type. - Type *string `json:"type,omitempty"` - // Location - Resource location. + // Zones - A list of availability zones denoting where the resource needs to come from. + Zones *[]string `json:"zones,omitempty"` + // Location - The geo-location where the resource lives Location *string `json:"location,omitempty"` // Tags - Resource tags. Tags map[string]*string `json:"tags"` @@ -197,14 +304,8 @@ func (cp CreateParameters) MarshalJSON() ([]byte, error) { if cp.CreateProperties != nil { objectMap["properties"] = cp.CreateProperties } - if cp.ID != nil { - objectMap["id"] = cp.ID - } - if cp.Name != nil { - objectMap["name"] = cp.Name - } - if cp.Type != nil { - objectMap["type"] = cp.Type + if cp.Zones != nil { + objectMap["zones"] = cp.Zones } if cp.Location != nil { objectMap["location"] = cp.Location @@ -233,32 +334,14 @@ func (cp *CreateParameters) UnmarshalJSON(body []byte) error { } cp.CreateProperties = &createProperties } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - cp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - cp.Name = &name - } - case "type": + case "zones": if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) + var zones []string + err = json.Unmarshal(*v, &zones) if err != nil { return err } - cp.Type = &typeVar + cp.Zones = &zones } case "location": if v != nil { @@ -288,18 +371,20 @@ func (cp *CreateParameters) UnmarshalJSON(body []byte) error { type CreateProperties struct { // Sku - The SKU of the Redis cache to deploy. Sku *Sku `json:"sku,omitempty"` + // SubnetID - The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 + SubnetID *string `json:"subnetId,omitempty"` + // StaticIP - Static IP address. Required when deploying a Redis cache inside an existing Azure Virtual Network. + StaticIP *string `json:"staticIP,omitempty"` // RedisConfiguration - All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value etc. RedisConfiguration map[string]*string `json:"redisConfiguration"` // EnableNonSslPort - Specifies whether the non-ssl Redis server port (6379) is enabled. EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"` - // TenantSettings - tenantSettings + // TenantSettings - A dictionary of tenant settings TenantSettings map[string]*string `json:"tenantSettings"` // ShardCount - The number of shards to be created on a Premium Cluster Cache. ShardCount *int32 `json:"shardCount,omitempty"` - // SubnetID - The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 - SubnetID *string `json:"subnetId,omitempty"` - // StaticIP - Static IP address. Required when deploying a Redis cache inside an existing Azure Virtual Network. - StaticIP *string `json:"staticIP,omitempty"` + // MinimumTLSVersion - Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2'). Possible values include: 'OneFullStopZero', 'OneFullStopOne', 'OneFullStopTwo' + MinimumTLSVersion TLSVersion `json:"minimumTlsVersion,omitempty"` } // MarshalJSON is the custom marshaler for CreateProperties. @@ -308,6 +393,12 @@ func (cp CreateProperties) MarshalJSON() ([]byte, error) { if cp.Sku != nil { objectMap["sku"] = cp.Sku } + if cp.SubnetID != nil { + objectMap["subnetId"] = cp.SubnetID + } + if cp.StaticIP != nil { + objectMap["staticIP"] = cp.StaticIP + } if cp.RedisConfiguration != nil { objectMap["redisConfiguration"] = cp.RedisConfiguration } @@ -320,11 +411,8 @@ func (cp CreateProperties) MarshalJSON() ([]byte, error) { if cp.ShardCount != nil { objectMap["shardCount"] = cp.ShardCount } - if cp.SubnetID != nil { - objectMap["subnetId"] = cp.SubnetID - } - if cp.StaticIP != nil { - objectMap["staticIP"] = cp.StaticIP + if cp.MinimumTLSVersion != "" { + objectMap["minimumTlsVersion"] = cp.MinimumTLSVersion } return json.Marshal(objectMap) } @@ -439,19 +527,22 @@ type ExportRDBParameters struct { // permitted to connect type FirewallRule struct { autorest.Response `json:"-"` - // ID - resource ID (of the firewall rule) + // FirewallRuleProperties - redis cache firewall rule properties + *FirewallRuleProperties `json:"properties,omitempty"` + // ID - Resource ID. ID *string `json:"id,omitempty"` - // Name - name of the firewall rule + // Name - Resource name. Name *string `json:"name,omitempty"` - // Type - type (of the firewall rule resource = 'Microsoft.Cache/redis/firewallRule') + // Type - Resource type. Type *string `json:"type,omitempty"` - // FirewallRuleProperties - redis cache firewall rule properties - *FirewallRuleProperties `json:"properties,omitempty"` } // MarshalJSON is the custom marshaler for FirewallRule. func (fr FirewallRule) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } if fr.ID != nil { objectMap["id"] = fr.ID } @@ -461,9 +552,6 @@ func (fr FirewallRule) MarshalJSON() ([]byte, error) { if fr.Type != nil { objectMap["type"] = fr.Type } - if fr.FirewallRuleProperties != nil { - objectMap["properties"] = fr.FirewallRuleProperties - } return json.Marshal(objectMap) } @@ -476,6 +564,15 @@ func (fr *FirewallRule) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { + case "properties": + if v != nil { + var firewallRuleProperties FirewallRuleProperties + err = json.Unmarshal(*v, &firewallRuleProperties) + if err != nil { + return err + } + fr.FirewallRuleProperties = &firewallRuleProperties + } case "id": if v != nil { var ID string @@ -503,6 +600,36 @@ func (fr *FirewallRule) UnmarshalJSON(body []byte) error { } fr.Type = &typeVar } + } + } + + return nil +} + +// FirewallRuleCreateParameters parameters required for creating a firewall rule on redis cache. +type FirewallRuleCreateParameters struct { + // FirewallRuleProperties - Properties required to create a firewall rule . + *FirewallRuleProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for FirewallRuleCreateParameters. +func (frcp FirewallRuleCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if frcp.FirewallRuleProperties != nil { + objectMap["properties"] = frcp.FirewallRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRuleCreateParameters struct. +func (frcp *FirewallRuleCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { case "properties": if v != nil { var firewallRuleProperties FirewallRuleProperties @@ -510,7 +637,7 @@ func (fr *FirewallRule) UnmarshalJSON(body []byte) error { if err != nil { return err } - fr.FirewallRuleProperties = &firewallRuleProperties + frcp.FirewallRuleProperties = &firewallRuleProperties } } } @@ -632,7 +759,7 @@ type FirewallRuleProperties struct { type ForceRebootResponse struct { autorest.Response `json:"-"` // Message - Status message - Message *string `json:"Message,omitempty"` + Message *string `json:"message,omitempty"` } // ImportDataFuture an abstraction for monitoring and retrieving the results of a long-running operation. @@ -691,98 +818,398 @@ type ImportRDBParameters struct { Files *[]string `json:"files,omitempty"` } -// ListResult the response of list Redis operation. -type ListResult struct { - autorest.Response `json:"-"` - // Value - List of Redis cache instances. - Value *[]ResourceType `json:"value,omitempty"` - // NextLink - Link for next set of locations. - NextLink *string `json:"nextLink,omitempty"` +// LinkedServer linked server Id +type LinkedServer struct { + // ID - Linked server Id. + ID *string `json:"id,omitempty"` } -// ListResultIterator provides access to a complete listing of ResourceType values. -type ListResultIterator struct { - i int - page ListResultPage +// LinkedServerCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type LinkedServerCreateFuture struct { + azure.Future + req *http.Request } -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ListResultIterator) Next() error { - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future LinkedServerCreateFuture) Result(client LinkedServerClient) (lswp LinkedServerWithProperties, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerCreateFuture", "Result", future.Response(), "Polling failure") + return } - err := iter.page.Next() + if !done { + return lswp, azure.NewAsyncOpIncompleteError("redis.LinkedServerCreateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + lswp, err = client.CreateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerCreateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { - iter.i-- - return err + err = autorest.NewErrorWithError(err, "redis.LinkedServerCreateFuture", "Result", resp, "Failure sending request") + return } - iter.i = 0 - return nil -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ListResultIterator) Response() ListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ListResultIterator) Value() ResourceType { - if !iter.page.NotDone() { - return ResourceType{} + lswp, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.LinkedServerCreateFuture", "Result", resp, "Failure responding to request") } - return iter.page.Values()[iter.i] + return } -// IsEmpty returns true if the ListResult contains no values. -func (lr ListResult) IsEmpty() bool { - return lr.Value == nil || len(*lr.Value) == 0 +// LinkedServerCreateParameters parameter required for creating a linked server to redis cache. +type LinkedServerCreateParameters struct { + // LinkedServerCreateProperties - Properties required to create a linked server. + *LinkedServerCreateProperties `json:"properties,omitempty"` } -// listResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (lr ListResult) listResultPreparer() (*http.Request, error) { - if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 { - return nil, nil +// MarshalJSON is the custom marshaler for LinkedServerCreateParameters. +func (lscp LinkedServerCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lscp.LinkedServerCreateProperties != nil { + objectMap["properties"] = lscp.LinkedServerCreateProperties } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(lr.NextLink))) -} - -// ListResultPage contains a page of ResourceType values. -type ListResultPage struct { - fn func(ListResult) (ListResult, error) - lr ListResult + return json.Marshal(objectMap) } -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ListResultPage) Next() error { - next, err := page.fn(page.lr) +// UnmarshalJSON is the custom unmarshaler for LinkedServerCreateParameters struct. +func (lscp *LinkedServerCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) if err != nil { return err } - page.lr = next + for k, v := range m { + switch k { + case "properties": + if v != nil { + var linkedServerCreateProperties LinkedServerCreateProperties + err = json.Unmarshal(*v, &linkedServerCreateProperties) + if err != nil { + return err + } + lscp.LinkedServerCreateProperties = &linkedServerCreateProperties + } + } + } + return nil } -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ListResultPage) NotDone() bool { - return !page.lr.IsEmpty() +// LinkedServerCreateProperties create properties for a linked server +type LinkedServerCreateProperties struct { + // LinkedRedisCacheID - Fully qualified resourceId of the linked redis cache. + LinkedRedisCacheID *string `json:"linkedRedisCacheId,omitempty"` + // LinkedRedisCacheLocation - Location of the linked redis cache. + LinkedRedisCacheLocation *string `json:"linkedRedisCacheLocation,omitempty"` + // ServerRole - Role of the linked server. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary' + ServerRole ReplicationRole `json:"serverRole,omitempty"` } -// Response returns the raw server response from the last page request. -func (page ListResultPage) Response() ListResult { - return page.lr +// LinkedServerProperties properties of a linked server to be returned in get/put response +type LinkedServerProperties struct { + // ProvisioningState - Terminal state of the link between primary and secondary redis cache. + ProvisioningState *string `json:"provisioningState,omitempty"` + // LinkedRedisCacheID - Fully qualified resourceId of the linked redis cache. + LinkedRedisCacheID *string `json:"linkedRedisCacheId,omitempty"` + // LinkedRedisCacheLocation - Location of the linked redis cache. + LinkedRedisCacheLocation *string `json:"linkedRedisCacheLocation,omitempty"` + // ServerRole - Role of the linked server. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary' + ServerRole ReplicationRole `json:"serverRole,omitempty"` +} + +// LinkedServerWithProperties response to put/get linked server (with properties) for Redis cache. +type LinkedServerWithProperties struct { + autorest.Response `json:"-"` + // LinkedServerProperties - Properties of the linked server. + *LinkedServerProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LinkedServerWithProperties. +func (lswp LinkedServerWithProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lswp.LinkedServerProperties != nil { + objectMap["properties"] = lswp.LinkedServerProperties + } + if lswp.ID != nil { + objectMap["id"] = lswp.ID + } + if lswp.Name != nil { + objectMap["name"] = lswp.Name + } + if lswp.Type != nil { + objectMap["type"] = lswp.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LinkedServerWithProperties struct. +func (lswp *LinkedServerWithProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var linkedServerProperties LinkedServerProperties + err = json.Unmarshal(*v, &linkedServerProperties) + if err != nil { + return err + } + lswp.LinkedServerProperties = &linkedServerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + lswp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + lswp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + lswp.Type = &typeVar + } + } + } + + return nil +} + +// LinkedServerWithPropertiesList list of linked servers (with properites) of a Redis cache. +type LinkedServerWithPropertiesList struct { + autorest.Response `json:"-"` + // Value - List of linked servers (with properites) of a Redis cache. + Value *[]LinkedServerWithProperties `json:"value,omitempty"` + // NextLink - Link for next set. + NextLink *string `json:"nextLink,omitempty"` +} + +// LinkedServerWithPropertiesListIterator provides access to a complete listing of LinkedServerWithProperties +// values. +type LinkedServerWithPropertiesListIterator struct { + i int + page LinkedServerWithPropertiesListPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *LinkedServerWithPropertiesListIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LinkedServerWithPropertiesListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter LinkedServerWithPropertiesListIterator) Response() LinkedServerWithPropertiesList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter LinkedServerWithPropertiesListIterator) Value() LinkedServerWithProperties { + if !iter.page.NotDone() { + return LinkedServerWithProperties{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (lswpl LinkedServerWithPropertiesList) IsEmpty() bool { + return lswpl.Value == nil || len(*lswpl.Value) == 0 +} + +// linkedServerWithPropertiesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lswpl LinkedServerWithPropertiesList) linkedServerWithPropertiesListPreparer() (*http.Request, error) { + if lswpl.NextLink == nil || len(to.String(lswpl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lswpl.NextLink))) +} + +// LinkedServerWithPropertiesListPage contains a page of LinkedServerWithProperties values. +type LinkedServerWithPropertiesListPage struct { + fn func(LinkedServerWithPropertiesList) (LinkedServerWithPropertiesList, error) + lswpl LinkedServerWithPropertiesList +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *LinkedServerWithPropertiesListPage) Next() error { + next, err := page.fn(page.lswpl) + if err != nil { + return err + } + page.lswpl = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LinkedServerWithPropertiesListPage) NotDone() bool { + return !page.lswpl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LinkedServerWithPropertiesListPage) Response() LinkedServerWithPropertiesList { + return page.lswpl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LinkedServerWithPropertiesListPage) Values() []LinkedServerWithProperties { + if page.lswpl.IsEmpty() { + return nil + } + return *page.lswpl.Value +} + +// ListResult the response of list Redis operation. +type ListResult struct { + autorest.Response `json:"-"` + // Value - List of Redis cache instances. + Value *[]ResourceType `json:"value,omitempty"` + // NextLink - Link for next set of locations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ListResultIterator provides access to a complete listing of ResourceType values. +type ListResultIterator struct { + i int + page ListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ListResultIterator) Response() ListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ListResultIterator) Value() ResourceType { + if !iter.page.NotDone() { + return ResourceType{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (lr ListResult) IsEmpty() bool { + return lr.Value == nil || len(*lr.Value) == 0 +} + +// listResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lr ListResult) listResultPreparer() (*http.Request, error) { + if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lr.NextLink))) +} + +// ListResultPage contains a page of ResourceType values. +type ListResultPage struct { + fn func(ListResult) (ListResult, error) + lr ListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ListResultPage) Next() error { + next, err := page.fn(page.lr) + if err != nil { + return err + } + page.lr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ListResultPage) NotDone() bool { + return !page.lr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ListResultPage) Response() ListResult { + return page.lr } // Values returns the slice of values for the current page or nil if there are no values. @@ -793,6 +1220,15 @@ func (page ListResultPage) Values() []ResourceType { return *page.lr.Value } +// NotificationListResponse the response of listUpgradeNotifications. +type NotificationListResponse struct { + autorest.Response `json:"-"` + // Value - List of all notifications. + Value *[]UpgradeNotification `json:"value,omitempty"` + // NextLink - Link for next set of notifications. + NextLink *string `json:"nextLink,omitempty"` +} + // Operation REST API operation type Operation struct { // Name - Operation name: {provider}/{resource}/{operation} @@ -919,21 +1355,22 @@ func (page OperationListResultPage) Values() []Operation { // PatchSchedule response to put/get patch schedules for Redis cache. type PatchSchedule struct { autorest.Response `json:"-"` + // ScheduleEntries - List of patch schedules for a Redis cache. + *ScheduleEntries `json:"properties,omitempty"` // ID - Resource ID. ID *string `json:"id,omitempty"` // Name - Resource name. Name *string `json:"name,omitempty"` // Type - Resource type. Type *string `json:"type,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // ScheduleEntries - List of patch schedules for a Redis cache. - *ScheduleEntries `json:"properties,omitempty"` } // MarshalJSON is the custom marshaler for PatchSchedule. func (ps PatchSchedule) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if ps.ScheduleEntries != nil { + objectMap["properties"] = ps.ScheduleEntries + } if ps.ID != nil { objectMap["id"] = ps.ID } @@ -943,12 +1380,6 @@ func (ps PatchSchedule) MarshalJSON() ([]byte, error) { if ps.Type != nil { objectMap["type"] = ps.Type } - if ps.Location != nil { - objectMap["location"] = ps.Location - } - if ps.ScheduleEntries != nil { - objectMap["properties"] = ps.ScheduleEntries - } return json.Marshal(objectMap) } @@ -961,6 +1392,15 @@ func (ps *PatchSchedule) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { + case "properties": + if v != nil { + var scheduleEntries ScheduleEntries + err = json.Unmarshal(*v, &scheduleEntries) + if err != nil { + return err + } + ps.ScheduleEntries = &scheduleEntries + } case "id": if v != nil { var ID string @@ -988,49 +1428,79 @@ func (ps *PatchSchedule) UnmarshalJSON(body []byte) error { } ps.Type = &typeVar } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ps.Location = &location - } - case "properties": - if v != nil { - var scheduleEntries ScheduleEntries - err = json.Unmarshal(*v, &scheduleEntries) - if err != nil { - return err - } - ps.ScheduleEntries = &scheduleEntries - } } } return nil } -// Properties properties supplied to Create or Update Redis operation. +// Properties properties of the redis cache. type Properties struct { + // RedisVersion - Redis version. + RedisVersion *string `json:"redisVersion,omitempty"` + // ProvisioningState - Redis instance provisioning status. Possible values include: 'Creating', 'Deleting', 'Disabled', 'Failed', 'Linking', 'Provisioning', 'RecoveringScaleFailure', 'Scaling', 'Succeeded', 'Unlinking', 'Unprovisioning', 'Updating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // HostName - Redis host name. + HostName *string `json:"hostName,omitempty"` + // Port - Redis non-SSL port. + Port *int32 `json:"port,omitempty"` + // SslPort - Redis SSL port. + SslPort *int32 `json:"sslPort,omitempty"` + // AccessKeys - The keys of the Redis cache - not set if this object is not the response to Create or Update redis cache + AccessKeys *AccessKeys `json:"accessKeys,omitempty"` + // LinkedServers - List of the linked servers associated with the cache + LinkedServers *[]LinkedServer `json:"linkedServers,omitempty"` + // Sku - The SKU of the Redis cache to deploy. + Sku *Sku `json:"sku,omitempty"` + // SubnetID - The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 + SubnetID *string `json:"subnetId,omitempty"` + // StaticIP - Static IP address. Required when deploying a Redis cache inside an existing Azure Virtual Network. + StaticIP *string `json:"staticIP,omitempty"` // RedisConfiguration - All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value etc. RedisConfiguration map[string]*string `json:"redisConfiguration"` // EnableNonSslPort - Specifies whether the non-ssl Redis server port (6379) is enabled. EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"` - // TenantSettings - tenantSettings + // TenantSettings - A dictionary of tenant settings TenantSettings map[string]*string `json:"tenantSettings"` // ShardCount - The number of shards to be created on a Premium Cluster Cache. ShardCount *int32 `json:"shardCount,omitempty"` - // SubnetID - The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 - SubnetID *string `json:"subnetId,omitempty"` - // StaticIP - Static IP address. Required when deploying a Redis cache inside an existing Azure Virtual Network. - StaticIP *string `json:"staticIP,omitempty"` + // MinimumTLSVersion - Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2'). Possible values include: 'OneFullStopZero', 'OneFullStopOne', 'OneFullStopTwo' + MinimumTLSVersion TLSVersion `json:"minimumTlsVersion,omitempty"` } // MarshalJSON is the custom marshaler for Properties. func (p Properties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if p.RedisVersion != nil { + objectMap["redisVersion"] = p.RedisVersion + } + if p.ProvisioningState != "" { + objectMap["provisioningState"] = p.ProvisioningState + } + if p.HostName != nil { + objectMap["hostName"] = p.HostName + } + if p.Port != nil { + objectMap["port"] = p.Port + } + if p.SslPort != nil { + objectMap["sslPort"] = p.SslPort + } + if p.AccessKeys != nil { + objectMap["accessKeys"] = p.AccessKeys + } + if p.LinkedServers != nil { + objectMap["linkedServers"] = p.LinkedServers + } + if p.Sku != nil { + objectMap["sku"] = p.Sku + } + if p.SubnetID != nil { + objectMap["subnetId"] = p.SubnetID + } + if p.StaticIP != nil { + objectMap["staticIP"] = p.StaticIP + } if p.RedisConfiguration != nil { objectMap["redisConfiguration"] = p.RedisConfiguration } @@ -1043,15 +1513,23 @@ func (p Properties) MarshalJSON() ([]byte, error) { if p.ShardCount != nil { objectMap["shardCount"] = p.ShardCount } - if p.SubnetID != nil { - objectMap["subnetId"] = p.SubnetID - } - if p.StaticIP != nil { - objectMap["staticIP"] = p.StaticIP + if p.MinimumTLSVersion != "" { + objectMap["minimumTlsVersion"] = p.MinimumTLSVersion } return json.Marshal(objectMap) } +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + // RebootParameters specifies which Redis node(s) to reboot. type RebootParameters struct { // RebootType - Which Redis node(s) to reboot. Depending on this value data loss is possible. Possible values include: 'PrimaryNode', 'SecondaryNode', 'AllNodes' @@ -1074,130 +1552,41 @@ type Resource struct { Name *string `json:"name,omitempty"` // Type - Resource type. Type *string `json:"type,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.ID != nil { - objectMap["id"] = r.ID - } - if r.Name != nil { - objectMap["name"] = r.Name - } - if r.Type != nil { - objectMap["type"] = r.Type - } - if r.Location != nil { - objectMap["location"] = r.Location - } - if r.Tags != nil { - objectMap["tags"] = r.Tags - } - return json.Marshal(objectMap) -} - -// ResourceProperties parameters describing a Redis instance. -type ResourceProperties struct { - // Sku - The SKU of the Redis cache to deploy. - Sku *Sku `json:"sku,omitempty"` - // RedisVersion - Redis version. - RedisVersion *string `json:"redisVersion,omitempty"` - // ProvisioningState - Redis instance provisioning status. - ProvisioningState *string `json:"provisioningState,omitempty"` - // HostName - Redis host name. - HostName *string `json:"hostName,omitempty"` - // Port - Redis non-SSL port. - Port *int32 `json:"port,omitempty"` - // SslPort - Redis SSL port. - SslPort *int32 `json:"sslPort,omitempty"` - // AccessKeys - The keys of the Redis cache - not set if this object is not the response to Create or Update redis cache - AccessKeys *AccessKeys `json:"accessKeys,omitempty"` - // RedisConfiguration - All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value etc. - RedisConfiguration map[string]*string `json:"redisConfiguration"` - // EnableNonSslPort - Specifies whether the non-ssl Redis server port (6379) is enabled. - EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"` - // TenantSettings - tenantSettings - TenantSettings map[string]*string `json:"tenantSettings"` - // ShardCount - The number of shards to be created on a Premium Cluster Cache. - ShardCount *int32 `json:"shardCount,omitempty"` - // SubnetID - The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 - SubnetID *string `json:"subnetId,omitempty"` - // StaticIP - Static IP address. Required when deploying a Redis cache inside an existing Azure Virtual Network. - StaticIP *string `json:"staticIP,omitempty"` -} - -// MarshalJSON is the custom marshaler for ResourceProperties. -func (rp ResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rp.Sku != nil { - objectMap["sku"] = rp.Sku - } - if rp.RedisVersion != nil { - objectMap["redisVersion"] = rp.RedisVersion - } - if rp.ProvisioningState != nil { - objectMap["provisioningState"] = rp.ProvisioningState - } - if rp.HostName != nil { - objectMap["hostName"] = rp.HostName - } - if rp.Port != nil { - objectMap["port"] = rp.Port - } - if rp.SslPort != nil { - objectMap["sslPort"] = rp.SslPort - } - if rp.AccessKeys != nil { - objectMap["accessKeys"] = rp.AccessKeys - } - if rp.RedisConfiguration != nil { - objectMap["redisConfiguration"] = rp.RedisConfiguration - } - if rp.EnableNonSslPort != nil { - objectMap["enableNonSslPort"] = rp.EnableNonSslPort - } - if rp.TenantSettings != nil { - objectMap["tenantSettings"] = rp.TenantSettings - } - if rp.ShardCount != nil { - objectMap["shardCount"] = rp.ShardCount - } - if rp.SubnetID != nil { - objectMap["subnetId"] = rp.SubnetID - } - if rp.StaticIP != nil { - objectMap["staticIP"] = rp.StaticIP - } - return json.Marshal(objectMap) } // ResourceType a single Redis item in List or Get Operation. type ResourceType struct { autorest.Response `json:"-"` - // ResourceProperties - Redis cache properties. - *ResourceProperties `json:"properties,omitempty"` + // Properties - Redis cache properties. + *Properties `json:"properties,omitempty"` + // Zones - A list of availability zones denoting where the resource needs to come from. + Zones *[]string `json:"zones,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` // ID - Resource ID. ID *string `json:"id,omitempty"` // Name - Resource name. Name *string `json:"name,omitempty"` // Type - Resource type. Type *string `json:"type,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` } // MarshalJSON is the custom marshaler for ResourceType. func (rt ResourceType) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if rt.ResourceProperties != nil { - objectMap["properties"] = rt.ResourceProperties + if rt.Properties != nil { + objectMap["properties"] = rt.Properties + } + if rt.Zones != nil { + objectMap["zones"] = rt.Zones + } + if rt.Tags != nil { + objectMap["tags"] = rt.Tags + } + if rt.Location != nil { + objectMap["location"] = rt.Location } if rt.ID != nil { objectMap["id"] = rt.ID @@ -1208,12 +1597,6 @@ func (rt ResourceType) MarshalJSON() ([]byte, error) { if rt.Type != nil { objectMap["type"] = rt.Type } - if rt.Location != nil { - objectMap["location"] = rt.Location - } - if rt.Tags != nil { - objectMap["tags"] = rt.Tags - } return json.Marshal(objectMap) } @@ -1228,12 +1611,39 @@ func (rt *ResourceType) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var resourceProperties ResourceProperties - err = json.Unmarshal(*v, &resourceProperties) + var properties Properties + err = json.Unmarshal(*v, &properties) if err != nil { return err } - rt.ResourceProperties = &resourceProperties + rt.Properties = &properties + } + case "zones": + if v != nil { + var zones []string + err = json.Unmarshal(*v, &zones) + if err != nil { + return err + } + rt.Zones = &zones + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rt.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rt.Location = &location } case "id": if v != nil { @@ -1262,24 +1672,6 @@ func (rt *ResourceType) UnmarshalJSON(body []byte) error { } rt.Type = &typeVar } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - rt.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - rt.Tags = tags - } } } @@ -1312,6 +1704,41 @@ type Sku struct { Capacity *int32 `json:"capacity,omitempty"` } +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.ID != nil { + objectMap["id"] = tr.ID + } + if tr.Name != nil { + objectMap["name"] = tr.Name + } + if tr.Type != nil { + objectMap["type"] = tr.Type + } + return json.Marshal(objectMap) +} + // UpdateParameters parameters supplied to the Update Redis operation. type UpdateParameters struct { // UpdateProperties - Redis cache properties. @@ -1365,7 +1792,7 @@ func (up *UpdateParameters) UnmarshalJSON(body []byte) error { return nil } -// UpdateProperties properties supplied to Update Redis operation. +// UpdateProperties patchable properties of the redis cache. type UpdateProperties struct { // Sku - The SKU of the Redis cache to deploy. Sku *Sku `json:"sku,omitempty"` @@ -1373,14 +1800,12 @@ type UpdateProperties struct { RedisConfiguration map[string]*string `json:"redisConfiguration"` // EnableNonSslPort - Specifies whether the non-ssl Redis server port (6379) is enabled. EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"` - // TenantSettings - tenantSettings + // TenantSettings - A dictionary of tenant settings TenantSettings map[string]*string `json:"tenantSettings"` // ShardCount - The number of shards to be created on a Premium Cluster Cache. ShardCount *int32 `json:"shardCount,omitempty"` - // SubnetID - The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 - SubnetID *string `json:"subnetId,omitempty"` - // StaticIP - Static IP address. Required when deploying a Redis cache inside an existing Azure Virtual Network. - StaticIP *string `json:"staticIP,omitempty"` + // MinimumTLSVersion - Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2'). Possible values include: 'OneFullStopZero', 'OneFullStopOne', 'OneFullStopTwo' + MinimumTLSVersion TLSVersion `json:"minimumTlsVersion,omitempty"` } // MarshalJSON is the custom marshaler for UpdateProperties. @@ -1401,11 +1826,33 @@ func (up UpdateProperties) MarshalJSON() ([]byte, error) { if up.ShardCount != nil { objectMap["shardCount"] = up.ShardCount } - if up.SubnetID != nil { - objectMap["subnetId"] = up.SubnetID + if up.MinimumTLSVersion != "" { + objectMap["minimumTlsVersion"] = up.MinimumTLSVersion + } + return json.Marshal(objectMap) +} + +// UpgradeNotification properties of upgrade notification. +type UpgradeNotification struct { + // Name - Name of upgrade notification. + Name *string `json:"name,omitempty"` + // Timestamp - Timestamp when upgrade notification occured. + Timestamp *date.Time `json:"timestamp,omitempty"` + // UpsellNotification - Details about this upgrade notification + UpsellNotification map[string]*string `json:"upsellNotification"` +} + +// MarshalJSON is the custom marshaler for UpgradeNotification. +func (un UpgradeNotification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if un.Name != nil { + objectMap["name"] = un.Name + } + if un.Timestamp != nil { + objectMap["timestamp"] = un.Timestamp } - if up.StaticIP != nil { - objectMap["staticIP"] = up.StaticIP + if un.UpsellNotification != nil { + objectMap["upsellNotification"] = un.UpsellNotification } return json.Marshal(objectMap) } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/operations.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/operations.go index b4b183ecbf5a..315e3d9d4a7f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/operations.go @@ -65,7 +65,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/patchschedules.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/patchschedules.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/patchschedules.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/patchschedules.go index ad1c62779dd9..f24c2b011669 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/patchschedules.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/patchschedules.go @@ -76,12 +76,13 @@ func (client PatchSchedulesClient) CreateOrUpdate(ctx context.Context, resourceG // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client PatchSchedulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, name string, parameters PatchSchedule) (*http.Request, error) { pathParameters := map[string]interface{}{ + "default": autorest.Encode("path", "default"), "name": autorest.Encode("path", name), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -90,7 +91,7 @@ func (client PatchSchedulesClient) CreateOrUpdatePreparer(ctx context.Context, r autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/default", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/{default}", pathParameters), autorest.WithJSON(parameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) @@ -144,12 +145,13 @@ func (client PatchSchedulesClient) Delete(ctx context.Context, resourceGroupName // DeletePreparer prepares the Delete request. func (client PatchSchedulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { pathParameters := map[string]interface{}{ + "default": autorest.Encode("path", "default"), "name": autorest.Encode("path", name), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -157,7 +159,7 @@ func (client PatchSchedulesClient) DeletePreparer(ctx context.Context, resourceG preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/default", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/{default}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -209,12 +211,13 @@ func (client PatchSchedulesClient) Get(ctx context.Context, resourceGroupName st // GetPreparer prepares the Get request. func (client PatchSchedulesClient) GetPreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { pathParameters := map[string]interface{}{ + "default": autorest.Encode("path", "default"), "name": autorest.Encode("path", name), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -222,7 +225,7 @@ func (client PatchSchedulesClient) GetPreparer(ctx context.Context, resourceGrou preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/default", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/{default}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/redis.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/redis.go similarity index 82% rename from vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/redis.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/redis.go index a4f61075d05d..888a76908d29 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/redis.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/redis.go @@ -40,6 +40,71 @@ func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { return Client{NewWithBaseURI(baseURI, subscriptionID)} } +// CheckNameAvailability checks that the redis cache name is valid and is not already in use. +// +// parameters is parameters supplied to the CheckNameAvailability Redis operation. +func (client Client) CheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityParameters) (result autorest.Response, err error) { + req, err := client.CheckNameAvailabilityPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.Client", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "redis.Client", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.Client", "CheckNameAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client Client) CheckNameAvailabilityPreparer(ctx context.Context, parameters CheckNameAvailabilityParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cache/CheckNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client Client) CheckNameAvailabilityResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + // Create create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. // // resourceGroupName is the name of the resource group. name is the name of the Redis cache. parameters is @@ -50,7 +115,12 @@ func (client Client) Create(ctx context.Context, resourceGroupName string, name Constraints: []validation.Constraint{{Target: "parameters.CreateProperties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.CreateProperties.Sku", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.CreateProperties.Sku.Capacity", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { + {Target: "parameters.CreateProperties.SubnetID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.CreateProperties.SubnetID", Name: validation.Pattern, Rule: `^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$`, Chain: nil}}}, + {Target: "parameters.CreateProperties.StaticIP", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.CreateProperties.StaticIP", Name: validation.Pattern, Rule: `^\d+\.\d+\.\d+\.\d+$`, Chain: nil}}}, + }}, + {Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewError("redis.Client", "Create", err.Error()) } @@ -77,7 +147,7 @@ func (client Client) CreatePreparer(ctx context.Context, resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -147,7 +217,7 @@ func (client Client) DeletePreparer(ctx context.Context, resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -171,7 +241,7 @@ func (client Client) DeleteSender(req *http.Request) (future DeleteFuture, err e return } err = autorest.Respond(future.Response(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent)) + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) return } @@ -181,7 +251,7 @@ func (client Client) DeleteResponder(resp *http.Response) (result autorest.Respo err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return @@ -222,7 +292,7 @@ func (client Client) ExportDataPreparer(ctx context.Context, resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -299,7 +369,7 @@ func (client Client) ForceRebootPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -367,7 +437,7 @@ func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -434,7 +504,7 @@ func (client Client) ImportDataPreparer(ctx context.Context, resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -506,7 +576,7 @@ func (client Client) ListPreparer(ctx context.Context) (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -514,7 +584,7 @@ func (client Client) ListPreparer(ctx context.Context) (*http.Request, error) { preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cache/Redis/", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cache/Redis", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -599,7 +669,7 @@ func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -607,7 +677,7 @@ func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGr preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -692,7 +762,7 @@ func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -725,6 +795,74 @@ func (client Client) ListKeysResponder(resp *http.Response) (result AccessKeys, return } +// ListUpgradeNotifications gets any upgrade notifications for a Redis cache. +// +// resourceGroupName is the name of the resource group. name is the name of the Redis cache. history is how many +// minutes in past to look for upgrade notifications +func (client Client) ListUpgradeNotifications(ctx context.Context, resourceGroupName string, name string, history float64) (result NotificationListResponse, err error) { + req, err := client.ListUpgradeNotificationsPreparer(ctx, resourceGroupName, name, history) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.Client", "ListUpgradeNotifications", nil, "Failure preparing request") + return + } + + resp, err := client.ListUpgradeNotificationsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.Client", "ListUpgradeNotifications", resp, "Failure sending request") + return + } + + result, err = client.ListUpgradeNotificationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.Client", "ListUpgradeNotifications", resp, "Failure responding to request") + } + + return +} + +// ListUpgradeNotificationsPreparer prepares the ListUpgradeNotifications request. +func (client Client) ListUpgradeNotificationsPreparer(ctx context.Context, resourceGroupName string, name string, history float64) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "history": autorest.Encode("query", history), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/listUpgradeNotifications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUpgradeNotificationsSender sends the ListUpgradeNotifications request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListUpgradeNotificationsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListUpgradeNotificationsResponder handles the response to the ListUpgradeNotifications request. The method always +// closes the http.Response Body. +func (client Client) ListUpgradeNotificationsResponder(resp *http.Response) (result NotificationListResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // RegenerateKey regenerate Redis cache's access keys. This operation requires write permission to the cache resource. // // resourceGroupName is the name of the resource group. name is the name of the Redis cache. parameters is @@ -759,7 +897,7 @@ func (client Client) RegenerateKeyPreparer(ctx context.Context, resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -828,7 +966,7 @@ func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-04-01" + const APIVersion = "2018-03-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/version.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/version.go index b4f0d2900201..2e62cd1b3f8f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " redis/2016-04-01" + return "Azure-SDK-For-Go/" + version.Number + " redis/2018-03-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/vendor.json b/vendor/vendor.json index 762786086086..67628030e451 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -179,8 +179,8 @@ "versionExact": "v15.0.1" }, { - "checksumSHA1": "0RWJdclCgo0gzJQVKXqcz6SxMkI=", - "path": "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis", + "checksumSHA1": "JNSBPrbVww7i2tKS02XHTRU9f6A=", + "path": "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis", "revision": "068ec4d616be5b2175509bf1fb3e4c8ea160d5c8", "revisionTime": "2018-04-05T22:23:54Z", "version": "v15.0.1", From c73020940fd78995e37e51b5a6215cd2619e89df Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 6 Apr 2018 14:14:26 +0200 Subject: [PATCH 3/6] SDK changes for the 2018 version --- azurerm/config.go | 6 +++--- azurerm/resource_arm_redis_cache.go | 2 +- azurerm/resource_arm_redis_firewall_rule.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/azurerm/config.go b/azurerm/config.go index 537bdda83b45..488cd7ecf9dc 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -32,7 +32,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights" "github.com/Azure/azure-sdk-for-go/services/operationsmanagement/mgmt/2015-11-01-preview/operationsmanagement" "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-04-30-preview/postgresql" - "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis" + "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-06-01/subscriptions" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-12-01/policy" @@ -89,7 +89,7 @@ type ArmClient struct { solutionsClient operationsmanagement.SolutionsClient redisClient redis.Client - redisFirewallClient redis.FirewallRuleClient + redisFirewallClient redis.FirewallRulesClient redisPatchSchedulesClient redis.PatchSchedulesClient // Application Insights @@ -791,7 +791,7 @@ func (c *ArmClient) registerRedisClients(endpoint, subscriptionId string, auth a c.configureClient(&redisClient.Client, auth) c.redisClient = redisClient - firewallRuleClient := redis.NewFirewallRuleClientWithBaseURI(endpoint, subscriptionId) + firewallRuleClient := redis.NewFirewallRulesClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&firewallRuleClient.Client, auth) c.redisFirewallClient = firewallRuleClient diff --git a/azurerm/resource_arm_redis_cache.go b/azurerm/resource_arm_redis_cache.go index 4611b453b679..e0f2e16a41c3 100644 --- a/azurerm/resource_arm_redis_cache.go +++ b/azurerm/resource_arm_redis_cache.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis" + "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" diff --git a/azurerm/resource_arm_redis_firewall_rule.go b/azurerm/resource_arm_redis_firewall_rule.go index cea6af78a65d..3f8ade993d99 100644 --- a/azurerm/resource_arm_redis_firewall_rule.go +++ b/azurerm/resource_arm_redis_firewall_rule.go @@ -6,7 +6,7 @@ import ( "regexp" - "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2016-04-01/redis" + "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis" "github.com/hashicorp/terraform/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) From d4ba49c4b7defe75c3c95ce420f1d7c8362cf6d2 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 6 Apr 2018 14:17:34 +0200 Subject: [PATCH 4/6] Code changes required for the 2018 API --- azurerm/resource_arm_redis_cache.go | 19 ++++--------------- azurerm/resource_arm_redis_firewall_rule.go | 3 +-- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/azurerm/resource_arm_redis_cache.go b/azurerm/resource_arm_redis_cache.go index e0f2e16a41c3..4fc3e041d0b4 100644 --- a/azurerm/resource_arm_redis_cache.go +++ b/azurerm/resource_arm_redis_cache.go @@ -77,12 +77,14 @@ func resourceArmRedisCache() *schema.Resource { "subnet_id": { Type: schema.TypeString, Optional: true, + ForceNew: true, }, "private_static_ip_address": { Type: schema.TypeString, Optional: true, Computed: true, + ForceNew: true, }, "redis_configuration": { @@ -222,7 +224,6 @@ func resourceArmRedisCacheCreate(d *schema.ResourceData, meta interface{}) error } parameters := redis.CreateParameters{ - Name: utils.String(name), Location: utils.String(location), CreateProperties: &redis.CreateProperties{ EnableNonSslPort: utils.Bool(enableNonSSLPort), @@ -328,18 +329,6 @@ func resourceArmRedisCacheUpdate(d *schema.ResourceData, meta interface{}) error } } - if v, ok := d.GetOk("private_static_ip_address"); ok { - if d.HasChange("private_static_ip_address") { - parameters.StaticIP = utils.String(v.(string)) - } - } - - if v, ok := d.GetOk("subnet_id"); ok { - if d.HasChange("subnet_id") { - parameters.SubnetID = utils.String(v.(string)) - } - } - if d.HasChange("redis_configuration") { redisConfiguration := expandRedisConfiguration(d) parameters.RedisConfiguration = redisConfiguration @@ -443,7 +432,7 @@ func resourceArmRedisCacheRead(d *schema.ResourceData, meta interface{}) error { d.Set("sku_name", sku.Name) } - if props := resp.ResourceProperties; props != nil { + if props := resp.Properties; props != nil { d.Set("ssl_port", props.SslPort) d.Set("hostname", props.HostName) d.Set("port", props.Port) @@ -504,7 +493,7 @@ func redisStateRefreshFunc(ctx context.Context, client redis.Client, resourceGro return nil, "", fmt.Errorf("Error issuing read request in redisStateRefreshFunc to Azure ARM for Redis Cache Instance '%s' (RG: '%s'): %s", sgName, resourceGroupName, err) } - return res, *res.ProvisioningState, nil + return res, string(res.ProvisioningState), nil } } diff --git a/azurerm/resource_arm_redis_firewall_rule.go b/azurerm/resource_arm_redis_firewall_rule.go index 3f8ade993d99..28071c872770 100644 --- a/azurerm/resource_arm_redis_firewall_rule.go +++ b/azurerm/resource_arm_redis_firewall_rule.go @@ -58,8 +58,7 @@ func resourceArmRedisFirewallRuleCreateUpdate(d *schema.ResourceData, meta inter startIP := d.Get("start_ip").(string) endIP := d.Get("end_ip").(string) - parameters := redis.FirewallRule{ - Name: &name, + parameters := redis.FirewallRuleCreateParameters{ FirewallRuleProperties: &redis.FirewallRuleProperties{ StartIP: utils.String(startIP), EndIP: utils.String(endIP), From 7042a808d0343234bde13d82314c0ba300cb18db Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 6 Apr 2018 14:18:26 +0200 Subject: [PATCH 5/6] Removing the update use-case since it's no longer valid --- azurerm/resource_arm_redis_cache_test.go | 38 ------------------------ 1 file changed, 38 deletions(-) diff --git a/azurerm/resource_arm_redis_cache_test.go b/azurerm/resource_arm_redis_cache_test.go index fa13a231481b..6aced55ab66d 100644 --- a/azurerm/resource_arm_redis_cache_test.go +++ b/azurerm/resource_arm_redis_cache_test.go @@ -356,44 +356,6 @@ func TestAccAzureRMRedisCache_InternalSubnetStaticIP(t *testing.T) { }) } -func TestAccAzureRMRedisCache_InternalSubnetUpdate(t *testing.T) { - resourceName := "azurerm_redis_cache.test" - ri := acctest.RandInt() - location := testLocation() - - config := testAccAzureRMRedisCache_premium(ri, location) - updatedConfig := testAccAzureRMRedisCache_internalSubnet(ri, location) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMRedisCacheDestroy, - Steps: []resource.TestStep{ - { - Config: config, - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMRedisCacheExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "subnet_id", ""), - ), - }, - { - Config: updatedConfig, - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMRedisCacheExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "subnet_id"), - ), - }, - { - Config: config, - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMRedisCacheExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "subnet_id", ""), - ), - }, - }, - }) -} - func testCheckAzureRMRedisCacheExists(name string) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API From e356e0abb45dff5dda500e432862907d3b764fe0 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 6 Apr 2018 14:21:14 +0200 Subject: [PATCH 6/6] Making the network fields ForceNew in the docs --- website/docs/r/redis_cache.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/redis_cache.html.markdown b/website/docs/r/redis_cache.html.markdown index 0e6efa655e2b..ee67bb1faaba 100644 --- a/website/docs/r/redis_cache.html.markdown +++ b/website/docs/r/redis_cache.html.markdown @@ -165,13 +165,13 @@ The pricing group for the Redis Family - either "C" or "P" at present. * `patch_schedule` - (Optional) A list of `patch_schedule` blocks as defined below - only available for Premium SKU's. -* `private_static_ip_address` - (Optional) The Static IP Address to assign to the Redis Cache when hosted inside the Virtual Network. +* `private_static_ip_address` - (Optional) The Static IP Address to assign to the Redis Cache when hosted inside the Virtual Network. Changing this forces a new resource to be created. * `redis_configuration` - (Required) A `redis_configuration` as defined below - with some limitations by SKU - defaults/details are shown below. * `shard_count` - (Optional) *Only available when using the Premium SKU* The number of Shards to create on the Redis Cluster. -* `subnet_id` - (Optional) The ID of the Subnet within which the Redis Cache should be deployed. +* `subnet_id` - (Optional) The ID of the Subnet within which the Redis Cache should be deployed. Changing this forces a new resource to be created. ---