mirror of
https://github.com/octoleo/restic.git
synced 2024-11-19 03:25:19 +00:00
917 lines
34 KiB
Go
917 lines
34 KiB
Go
|
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 1.0.1.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"
|
||
|
)
|
||
|
|
||
|
// GroupClient is the rEST API for Azure Redis Cache Service.
|
||
|
type GroupClient struct {
|
||
|
ManagementClient
|
||
|
}
|
||
|
|
||
|
// NewGroupClient creates an instance of the GroupClient client.
|
||
|
func NewGroupClient(subscriptionID string) GroupClient {
|
||
|
return NewGroupClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||
|
}
|
||
|
|
||
|
// NewGroupClientWithBaseURI creates an instance of the GroupClient client.
|
||
|
func NewGroupClientWithBaseURI(baseURI string, subscriptionID string) GroupClient {
|
||
|
return GroupClient{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 GroupClient) Create(resourceGroupName string, name string, parameters CreateParameters, cancel <-chan struct{}) (<-chan ResourceType, <-chan error) {
|
||
|
resultChan := make(chan ResourceType, 1)
|
||
|
errChan := make(chan error, 1)
|
||
|
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 {
|
||
|
errChan <- validation.NewErrorWithValidationError(err, "redis.GroupClient", "Create")
|
||
|
close(errChan)
|
||
|
close(resultChan)
|
||
|
return resultChan, errChan
|
||
|
}
|
||
|
|
||
|
go func() {
|
||
|
var err error
|
||
|
var result ResourceType
|
||
|
defer func() {
|
||
|
resultChan <- result
|
||
|
errChan <- err
|
||
|
close(resultChan)
|
||
|
close(errChan)
|
||
|
}()
|
||
|
req, err := client.CreatePreparer(resourceGroupName, name, parameters, cancel)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Create", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.CreateSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Create", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.CreateResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Create", resp, "Failure responding to request")
|
||
|
}
|
||
|
}()
|
||
|
return resultChan, errChan
|
||
|
}
|
||
|
|
||
|
// CreatePreparer prepares the Create request.
|
||
|
func (client GroupClient) 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),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-04-01"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": 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 GroupClient) 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 GroupClient) CreateResponder(resp *http.Response) (result ResourceType, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
|
||
|
autorest.ByUnmarshallingJSON(&result),
|
||
|
autorest.ByClosing())
|
||
|
result.Response = autorest.Response{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 GroupClient) Delete(resourceGroupName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
||
|
resultChan := make(chan autorest.Response, 1)
|
||
|
errChan := make(chan error, 1)
|
||
|
go func() {
|
||
|
var err error
|
||
|
var result autorest.Response
|
||
|
defer func() {
|
||
|
resultChan <- result
|
||
|
errChan <- err
|
||
|
close(resultChan)
|
||
|
close(errChan)
|
||
|
}()
|
||
|
req, err := client.DeletePreparer(resourceGroupName, name, cancel)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.DeleteSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = resp
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.DeleteResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", resp, "Failure responding to request")
|
||
|
}
|
||
|
}()
|
||
|
return resultChan, errChan
|
||
|
}
|
||
|
|
||
|
// DeletePreparer prepares the Delete request.
|
||
|
func (client GroupClient) 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),
|
||
|
}
|
||
|
|
||
|
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/{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 GroupClient) 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 GroupClient) 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 export data from the redis cache to blobs in a container. 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 GroupClient) ExportData(resourceGroupName string, name string, parameters ExportRDBParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
||
|
resultChan := make(chan autorest.Response, 1)
|
||
|
errChan := make(chan error, 1)
|
||
|
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 {
|
||
|
errChan <- validation.NewErrorWithValidationError(err, "redis.GroupClient", "ExportData")
|
||
|
close(errChan)
|
||
|
close(resultChan)
|
||
|
return resultChan, errChan
|
||
|
}
|
||
|
|
||
|
go func() {
|
||
|
var err error
|
||
|
var result autorest.Response
|
||
|
defer func() {
|
||
|
resultChan <- result
|
||
|
errChan <- err
|
||
|
close(resultChan)
|
||
|
close(errChan)
|
||
|
}()
|
||
|
req, err := client.ExportDataPreparer(resourceGroupName, name, parameters, cancel)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.ExportDataSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = resp
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.ExportDataResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", resp, "Failure responding to request")
|
||
|
}
|
||
|
}()
|
||
|
return resultChan, errChan
|
||
|
}
|
||
|
|
||
|
// ExportDataPreparer prepares the ExportData request.
|
||
|
func (client GroupClient) 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),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-04-01"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": 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 GroupClient) 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 GroupClient) ExportDataResponder(resp *http.Response) (result autorest.Response, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusNoContent),
|
||
|
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 GroupClient) ForceReboot(resourceGroupName string, name string, parameters RebootParameters) (result ForceRebootResponse, err error) {
|
||
|
req, err := client.ForceRebootPreparer(resourceGroupName, name, parameters)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ForceReboot", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.ForceRebootSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ForceReboot", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.ForceRebootResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ForceReboot", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// ForceRebootPreparer prepares the ForceReboot request.
|
||
|
func (client GroupClient) 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),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-04-01"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": 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 GroupClient) 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 GroupClient) ForceRebootResponder(resp *http.Response) (result ForceRebootResponse, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||
|
autorest.ByUnmarshallingJSON(&result),
|
||
|
autorest.ByClosing())
|
||
|
result.Response = autorest.Response{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 GroupClient) Get(resourceGroupName string, name string) (result ResourceType, err error) {
|
||
|
req, err := client.GetPreparer(resourceGroupName, name)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "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.GroupClient", "Get", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.GetResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Get", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// GetPreparer prepares the Get request.
|
||
|
func (client GroupClient) 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),
|
||
|
}
|
||
|
|
||
|
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/{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 GroupClient) 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 GroupClient) 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 GroupClient) ImportData(resourceGroupName string, name string, parameters ImportRDBParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
||
|
resultChan := make(chan autorest.Response, 1)
|
||
|
errChan := make(chan error, 1)
|
||
|
if err := validation.Validate([]validation.Validation{
|
||
|
{TargetValue: parameters,
|
||
|
Constraints: []validation.Constraint{{Target: "parameters.Files", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||
|
errChan <- validation.NewErrorWithValidationError(err, "redis.GroupClient", "ImportData")
|
||
|
close(errChan)
|
||
|
close(resultChan)
|
||
|
return resultChan, errChan
|
||
|
}
|
||
|
|
||
|
go func() {
|
||
|
var err error
|
||
|
var result autorest.Response
|
||
|
defer func() {
|
||
|
resultChan <- result
|
||
|
errChan <- err
|
||
|
close(resultChan)
|
||
|
close(errChan)
|
||
|
}()
|
||
|
req, err := client.ImportDataPreparer(resourceGroupName, name, parameters, cancel)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.ImportDataSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = resp
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.ImportDataResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", resp, "Failure responding to request")
|
||
|
}
|
||
|
}()
|
||
|
return resultChan, errChan
|
||
|
}
|
||
|
|
||
|
// ImportDataPreparer prepares the ImportData request.
|
||
|
func (client GroupClient) 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),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-04-01"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": 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 GroupClient) 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 GroupClient) ImportDataResponder(resp *http.Response) (result autorest.Response, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusNoContent),
|
||
|
autorest.ByClosing())
|
||
|
result.Response = resp
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// List gets all Redis caches in the specified subscription.
|
||
|
func (client GroupClient) List() (result ListResult, err error) {
|
||
|
req, err := client.ListPreparer()
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "List", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.ListSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "List", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.ListResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "List", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// ListPreparer prepares the List request.
|
||
|
func (client GroupClient) ListPreparer() (*http.Request, error) {
|
||
|
pathParameters := map[string]interface{}{
|
||
|
"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}/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 GroupClient) 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 GroupClient) 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 GroupClient) ListNextResults(lastResults ListResult) (result ListResult, err error) {
|
||
|
req, err := lastResults.ListResultPreparer()
|
||
|
if err != nil {
|
||
|
return result, autorest.NewErrorWithError(err, "redis.GroupClient", "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.GroupClient", "List", resp, "Failure sending next results request")
|
||
|
}
|
||
|
|
||
|
result, err = client.ListResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "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 GroupClient) ListByResourceGroup(resourceGroupName string) (result ListResult, err error) {
|
||
|
req, err := client.ListByResourceGroupPreparer(resourceGroupName)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.ListByResourceGroupSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListByResourceGroup", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||
|
func (client GroupClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
|
||
|
pathParameters := map[string]interface{}{
|
||
|
"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/", 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 GroupClient) 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 GroupClient) 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 GroupClient) ListByResourceGroupNextResults(lastResults ListResult) (result ListResult, err error) {
|
||
|
req, err := lastResults.ListResultPreparer()
|
||
|
if err != nil {
|
||
|
return result, autorest.NewErrorWithError(err, "redis.GroupClient", "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.GroupClient", "ListByResourceGroup", resp, "Failure sending next results request")
|
||
|
}
|
||
|
|
||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "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 GroupClient) ListKeys(resourceGroupName string, name string) (result AccessKeys, err error) {
|
||
|
req, err := client.ListKeysPreparer(resourceGroupName, name)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListKeys", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.ListKeysSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListKeys", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.ListKeysResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListKeys", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// ListKeysPreparer prepares the ListKeys request.
|
||
|
func (client GroupClient) 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),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-04-01"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": 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 GroupClient) 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 GroupClient) 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 GroupClient) RegenerateKey(resourceGroupName string, name string, parameters RegenerateKeyParameters) (result AccessKeys, err error) {
|
||
|
req, err := client.RegenerateKeyPreparer(resourceGroupName, name, parameters)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "RegenerateKey", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.RegenerateKeySender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "RegenerateKey", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.RegenerateKeyResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "RegenerateKey", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// RegenerateKeyPreparer prepares the RegenerateKey request.
|
||
|
func (client GroupClient) 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),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-04-01"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": 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 GroupClient) 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 GroupClient) 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.
|
||
|
//
|
||
|
// 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 GroupClient) Update(resourceGroupName string, name string, parameters UpdateParameters) (result ResourceType, err error) {
|
||
|
req, err := client.UpdatePreparer(resourceGroupName, name, parameters)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Update", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.UpdateSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Update", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.UpdateResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "redis.GroupClient", "Update", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// UpdatePreparer prepares the Update request.
|
||
|
func (client GroupClient) UpdatePreparer(resourceGroupName string, name string, parameters UpdateParameters) (*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 = "2016-04-01"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": 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{})
|
||
|
}
|
||
|
|
||
|
// UpdateSender sends the Update request. The method will close the
|
||
|
// http.Response Body if it receives an error.
|
||
|
func (client GroupClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||
|
return autorest.SendWithSender(client, req)
|
||
|
}
|
||
|
|
||
|
// UpdateResponder handles the response to the Update request. The method always
|
||
|
// closes the http.Response Body.
|
||
|
func (client GroupClient) UpdateResponder(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
|
||
|
}
|