provider/azurerm: Redis Cache (#10184)

* Implementing Redis Cache

* Properties should never be nil

* Updating the SDK to 7.0.1

* Redis Cache updated for SDK 7.0.1

* Fixing the max memory validation tests

* Cleaning up

* Adding tests for Standard with Tags

* Int's -> Strings for the moment

* Making the RedisConfiguration object mandatory

* Only parse out redis configuration values if they're set

* Updating the RedisConfiguration object to be required in the documentaqtion

* Adding Tags to the Standard tests / importing excluding the redisConfiguration

* Removing support for import for Redis Cache for now

* Removed a scaling test
This commit is contained in:
Tom Harvey 2016-12-18 14:23:29 +00:00 committed by Paul Stack
parent 89f4424abc
commit 776e76f6ce
12 changed files with 2403 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/eventhub" "github.com/Azure/azure-sdk-for-go/arm/eventhub"
"github.com/Azure/azure-sdk-for-go/arm/keyvault" "github.com/Azure/azure-sdk-for-go/arm/keyvault"
"github.com/Azure/azure-sdk-for-go/arm/network" "github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/redis"
"github.com/Azure/azure-sdk-for-go/arm/resources/resources" "github.com/Azure/azure-sdk-for-go/arm/resources/resources"
"github.com/Azure/azure-sdk-for-go/arm/scheduler" "github.com/Azure/azure-sdk-for-go/arm/scheduler"
"github.com/Azure/azure-sdk-for-go/arm/servicebus" "github.com/Azure/azure-sdk-for-go/arm/servicebus"
@ -78,6 +79,8 @@ type ArmClient struct {
deploymentsClient resources.DeploymentsClient deploymentsClient resources.DeploymentsClient
redisClient redis.Client
trafficManagerProfilesClient trafficmanager.ProfilesClient trafficManagerProfilesClient trafficmanager.ProfilesClient
trafficManagerEndpointsClient trafficmanager.EndpointsClient trafficManagerEndpointsClient trafficmanager.EndpointsClient
@ -385,6 +388,12 @@ func (c *Config) getArmClient() (*ArmClient, error) {
tmec.Sender = autorest.CreateSender(withRequestLogging()) tmec.Sender = autorest.CreateSender(withRequestLogging())
client.trafficManagerEndpointsClient = tmec client.trafficManagerEndpointsClient = tmec
rdc := redis.NewClient(c.SubscriptionID)
setUserAgent(&rdc.Client)
rdc.Authorizer = spt
rdc.Sender = autorest.CreateSender(withRequestLogging())
client.redisClient = rdc
sbnc := servicebus.NewNamespacesClient(c.SubscriptionID) sbnc := servicebus.NewNamespacesClient(c.SubscriptionID)
setUserAgent(&sbnc.Client) setUserAgent(&sbnc.Client)
sbnc.Authorizer = spt sbnc.Authorizer = spt

View File

@ -71,6 +71,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_network_security_group": resourceArmNetworkSecurityGroup(), "azurerm_network_security_group": resourceArmNetworkSecurityGroup(),
"azurerm_network_security_rule": resourceArmNetworkSecurityRule(), "azurerm_network_security_rule": resourceArmNetworkSecurityRule(),
"azurerm_public_ip": resourceArmPublicIp(), "azurerm_public_ip": resourceArmPublicIp(),
"azurerm_redis_cache": resourceArmRedisCache(),
"azurerm_route": resourceArmRoute(), "azurerm_route": resourceArmRoute(),
"azurerm_route_table": resourceArmRouteTable(), "azurerm_route_table": resourceArmRouteTable(),
"azurerm_servicebus_namespace": resourceArmServiceBusNamespace(), "azurerm_servicebus_namespace": resourceArmServiceBusNamespace(),
@ -205,7 +206,18 @@ func registerAzureResourceProvidersWithSubscription(client *riviera.Client) erro
var err error var err error
providerRegistrationOnce.Do(func() { providerRegistrationOnce.Do(func() {
// We register Microsoft.Compute during client initialization // We register Microsoft.Compute during client initialization
providers := []string{"Microsoft.Network", "Microsoft.Cdn", "Microsoft.Storage", "Microsoft.Sql", "Microsoft.Search", "Microsoft.Resources", "Microsoft.ServiceBus", "Microsoft.KeyVault", "Microsoft.EventHub"} providers := []string{
"Microsoft.Cache",
"Microsoft.Network",
"Microsoft.Cdn",
"Microsoft.Storage",
"Microsoft.Sql",
"Microsoft.Search",
"Microsoft.Resources",
"Microsoft.ServiceBus",
"Microsoft.KeyVault",
"Microsoft.EventHub",
}
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(len(providers)) wg.Add(len(providers))

View File

@ -0,0 +1,452 @@
package azurerm
import (
"fmt"
"log"
"net/http"
"strings"
"time"
"github.com/Azure/azure-sdk-for-go/arm/redis"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/jen20/riviera/azure"
)
func resourceArmRedisCache() *schema.Resource {
return &schema.Resource{
Create: resourceArmRedisCacheCreate,
Read: resourceArmRedisCacheRead,
Update: resourceArmRedisCacheUpdate,
Delete: resourceArmRedisCacheDelete,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"location": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: azureRMNormalizeLocation,
},
"resource_group_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"capacity": {
Type: schema.TypeInt,
Required: true,
},
"family": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateRedisFamily,
},
"sku_name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateRedisSku,
},
"shard_count": {
Type: schema.TypeInt,
Optional: true,
},
"enable_non_ssl_port": {
Type: schema.TypeBool,
Default: false,
Optional: true,
},
"redis_configuration": {
Type: schema.TypeList,
Required: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"maxclients": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"maxmemory_delta": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"maxmemory_reserved": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"maxmemory_policy": {
Type: schema.TypeString,
Optional: true,
Default: "volatile-lru",
ValidateFunc: validateRedisMaxMemoryPolicy,
},
},
},
},
"hostname": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
"ssl_port": {
Type: schema.TypeInt,
Computed: true,
},
"primary_access_key": {
Type: schema.TypeString,
Computed: true,
},
"secondary_access_key": {
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(),
},
}
}
func resourceArmRedisCacheCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).redisClient
log.Printf("[INFO] preparing arguments for Azure ARM Redis Cache creation.")
name := d.Get("name").(string)
location := d.Get("location").(string)
resGroup := d.Get("resource_group_name").(string)
enableNonSSLPort := d.Get("enable_non_ssl_port").(bool)
capacity := int32(d.Get("capacity").(int))
family := redis.SkuFamily(d.Get("family").(string))
sku := redis.SkuName(d.Get("sku_name").(string))
tags := d.Get("tags").(map[string]interface{})
expandedTags := expandTags(tags)
parameters := redis.CreateParameters{
Name: &name,
Location: &location,
CreateProperties: &redis.CreateProperties{
EnableNonSslPort: &enableNonSSLPort,
Sku: &redis.Sku{
Capacity: &capacity,
Family: family,
Name: sku,
},
RedisConfiguration: expandRedisConfiguration(d),
},
Tags: expandedTags,
}
if v, ok := d.GetOk("shard_count"); ok {
shardCount := int32(v.(int))
parameters.ShardCount = &shardCount
}
_, err := client.Create(resGroup, name, parameters, make(chan struct{}))
if err != nil {
return err
}
read, err := client.Get(resGroup, name)
if err != nil {
return err
}
if read.ID == nil {
return fmt.Errorf("Cannot read Redis Instance %s (resource group %s) ID", name, resGroup)
}
log.Printf("[DEBUG] Waiting for Redis Instance (%s) to become available", d.Get("name"))
stateConf := &resource.StateChangeConf{
Pending: []string{"Updating", "Creating"},
Target: []string{"Succeeded"},
Refresh: redisStateRefreshFunc(client, resGroup, name),
Timeout: 60 * time.Minute,
MinTimeout: 15 * time.Second,
}
if _, err := stateConf.WaitForState(); err != nil {
return fmt.Errorf("Error waiting for Redis Instance (%s) to become available: %s", d.Get("name"), err)
}
d.SetId(*read.ID)
return resourceArmRedisCacheRead(d, meta)
}
func resourceArmRedisCacheUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).redisClient
log.Printf("[INFO] preparing arguments for Azure ARM Redis Cache update.")
name := d.Get("name").(string)
resGroup := d.Get("resource_group_name").(string)
enableNonSSLPort := d.Get("enable_non_ssl_port").(bool)
capacity := int32(d.Get("capacity").(int))
family := redis.SkuFamily(d.Get("family").(string))
sku := redis.SkuName(d.Get("sku_name").(string))
tags := d.Get("tags").(map[string]interface{})
expandedTags := expandTags(tags)
parameters := redis.UpdateParameters{
UpdateProperties: &redis.UpdateProperties{
EnableNonSslPort: &enableNonSSLPort,
Sku: &redis.Sku{
Capacity: &capacity,
Family: family,
Name: sku,
},
Tags: expandedTags,
},
}
if v, ok := d.GetOk("shard_count"); ok {
if d.HasChange("shard_count") {
shardCount := int32(v.(int))
parameters.ShardCount = &shardCount
}
}
if d.HasChange("redis_configuration") {
redisConfiguration := expandRedisConfiguration(d)
parameters.RedisConfiguration = redisConfiguration
}
_, err := client.Update(resGroup, name, parameters, make(chan struct{}))
if err != nil {
return err
}
read, err := client.Get(resGroup, name)
if err != nil {
return err
}
if read.ID == nil {
return fmt.Errorf("Cannot read Redis Instance %s (resource group %s) ID", name, resGroup)
}
log.Printf("[DEBUG] Waiting for Redis Instance (%s) to become available", d.Get("name"))
stateConf := &resource.StateChangeConf{
Pending: []string{"Updating", "Creating"},
Target: []string{"Succeeded"},
Refresh: redisStateRefreshFunc(client, resGroup, name),
Timeout: 60 * time.Minute,
MinTimeout: 15 * time.Second,
}
if _, err := stateConf.WaitForState(); err != nil {
return fmt.Errorf("Error waiting for Redis Instance (%s) to become available: %s", d.Get("name"), err)
}
d.SetId(*read.ID)
return resourceArmRedisCacheRead(d, meta)
}
func resourceArmRedisCacheRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).redisClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
resGroup := id.ResourceGroup
name := id.Path["Redis"]
resp, err := client.Get(resGroup, name)
if err != nil {
return fmt.Errorf("Error making Read request on Azure Redis Cache %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}
keysResp, err := client.ListKeys(resGroup, name)
if err != nil {
return fmt.Errorf("Error making ListKeys request on Azure Redis Cache %s: %s", name, err)
}
d.Set("name", name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("ssl_port", resp.SslPort)
d.Set("host_name", resp.HostName)
d.Set("port", resp.Port)
d.Set("enable_non_ssl_port", resp.EnableNonSslPort)
d.Set("capacity", resp.Sku.Capacity)
d.Set("family", resp.Sku.Family)
d.Set("sku_name", resp.Sku.Name)
if resp.ShardCount != nil {
d.Set("shard_count", resp.ShardCount)
}
redisConfiguration := flattenRedisConfiguration(resp.RedisConfiguration)
d.Set("redis_configuration", &redisConfiguration)
d.Set("primary_access_key", keysResp.PrimaryKey)
d.Set("secondary_access_key", keysResp.SecondaryKey)
flattenAndSetTags(d, resp.Tags)
return nil
}
func resourceArmRedisCacheDelete(d *schema.ResourceData, meta interface{}) error {
redisClient := meta.(*ArmClient).redisClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
resGroup := id.ResourceGroup
name := id.Path["Redis"]
resp, err := redisClient.Delete(resGroup, name, make(chan struct{}))
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Error issuing Azure ARM delete request of Redis Cache Instance '%s': %s", name, err)
}
checkResp, _ := redisClient.Get(resGroup, name)
if checkResp.StatusCode != http.StatusNotFound {
return fmt.Errorf("Error issuing Azure ARM delete request of Redis Cache Instance '%s': it still exists after deletion", name)
}
return nil
}
func redisStateRefreshFunc(client redis.Client, resourceGroupName string, sgName string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
res, err := client.Get(resourceGroupName, sgName)
if err != nil {
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
}
}
func expandRedisConfiguration(d *schema.ResourceData) *map[string]*string {
configuration := d.Get("redis_configuration").([]interface{})
output := make(map[string]*string)
if configuration == nil {
return &output
}
// TODO: can we use this to remove the below? \/
//config := configuration[0].(map[string]interface{})
for _, v := range configuration {
config := v.(map[string]interface{})
maxClients := config["maxclients"].(string)
if maxClients != "" {
output["maxclients"] = azure.String(maxClients)
}
maxMemoryDelta := config["maxmemory_delta"].(string)
if maxMemoryDelta != "" {
output["maxmemory-delta"] = azure.String(maxMemoryDelta)
}
maxMemoryReserved := config["maxmemory_reserved"].(string)
if maxMemoryReserved != "" {
output["maxmemory-reserved"] = azure.String(maxMemoryReserved)
}
maxMemoryPolicy := config["maxmemory_policy"].(string)
if maxMemoryPolicy != "" {
output["maxmemory-policy"] = azure.String(maxMemoryPolicy)
}
}
return &output
}
func flattenRedisConfiguration(configuration *map[string]*string) map[string]*string {
redisConfiguration := make(map[string]*string, len(*configuration))
config := *configuration
redisConfiguration["maxclients"] = config["maxclients"]
redisConfiguration["maxmemory_delta"] = config["maxmemory-delta"]
redisConfiguration["maxmemory_reserved"] = config["maxmemory-reserved"]
redisConfiguration["maxmemory_policy"] = config["maxmemory-policy"]
return redisConfiguration
}
func validateRedisFamily(v interface{}, k string) (ws []string, errors []error) {
value := strings.ToLower(v.(string))
families := map[string]bool{
"c": true,
"p": true,
}
if !families[value] {
errors = append(errors, fmt.Errorf("Redis Family can only be C or P"))
}
return
}
func validateRedisMaxMemoryPolicy(v interface{}, k string) (ws []string, errors []error) {
value := strings.ToLower(v.(string))
families := map[string]bool{
"noeviction": true,
"allkeys-lru": true,
"volatile-lru": true,
"allkeys-random": true,
"volatile-random": true,
"volatile-ttl": true,
}
if !families[value] {
errors = append(errors, fmt.Errorf("Redis Max Memory Policy can only be 'noeviction' / 'allkeys-lru' / 'volatile-lru' / 'allkeys-random' / 'volatile-random' / 'volatile-ttl'"))
}
return
}
func validateRedisSku(v interface{}, k string) (ws []string, errors []error) {
value := strings.ToLower(v.(string))
skus := map[string]bool{
"basic": true,
"standard": true,
"premium": true,
}
if !skus[value] {
errors = append(errors, fmt.Errorf("Redis SKU can only be Basic, Standard or Premium"))
}
return
}

View File

@ -0,0 +1,332 @@
package azurerm
import (
"fmt"
"net/http"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccAzureRMRedisCacheFamily_validation(t *testing.T) {
cases := []struct {
Value string
ErrCount int
}{
{
Value: "C",
ErrCount: 0,
},
{
Value: "P",
ErrCount: 0,
},
{
Value: "c",
ErrCount: 0,
},
{
Value: "p",
ErrCount: 0,
},
{
Value: "a",
ErrCount: 1,
},
{
Value: "b",
ErrCount: 1,
},
{
Value: "D",
ErrCount: 1,
},
}
for _, tc := range cases {
_, errors := validateRedisFamily(tc.Value, "azurerm_redis_cache")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected the Azure RM Redis Cache Family to trigger a validation error")
}
}
}
func TestAccAzureRMRedisCacheMaxMemoryPolicy_validation(t *testing.T) {
cases := []struct {
Value string
ErrCount int
}{
{Value: "noeviction", ErrCount: 0},
{Value: "allkeys-lru", ErrCount: 0},
{Value: "volatile-lru", ErrCount: 0},
{Value: "allkeys-random", ErrCount: 0},
{Value: "volatile-random", ErrCount: 0},
{Value: "volatile-ttl", ErrCount: 0},
{Value: "something-else", ErrCount: 1},
}
for _, tc := range cases {
_, errors := validateRedisMaxMemoryPolicy(tc.Value, "azurerm_redis_cache")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected the Azure RM Redis Cache Max Memory Policy to trigger a validation error")
}
}
}
func TestAccAzureRMRedisCacheSku_validation(t *testing.T) {
cases := []struct {
Value string
ErrCount int
}{
{
Value: "Basic",
ErrCount: 0,
},
{
Value: "Standard",
ErrCount: 0,
},
{
Value: "Premium",
ErrCount: 0,
},
{
Value: "Random",
ErrCount: 1,
},
}
for _, tc := range cases {
_, errors := validateRedisSku(tc.Value, "azurerm_redis_cache")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected the Azure RM Redis Cache Sku to trigger a validation error")
}
}
}
func TestAccAzureRMRedisCache_basic(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMRedisCache_basic, ri, ri)
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_standard(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMRedisCache_standard, ri, ri)
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_premium(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMRedisCache_premium, ri, ri)
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_premiumSharded(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMRedisCache_premiumSharded, ri, ri)
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 testCheckAzureRMRedisCacheExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
// Ensure we have enough information in state to look up in API
rs, ok := s.RootModule().Resources[name]
if !ok {
return fmt.Errorf("Not found: %s", name)
}
redisName := rs.Primary.Attributes["name"]
resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
if !hasResourceGroup {
return fmt.Errorf("Bad: no resource group found in state for Redis Instance: %s", redisName)
}
conn := testAccProvider.Meta().(*ArmClient).redisClient
resp, err := conn.Get(resourceGroup, redisName)
if err != nil {
return fmt.Errorf("Bad: Get on redisClient: %s", err)
}
if resp.StatusCode == http.StatusNotFound {
return fmt.Errorf("Bad: Redis Instance %q (resource group: %q) does not exist", redisName, resourceGroup)
}
return nil
}
}
func testCheckAzureRMRedisCacheDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*ArmClient).redisClient
for _, rs := range s.RootModule().Resources {
if rs.Type != "azurerm_redis_cache" {
continue
}
name := rs.Primary.Attributes["name"]
resourceGroup := rs.Primary.Attributes["resource_group_name"]
resp, err := conn.Get(resourceGroup, name)
if err != nil {
return nil
}
if resp.StatusCode != http.StatusNotFound {
return fmt.Errorf("Redis Instance still exists:\n%#v", resp)
}
}
return nil
}
var testAccAzureRMRedisCache_basic = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
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 = "C"
sku_name = "Basic"
enable_non_ssl_port = false
redis_configuration {
maxclients = "256"
}
}
`
var testAccAzureRMRedisCache_standard = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
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 = "C"
sku_name = "Standard"
enable_non_ssl_port = false
redis_configuration {
maxclients = "256"
}
tags {
environment = "production"
}
}
`
var testAccAzureRMRedisCache_premium = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
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
redis_configuration {
maxclients = "256",
maxmemory_reserved = "2",
maxmemory_delta = "2"
maxmemory_policy = "allkeys-lru"
}
}
`
var testAccAzureRMRedisCache_premiumSharded = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
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 = true
shard_count = 3
redis_configuration {
maxclients = "256",
maxmemory_reserved = "2",
maxmemory_delta = "2"
maxmemory_policy = "allkeys-lru"
}
}
`

View File

@ -0,0 +1,57 @@
// Package redis implements the Azure ARM Redis service API version 2016-04-01.
//
// REST API for Azure Redis Cache Service.
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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
)
const (
// APIVersion is the version of the Redis
APIVersion = "2016-04-01"
// DefaultBaseURI is the default URI used for the service Redis
DefaultBaseURI = "https://management.azure.com"
)
// ManagementClient is the base client for Redis.
type ManagementClient struct {
autorest.Client
BaseURI string
APIVersion string
SubscriptionID string
}
// New creates an instance of the ManagementClient client.
func New(subscriptionID string) ManagementClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the ManagementClient client.
func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID,
}
}

View File

@ -0,0 +1,256 @@
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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/to"
"net/http"
)
// DayOfWeek enumerates the values for day of week.
type DayOfWeek string
const (
// Everyday specifies the everyday state for day of week.
Everyday DayOfWeek = "Everyday"
// Friday specifies the friday state for day of week.
Friday DayOfWeek = "Friday"
// Monday specifies the monday state for day of week.
Monday DayOfWeek = "Monday"
// Saturday specifies the saturday state for day of week.
Saturday DayOfWeek = "Saturday"
// Sunday specifies the sunday state for day of week.
Sunday DayOfWeek = "Sunday"
// Thursday specifies the thursday state for day of week.
Thursday DayOfWeek = "Thursday"
// Tuesday specifies the tuesday state for day of week.
Tuesday DayOfWeek = "Tuesday"
// Wednesday specifies the wednesday state for day of week.
Wednesday DayOfWeek = "Wednesday"
// Weekend specifies the weekend state for day of week.
Weekend DayOfWeek = "Weekend"
)
// KeyType enumerates the values for key type.
type KeyType string
const (
// Primary specifies the primary state for key type.
Primary KeyType = "Primary"
// Secondary specifies the secondary state for key type.
Secondary KeyType = "Secondary"
)
// RebootType enumerates the values for reboot type.
type RebootType string
const (
// AllNodes specifies the all nodes state for reboot type.
AllNodes RebootType = "AllNodes"
// PrimaryNode specifies the primary node state for reboot type.
PrimaryNode RebootType = "PrimaryNode"
// SecondaryNode specifies the secondary node state for reboot type.
SecondaryNode RebootType = "SecondaryNode"
)
// SkuFamily enumerates the values for sku family.
type SkuFamily string
const (
// C specifies the c state for sku family.
C SkuFamily = "C"
// P specifies the p state for sku family.
P SkuFamily = "P"
)
// SkuName enumerates the values for sku name.
type SkuName string
const (
// Basic specifies the basic state for sku name.
Basic SkuName = "Basic"
// Premium specifies the premium state for sku name.
Premium SkuName = "Premium"
// Standard specifies the standard state for sku name.
Standard SkuName = "Standard"
)
// AccessKeys is redis cache access keys.
type AccessKeys struct {
autorest.Response `json:"-"`
PrimaryKey *string `json:"primaryKey,omitempty"`
SecondaryKey *string `json:"secondaryKey,omitempty"`
}
// CreateParameters is parameters supplied to the Create Redis operation.
type CreateParameters struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
*CreateProperties `json:"properties,omitempty"`
}
// CreateProperties is properties supplied to Create Redis operation.
type CreateProperties struct {
RedisConfiguration *map[string]*string `json:"redisConfiguration,omitempty"`
EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"`
TenantSettings *map[string]*string `json:"tenantSettings,omitempty"`
ShardCount *int32 `json:"shardCount,omitempty"`
SubnetID *string `json:"subnetId,omitempty"`
StaticIP *string `json:"staticIP,omitempty"`
Sku *Sku `json:"sku,omitempty"`
}
// ExportRDBParameters is parameters for Redis export operation.
type ExportRDBParameters struct {
Format *string `json:"format,omitempty"`
Prefix *string `json:"prefix,omitempty"`
Container *string `json:"container,omitempty"`
}
// ImportRDBParameters is parameters for Redis import operation.
type ImportRDBParameters struct {
Format *string `json:"format,omitempty"`
Files *[]string `json:"files,omitempty"`
}
// ListResult is the response of list Redis operation.
type ListResult struct {
autorest.Response `json:"-"`
Value *[]ResourceType `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// ListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client ListResult) ListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// PatchSchedule is response to put/get patch schedules for Redis cache.
type PatchSchedule struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
*ScheduleEntries `json:"properties,omitempty"`
}
// Properties is properties supplied to Create or Update Redis operation.
type Properties struct {
RedisConfiguration *map[string]*string `json:"redisConfiguration,omitempty"`
EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"`
TenantSettings *map[string]*string `json:"tenantSettings,omitempty"`
ShardCount *int32 `json:"shardCount,omitempty"`
SubnetID *string `json:"subnetId,omitempty"`
StaticIP *string `json:"staticIP,omitempty"`
}
// RebootParameters is specifies which Redis node(s) to reboot.
type RebootParameters struct {
RebootType RebootType `json:"rebootType,omitempty"`
ShardID *int32 `json:"shardId,omitempty"`
}
// RegenerateKeyParameters is specifies which Redis access keys to reset.
type RegenerateKeyParameters struct {
KeyType KeyType `json:"keyType,omitempty"`
}
// Resource is the Resource definition.
type Resource struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
}
// ResourceProperties is parameters describing a Redis instance.
type ResourceProperties struct {
RedisConfiguration *map[string]*string `json:"redisConfiguration,omitempty"`
EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"`
TenantSettings *map[string]*string `json:"tenantSettings,omitempty"`
ShardCount *int32 `json:"shardCount,omitempty"`
SubnetID *string `json:"subnetId,omitempty"`
StaticIP *string `json:"staticIP,omitempty"`
Sku *Sku `json:"sku,omitempty"`
RedisVersion *string `json:"redisVersion,omitempty"`
ProvisioningState *string `json:"provisioningState,omitempty"`
HostName *string `json:"hostName,omitempty"`
Port *int32 `json:"port,omitempty"`
SslPort *int32 `json:"sslPort,omitempty"`
}
// ResourceType is a single Redis item in List or Get Operation.
type ResourceType struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
*ResourceProperties `json:"properties,omitempty"`
}
// ScheduleEntries is list of patch schedules for a Redis cache.
type ScheduleEntries struct {
ScheduleEntriesProperty *[]ScheduleEntry `json:"scheduleEntries,omitempty"`
}
// ScheduleEntry is patch schedule entry for a Premium Redis Cache.
type ScheduleEntry struct {
DayOfWeek DayOfWeek `json:"dayOfWeek,omitempty"`
StartHourUtc *int32 `json:"startHourUtc,omitempty"`
MaintenanceWindow *string `json:"maintenanceWindow,omitempty"`
}
// Sku is sKU parameters supplied to the create Redis operation.
type Sku struct {
Name SkuName `json:"name,omitempty"`
Family SkuFamily `json:"family,omitempty"`
Capacity *int32 `json:"capacity,omitempty"`
}
// UpdateParameters is parameters supplied to the Update Redis operation.
type UpdateParameters struct {
*UpdateProperties `json:"properties,omitempty"`
}
// UpdateProperties is properties supplied to Update Redis operation.
type UpdateProperties struct {
RedisConfiguration *map[string]*string `json:"redisConfiguration,omitempty"`
EnableNonSslPort *bool `json:"enableNonSslPort,omitempty"`
TenantSettings *map[string]*string `json:"tenantSettings,omitempty"`
ShardCount *int32 `json:"shardCount,omitempty"`
SubnetID *string `json:"subnetId,omitempty"`
StaticIP *string `json:"staticIP,omitempty"`
Sku *Sku `json:"sku,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
}

View File

@ -0,0 +1,245 @@
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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// PatchSchedulesClient is the rEST API for Azure Redis Cache Service.
type PatchSchedulesClient struct {
ManagementClient
}
// NewPatchSchedulesClient creates an instance of the PatchSchedulesClient
// client.
func NewPatchSchedulesClient(subscriptionID string) PatchSchedulesClient {
return NewPatchSchedulesClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewPatchSchedulesClientWithBaseURI creates an instance of the
// PatchSchedulesClient client.
func NewPatchSchedulesClientWithBaseURI(baseURI string, subscriptionID string) PatchSchedulesClient {
return PatchSchedulesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate create or replace the patching schedule for Redis cache.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache. parameters is parameters to set patch schedules for Redis
// cache.
func (client PatchSchedulesClient) CreateOrUpdate(resourceGroupName string, name string, parameters PatchSchedule) (result PatchSchedule, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.ScheduleEntries", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.ScheduleEntries.ScheduleEntriesProperty", Name: validation.Null, Rule: true, Chain: nil}}},
{Target: "parameters.ID", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.Name", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.Type", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.Location", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "redis.PatchSchedulesClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "CreateOrUpdate", nil, "Failure preparing request")
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "CreateOrUpdate", resp, "Failure sending request")
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client PatchSchedulesClient) CreateOrUpdatePreparer(resourceGroupName string, name string, parameters PatchSchedule) (*http.Request, error) {
pathParameters := map[string]interface{}{
"name": autorest.Encode("path", name),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
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{})
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client PatchSchedulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client PatchSchedulesClient) CreateOrUpdateResponder(resp *http.Response) (result PatchSchedule, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes the patching schedule for Redis cache.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache.
func (client PatchSchedulesClient) Delete(resourceGroupName string, name string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, name)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Delete", nil, "Failure preparing request")
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Delete", resp, "Failure sending request")
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client PatchSchedulesClient) DeletePreparer(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),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/default", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client PatchSchedulesClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client PatchSchedulesClient) 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 patching schedule for Redis cache.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache.
func (client PatchSchedulesClient) Get(resourceGroupName string, name string) (result PatchSchedule, err error) {
req, err := client.GetPreparer(resourceGroupName, name)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Get", nil, "Failure preparing request")
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Get", resp, "Failure sending request")
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client PatchSchedulesClient) GetPreparer(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),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/default", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client PatchSchedulesClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client PatchSchedulesClient) GetResponder(resp *http.Response) (result PatchSchedule, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}

View File

@ -0,0 +1,831 @@
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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// Client is the rEST API for Azure Redis Cache Service.
type Client struct {
ManagementClient
}
// NewClient creates an instance of the Client client.
func NewClient(subscriptionID string) Client {
return NewClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewClientWithBaseURI creates an instance of the Client client.
func NewClientWithBaseURI(baseURI string, subscriptionID string) Client {
return Client{NewWithBaseURI(baseURI, subscriptionID)}
}
// Create create or replace (overwrite/recreate, with potential downtime) an
// existing Redis cache. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache. parameters is parameters supplied to the Create Redis
// operation.
func (client Client) Create(resourceGroupName string, name string, parameters CreateParameters, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
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 {
return result, validation.NewErrorWithValidationError(err, "redis.Client", "Create")
}
req, err := client.CreatePreparer(resourceGroupName, name, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "Create", nil, "Failure preparing request")
}
resp, err := client.CreateSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "redis.Client", "Create", resp, "Failure sending request")
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "Create", resp, "Failure responding to request")
}
return
}
// CreatePreparer prepares the Create request.
func (client Client) CreatePreparer(resourceGroupName string, name string, parameters CreateParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"name": autorest.Encode("path", name),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateSender sends the Create request. The method will close the
// http.Response Body if it receives an error.
func (client Client) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Delete deletes a Redis cache. This method may poll for completion. Polling
// can be canceled by passing the cancel channel argument. The channel will
// be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache.
func (client Client) Delete(resourceGroupName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, name, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "Delete", nil, "Failure preparing request")
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "redis.Client", "Delete", resp, "Failure sending request")
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client Client) DeletePreparer(resourceGroupName string, name string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"name": autorest.Encode("path", name),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client Client) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client Client) 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
}
// ExportData import data into Redis cache. This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache. parameters is parameters for Redis export operation.
func (client Client) ExportData(resourceGroupName string, name string, parameters ExportRDBParameters, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Prefix", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Container", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "redis.Client", "ExportData")
}
req, err := client.ExportDataPreparer(resourceGroupName, name, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "ExportData", nil, "Failure preparing request")
}
resp, err := client.ExportDataSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "redis.Client", "ExportData", resp, "Failure sending request")
}
result, err = client.ExportDataResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "ExportData", resp, "Failure responding to request")
}
return
}
// ExportDataPreparer prepares the ExportData request.
func (client Client) ExportDataPreparer(resourceGroupName string, name string, parameters ExportRDBParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"name": autorest.Encode("path", name),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/export", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// ExportDataSender sends the ExportData request. The method will close the
// http.Response Body if it receives an error.
func (client Client) ExportDataSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// ExportDataResponder handles the response to the ExportData request. The method always
// closes the http.Response Body.
func (client Client) ExportDataResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
// ForceReboot reboot specified Redis node(s). This operation requires write
// permission to the cache resource. There can be potential data loss.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache. parameters is specifies which Redis node(s) to reboot.
func (client Client) ForceReboot(resourceGroupName string, name string, parameters RebootParameters) (result autorest.Response, err error) {
req, err := client.ForceRebootPreparer(resourceGroupName, name, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "ForceReboot", nil, "Failure preparing request")
}
resp, err := client.ForceRebootSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "redis.Client", "ForceReboot", resp, "Failure sending request")
}
result, err = client.ForceRebootResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "ForceReboot", resp, "Failure responding to request")
}
return
}
// ForceRebootPreparer prepares the ForceReboot request.
func (client Client) ForceRebootPreparer(resourceGroupName string, name string, parameters RebootParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"name": autorest.Encode("path", name),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/forceReboot", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ForceRebootSender sends the ForceReboot request. The method will close the
// http.Response Body if it receives an error.
func (client Client) ForceRebootSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ForceRebootResponder handles the response to the ForceReboot request. The method always
// closes the http.Response Body.
func (client Client) ForceRebootResponder(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 Redis cache (resource description).
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache.
func (client Client) Get(resourceGroupName string, name string) (result ResourceType, err error) {
req, err := client.GetPreparer(resourceGroupName, name)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "Get", nil, "Failure preparing request")
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "redis.Client", "Get", resp, "Failure sending request")
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client Client) GetPreparer(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),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client Client) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client Client) GetResponder(resp *http.Response) (result ResourceType, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ImportData import data into Redis cache. This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache. parameters is parameters for Redis import operation.
func (client Client) ImportData(resourceGroupName string, name string, parameters ImportRDBParameters, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Files", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "redis.Client", "ImportData")
}
req, err := client.ImportDataPreparer(resourceGroupName, name, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "ImportData", nil, "Failure preparing request")
}
resp, err := client.ImportDataSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "redis.Client", "ImportData", resp, "Failure sending request")
}
result, err = client.ImportDataResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "ImportData", resp, "Failure responding to request")
}
return
}
// ImportDataPreparer prepares the ImportData request.
func (client Client) ImportDataPreparer(resourceGroupName string, name string, parameters ImportRDBParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"name": autorest.Encode("path", name),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/import", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// ImportDataSender sends the ImportData request. The method will close the
// http.Response Body if it receives an error.
func (client Client) ImportDataSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// ImportDataResponder handles the response to the ImportData request. The method always
// closes the http.Response Body.
func (client Client) ImportDataResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
// List gets all Redis caches in the specified subscription.
func (client Client) List() (result ListResult, err error) {
req, err := client.ListPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "List", nil, "Failure preparing request")
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "redis.Client", "List", resp, "Failure sending request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client Client) ListPreparer() (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cache/Redis/", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client Client) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client Client) ListResponder(resp *http.Response) (result ListResult, 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 Client) ListNextResults(lastResults ListResult) (result ListResult, err error) {
req, err := lastResults.ListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "List", 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.Client", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "List", resp, "Failure responding to next results request")
}
return
}
// ListByResourceGroup lists all Redis caches in a resource group.
//
// resourceGroupName is the name of the resource group.
func (client Client) ListByResourceGroup(resourceGroupName string) (result ListResult, err error) {
req, err := client.ListByResourceGroupPreparer(resourceGroupName)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "ListByResourceGroup", nil, "Failure preparing request")
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "redis.Client", "ListByResourceGroup", resp, "Failure sending request")
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "ListByResourceGroup", resp, "Failure responding to request")
}
return
}
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
func (client Client) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
// http.Response Body if it receives an error.
func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
// closes the http.Response Body.
func (client Client) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListByResourceGroupNextResults retrieves the next set of results, if any.
func (client Client) ListByResourceGroupNextResults(lastResults ListResult) (result ListResult, err error) {
req, err := lastResults.ListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "ListByResourceGroup", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "redis.Client", "ListByResourceGroup", resp, "Failure sending next results request")
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "ListByResourceGroup", resp, "Failure responding to next results request")
}
return
}
// ListKeys retrieve a 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.
func (client Client) ListKeys(resourceGroupName string, name string) (result AccessKeys, err error) {
req, err := client.ListKeysPreparer(resourceGroupName, name)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "ListKeys", nil, "Failure preparing request")
}
resp, err := client.ListKeysSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "redis.Client", "ListKeys", resp, "Failure sending request")
}
result, err = client.ListKeysResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "ListKeys", resp, "Failure responding to request")
}
return
}
// ListKeysPreparer prepares the ListKeys request.
func (client Client) ListKeysPreparer(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),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/listKeys", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListKeysSender sends the ListKeys request. The method will close the
// http.Response Body if it receives an error.
func (client Client) ListKeysSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListKeysResponder handles the response to the ListKeys request. The method always
// closes the http.Response Body.
func (client Client) ListKeysResponder(resp *http.Response) (result AccessKeys, 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 specifies which key to regenerate.
func (client Client) RegenerateKey(resourceGroupName string, name string, parameters RegenerateKeyParameters) (result AccessKeys, err error) {
req, err := client.RegenerateKeyPreparer(resourceGroupName, name, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "RegenerateKey", nil, "Failure preparing request")
}
resp, err := client.RegenerateKeySender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "redis.Client", "RegenerateKey", resp, "Failure sending request")
}
result, err = client.RegenerateKeyResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "RegenerateKey", resp, "Failure responding to request")
}
return
}
// RegenerateKeyPreparer prepares the RegenerateKey request.
func (client Client) RegenerateKeyPreparer(resourceGroupName string, name string, parameters RegenerateKeyParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"name": autorest.Encode("path", name),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/regenerateKey", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// RegenerateKeySender sends the RegenerateKey request. The method will close the
// http.Response Body if it receives an error.
func (client Client) RegenerateKeySender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always
// closes the http.Response Body.
func (client Client) RegenerateKeyResponder(resp *http.Response) (result AccessKeys, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Update update an existing Redis cache. This method may poll for completion.
// Polling can be canceled by passing the cancel channel argument. The
// channel will be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. name is the name of
// the Redis cache. parameters is parameters supplied to the Update Redis
// operation.
func (client Client) Update(resourceGroupName string, name string, parameters UpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.UpdatePreparer(resourceGroupName, name, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "redis.Client", "Update", nil, "Failure preparing request")
}
resp, err := client.UpdateSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "redis.Client", "Update", resp, "Failure sending request")
}
result, err = client.UpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redis.Client", "Update", resp, "Failure responding to request")
}
return
}
// UpdatePreparer prepares the Update request.
func (client Client) UpdatePreparer(resourceGroupName string, name string, parameters UpdateParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"name": autorest.Encode("path", name),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// UpdateSender sends the Update request. The method will close the
// http.Response Body if it receives an error.
func (client Client) UpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// UpdateResponder handles the response to the Update request. The method always
// closes the http.Response Body.
func (client Client) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}

View File

@ -0,0 +1,43 @@
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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"fmt"
)
const (
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
)
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "redis", "2016-04-01")
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag)
}

11
vendor/vendor.json vendored
View File

@ -48,7 +48,16 @@
"versionExact": "v7.0.1-beta" "versionExact": "v7.0.1-beta"
}, },
{ {
"checksumSHA1": "uC6vwlBtGNsb+aJJG3m9tdEfHQM=", "checksumSHA1": "VECRv0I+g9uIgIZpeKb38hF/sT0=",
"comment": "v2.1.1-beta-8-gca4d906",
"path": "github.com/Azure/azure-sdk-for-go/arm/redis",
"revision": "0984e0641ae43b89283223034574d6465be93bf4",
"revisionTime": "2016-11-30T22:29:01Z",
"version": "v7.0.1-beta",
"versionExact": "v7.0.1-beta"
},
{
"checksumSHA1": "VECRv0I+g9uIgIZpeKb38hF/sT0=",
"comment": "v2.1.1-beta-8-gca4d906", "comment": "v2.1.1-beta-8-gca4d906",
"path": "github.com/Azure/azure-sdk-for-go/arm/resources/resources", "path": "github.com/Azure/azure-sdk-for-go/arm/resources/resources",
"revision": "0984e0641ae43b89283223034574d6465be93bf4", "revision": "0984e0641ae43b89283223034574d6465be93bf4",

View File

@ -0,0 +1,146 @@
---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_redis_cache"
sidebar_current: "docs-azurerm-resource-redis-cache"
description: |-
Creates a new Redis Cache Resource
---
# azurerm\_redis\_cache
Creates a new Redis Cache Resource
## Example Usage (Basic)
```
resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1"
location = "West US"
}
resource "azurerm_redis_cache" "test" {
name = "test"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
capacity = 0
family = "C"
sku_name = "Basic"
enable_non_ssl_port = false
redis_configuration {
maxclients = "256"
}
}
```
## Example Usage (Standard)
```
resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1"
location = "West US"
}
resource "azurerm_redis_cache" "test" {
name = "test"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
capacity = 1
family = "C"
sku_name = "Standard"
enable_non_ssl_port = false
redis_configuration {
maxclients = "1000"
}
}
```
## Example Usage (Premium with Clustering)
```
resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1"
location = "West US"
}
resource "azurerm_redis_cache" "test" {
name = "clustered-test"
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
shard_count = 3
redis_configuration {
maxclients = "7500",
maxmemory_reserved = "2",
maxmemory_delta = "2"
maxmemory_policy = "allkeys-lru"
}
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) The name of the Redis instance. Changing this forces a
new resource to be created.
* `location` - (Required) The location of the resource group.
* `resource_group_name` - (Required) The name of the resource group in which to
create the Redis instance.
* `capacity` - (Required) This corresponds to the size of the Redis instance you wish to use (e.g. a C0 would be 0, P3 would be 3 etc).
* `family` - (Required) The pricing group for the Redis Family - either "C" or "P" at present.
* `sku_name` - (Required) The SKU of Redis to use - can be either Basic, Standard or Premium.
* `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.
* `redis_configuration` - (Required) Potential Redis configuration values - with some limitations by SKU - defaults/details are shown below.
```
redis_configuration {
maxclients = "512"
maxmemory_reserve" = "10"
maxmemory_delta = "2"
maxmemory_policy = "allkeys-lru"
}
```
## Default Redis Configuration Values
| Redis Value | Basic | Standard | Premium |
| ------------------ | ------------ | ------------ | ------------ |
| maxclients | 256 | 1000 | 7500 |
| maxmemory_reserved | 2 | 50 | 200 |
| maxmemory_delta | 2 | 50 | 200 |
| maxmemory_policy | volatile-lru | volatile-lru | volatile-lru |
_*Important*: The maxmemory_reserved setting is only available for Standard and Premium caches. More details are available in the Relevant Links section below._
## Attributes Reference
The following attributes are exported:
* `id` - The Route ID.
* `hostname` - The Hostname of the Redis Instance
* `ssl_port` - The non-SSL Port of the Redis Instance
* `port` - The SSL Port of the Redis Instance
* `primary_access_key` - The Primary Access Key for the Redis Instance
* `secondary_access_key` - The Secondary Access Key for the Redis Instance
## Relevant Links
- [Azure Redis Cache: SKU specific configuration limitations](https://azure.microsoft.com/en-us/documentation/articles/cache-configure/#advanced-settings)
- [Redis: Available Configuration Settings](http://redis.io/topics/config)

View File

@ -192,6 +192,15 @@
</ul> </ul>
</li> </li>
<li<%= sidebar_current(/^docs-azurerm-redis-cache/) %>>
<a href="#">Redis Resources</a>
<ul class="nav nav-visible">
<li<%= sidebar_current("docs-azurerm-redis-cache") %>>
<a href="/docs/providers/azurerm/r/redis_cache.html">azurerm_redis_cache</a>
</li>
</ul>
</li>
<li<%= sidebar_current(/^docs-azurerm-resource-search/) %>> <li<%= sidebar_current(/^docs-azurerm-resource-search/) %>>
<a href="#">Search Resources</a> <a href="#">Search Resources</a>
<ul class="nav nav-visible"> <ul class="nav nav-visible">