From 66fba0929a61654800f56029e8924a137dc53810 Mon Sep 17 00:00:00 2001 From: JiahuiPeng <46921893+804873052@users.noreply.github.com> Date: Thu, 12 Aug 2021 12:37:40 +0800 Subject: [PATCH] track2 release `armredis` (#15253) * track2 gennerator redis * fix build.go --- sdk/redis/armredis/CHANGELOG.md | 3 + sdk/redis/armredis/LICENSE.txt | 21 + sdk/redis/armredis/README.md | 76 ++ sdk/redis/armredis/autorest.md | 10 + sdk/redis/armredis/build.go | 7 + sdk/redis/armredis/ci.yml | 15 + sdk/redis/armredis/go.mod | 9 + sdk/redis/armredis/go.sum | 20 + sdk/redis/armredis/go_mod_tidy_hack.go | 12 + sdk/redis/armredis/zz_generated_constants.go | 307 +++++ .../zz_generated_firewallrules_client.go | 295 +++++ .../zz_generated_linkedserver_client.go | 335 ++++++ sdk/redis/armredis/zz_generated_models.go | 1009 ++++++++++++++++ .../zz_generated_operations_client.go | 78 ++ sdk/redis/armredis/zz_generated_pagers.go | 400 +++++++ .../zz_generated_patchschedules_client.go | 295 +++++ sdk/redis/armredis/zz_generated_pollers.go | 286 +++++ ...rated_privateendpointconnections_client.go | 338 ++++++ ...z_generated_privatelinkresources_client.go | 97 ++ .../armredis/zz_generated_redis_client.go | 1010 +++++++++++++++++ .../armredis/zz_generated_response_types.go | 410 +++++++ .../armredis/zz_generated_time_rfc3339.go | 57 + 22 files changed, 5090 insertions(+) create mode 100644 sdk/redis/armredis/CHANGELOG.md create mode 100644 sdk/redis/armredis/LICENSE.txt create mode 100644 sdk/redis/armredis/README.md create mode 100644 sdk/redis/armredis/autorest.md create mode 100644 sdk/redis/armredis/build.go create mode 100644 sdk/redis/armredis/ci.yml create mode 100644 sdk/redis/armredis/go.mod create mode 100644 sdk/redis/armredis/go.sum create mode 100644 sdk/redis/armredis/go_mod_tidy_hack.go create mode 100644 sdk/redis/armredis/zz_generated_constants.go create mode 100644 sdk/redis/armredis/zz_generated_firewallrules_client.go create mode 100644 sdk/redis/armredis/zz_generated_linkedserver_client.go create mode 100644 sdk/redis/armredis/zz_generated_models.go create mode 100644 sdk/redis/armredis/zz_generated_operations_client.go create mode 100644 sdk/redis/armredis/zz_generated_pagers.go create mode 100644 sdk/redis/armredis/zz_generated_patchschedules_client.go create mode 100644 sdk/redis/armredis/zz_generated_pollers.go create mode 100644 sdk/redis/armredis/zz_generated_privateendpointconnections_client.go create mode 100644 sdk/redis/armredis/zz_generated_privatelinkresources_client.go create mode 100644 sdk/redis/armredis/zz_generated_redis_client.go create mode 100644 sdk/redis/armredis/zz_generated_response_types.go create mode 100644 sdk/redis/armredis/zz_generated_time_rfc3339.go diff --git a/sdk/redis/armredis/CHANGELOG.md b/sdk/redis/armredis/CHANGELOG.md new file mode 100644 index 000000000000..c7196df9ed8b --- /dev/null +++ b/sdk/redis/armredis/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## v0.1.0 (released) diff --git a/sdk/redis/armredis/LICENSE.txt b/sdk/redis/armredis/LICENSE.txt new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/redis/armredis/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/redis/armredis/README.md b/sdk/redis/armredis/README.md new file mode 100644 index 000000000000..c1918118f576 --- /dev/null +++ b/sdk/redis/armredis/README.md @@ -0,0 +1,76 @@ +# Azure Cache for Redis Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/redis/armredis)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/redis/armredis) + +The `armredis` module provides operations for working with Azure Cache for Redis. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/redis/armredis) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Cache for Redis module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/redis/armredis +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Cache for Redis. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Cache for Redis + +Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := armcore.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `armcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore). + +## Clients + +Azure Cache for Redis modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `armcore.Connection`. + +```go +client := armredis.NewRedisClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Cache for Redis` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/redis/armredis/autorest.md b/sdk/redis/armredis/autorest.md new file mode 100644 index 000000000000..6c0ee9751bbb --- /dev/null +++ b/sdk/redis/armredis/autorest.md @@ -0,0 +1,10 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +require: +- https://github.com/Azure/azure-rest-api-specs/blob/8b708ea0e665144ad1fe691fc7cca33517ac3c7e/specification/redis/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/8b708ea0e665144ad1fe691fc7cca33517ac3c7e/specification/redis/resource-manager/readme.go.md +module-version: 0.1.0 +``` \ No newline at end of file diff --git a/sdk/redis/armredis/build.go b/sdk/redis/armredis/build.go new file mode 100644 index 000000000000..79c93498e149 --- /dev/null +++ b/sdk/redis/armredis/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../eng/scripts/build.ps1 -skipBuild -format -tidy -generate armredis + +package armredis diff --git a/sdk/redis/armredis/ci.yml b/sdk/redis/armredis/ci.yml new file mode 100644 index 000000000000..dfaa8b757680 --- /dev/null +++ b/sdk/redis/armredis/ci.yml @@ -0,0 +1,15 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + paths: + include: + - sdk/redis/armredis/ + +pr: + paths: + include: + - sdk/redis/armredis/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'redis/armredis' diff --git a/sdk/redis/armredis/go.mod b/sdk/redis/armredis/go.mod new file mode 100644 index 000000000000..eddf79bdb3a7 --- /dev/null +++ b/sdk/redis/armredis/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/redis/armredis + +go 1.13 + +require ( + github.com/Azure/azure-sdk-for-go v56.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 +) diff --git a/sdk/redis/armredis/go.sum b/sdk/redis/armredis/go.sum new file mode 100644 index 000000000000..9e02912957fd --- /dev/null +++ b/sdk/redis/armredis/go.sum @@ -0,0 +1,20 @@ +github.com/Azure/azure-sdk-for-go v56.1.0+incompatible h1:Ofcecdw3F1ZqnpDEZcLzH9Hq0P4Y5Si8+EioXJSamJs= +github.com/Azure/azure-sdk-for-go v56.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 h1:HQQoaSGOh32mpoRkpLDjkngMwYJqkxu93FRx0epdLHE= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0/go.mod h1:BSKvHb/5cy8j4hahIInXH92X/2zGJ3TxKF6b9pw1Btg= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 h1:UC4vfOhW2l0f2QOCQpOxJS4/K6oKFy2tQZE+uWU1MEo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1 h1:vx8McI56N5oLSQu8xa+xdiE0fjQq8W8Zt49vHP8Rygw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/sdk/redis/armredis/go_mod_tidy_hack.go b/sdk/redis/armredis/go_mod_tidy_hack.go new file mode 100644 index 000000000000..8f663ac61cc4 --- /dev/null +++ b/sdk/redis/armredis/go_mod_tidy_hack.go @@ -0,0 +1,12 @@ +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armredis + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/redis/armredis/zz_generated_constants.go b/sdk/redis/armredis/zz_generated_constants.go new file mode 100644 index 000000000000..b7fcc7ecc149 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_constants.go @@ -0,0 +1,307 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +const telemetryInfo = "azsdk-go-armredis/v0.1.0" + +// DayOfWeek - Day of the week when a cache can be patched. +type DayOfWeek string + +const ( + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekEveryday DayOfWeek = "Everyday" + DayOfWeekWeekend DayOfWeek = "Weekend" +) + +// PossibleDayOfWeekValues returns the possible values for the DayOfWeek const type. +func PossibleDayOfWeekValues() []DayOfWeek { + return []DayOfWeek{ + DayOfWeekMonday, + DayOfWeekTuesday, + DayOfWeekWednesday, + DayOfWeekThursday, + DayOfWeekFriday, + DayOfWeekSaturday, + DayOfWeekSunday, + DayOfWeekEveryday, + DayOfWeekWeekend, + } +} + +// ToPtr returns a *DayOfWeek pointing to the current value. +func (c DayOfWeek) ToPtr() *DayOfWeek { + return &c +} + +type DefaultName string + +const ( + DefaultNameDefault DefaultName = "default" +) + +// PossibleDefaultNameValues returns the possible values for the DefaultName const type. +func PossibleDefaultNameValues() []DefaultName { + return []DefaultName{ + DefaultNameDefault, + } +} + +// ToPtr returns a *DefaultName pointing to the current value. +func (c DefaultName) ToPtr() *DefaultName { + return &c +} + +// PrivateEndpointConnectionProvisioningState - The current provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns the possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{ + PrivateEndpointConnectionProvisioningStateCreating, + PrivateEndpointConnectionProvisioningStateDeleting, + PrivateEndpointConnectionProvisioningStateFailed, + PrivateEndpointConnectionProvisioningStateSucceeded, + } +} + +// ToPtr returns a *PrivateEndpointConnectionProvisioningState pointing to the current value. +func (c PrivateEndpointConnectionProvisioningState) ToPtr() *PrivateEndpointConnectionProvisioningState { + return &c +} + +// PrivateEndpointServiceConnectionStatus - The private endpoint connection status. +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateEndpointServiceConnectionStatusValues returns the possible values for the PrivateEndpointServiceConnectionStatus const type. +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{ + PrivateEndpointServiceConnectionStatusApproved, + PrivateEndpointServiceConnectionStatusPending, + PrivateEndpointServiceConnectionStatusRejected, + } +} + +// ToPtr returns a *PrivateEndpointServiceConnectionStatus pointing to the current value. +func (c PrivateEndpointServiceConnectionStatus) ToPtr() *PrivateEndpointServiceConnectionStatus { + return &c +} + +// ProvisioningState - Redis instance provisioning status. +type ProvisioningState string + +const ( + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDisabled ProvisioningState = "Disabled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateLinking ProvisioningState = "Linking" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateRecoveringScaleFailure ProvisioningState = "RecoveringScaleFailure" + ProvisioningStateScaling ProvisioningState = "Scaling" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnlinking ProvisioningState = "Unlinking" + ProvisioningStateUnprovisioning ProvisioningState = "Unprovisioning" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateDisabled, + ProvisioningStateFailed, + ProvisioningStateLinking, + ProvisioningStateProvisioning, + ProvisioningStateRecoveringScaleFailure, + ProvisioningStateScaling, + ProvisioningStateSucceeded, + ProvisioningStateUnlinking, + ProvisioningStateUnprovisioning, + ProvisioningStateUpdating, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// PublicNetworkAccess - Whether or not public endpoint access is allowed for this cache. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. +// If 'Disabled', private endpoints are the exclusive access method. +// Default value is 'Enabled' +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{ + PublicNetworkAccessDisabled, + PublicNetworkAccessEnabled, + } +} + +// ToPtr returns a *PublicNetworkAccess pointing to the current value. +func (c PublicNetworkAccess) ToPtr() *PublicNetworkAccess { + return &c +} + +// RebootType - Which Redis node(s) to reboot. Depending on this value data loss is possible. +type RebootType string + +const ( + RebootTypeAllNodes RebootType = "AllNodes" + RebootTypePrimaryNode RebootType = "PrimaryNode" + RebootTypeSecondaryNode RebootType = "SecondaryNode" +) + +// PossibleRebootTypeValues returns the possible values for the RebootType const type. +func PossibleRebootTypeValues() []RebootType { + return []RebootType{ + RebootTypeAllNodes, + RebootTypePrimaryNode, + RebootTypeSecondaryNode, + } +} + +// ToPtr returns a *RebootType pointing to the current value. +func (c RebootType) ToPtr() *RebootType { + return &c +} + +// RedisKeyType - The Redis access key to regenerate. +type RedisKeyType string + +const ( + RedisKeyTypePrimary RedisKeyType = "Primary" + RedisKeyTypeSecondary RedisKeyType = "Secondary" +) + +// PossibleRedisKeyTypeValues returns the possible values for the RedisKeyType const type. +func PossibleRedisKeyTypeValues() []RedisKeyType { + return []RedisKeyType{ + RedisKeyTypePrimary, + RedisKeyTypeSecondary, + } +} + +// ToPtr returns a *RedisKeyType pointing to the current value. +func (c RedisKeyType) ToPtr() *RedisKeyType { + return &c +} + +// ReplicationRole - Role of the linked server. +type ReplicationRole string + +const ( + ReplicationRolePrimary ReplicationRole = "Primary" + ReplicationRoleSecondary ReplicationRole = "Secondary" +) + +// PossibleReplicationRoleValues returns the possible values for the ReplicationRole const type. +func PossibleReplicationRoleValues() []ReplicationRole { + return []ReplicationRole{ + ReplicationRolePrimary, + ReplicationRoleSecondary, + } +} + +// ToPtr returns a *ReplicationRole pointing to the current value. +func (c ReplicationRole) ToPtr() *ReplicationRole { + return &c +} + +// SKUFamily - The SKU family to use. Valid values: (C, P). (C = Basic/Standard, P = Premium). +type SKUFamily string + +const ( + SKUFamilyC SKUFamily = "C" + SKUFamilyP SKUFamily = "P" +) + +// PossibleSKUFamilyValues returns the possible values for the SKUFamily const type. +func PossibleSKUFamilyValues() []SKUFamily { + return []SKUFamily{ + SKUFamilyC, + SKUFamilyP, + } +} + +// ToPtr returns a *SKUFamily pointing to the current value. +func (c SKUFamily) ToPtr() *SKUFamily { + return &c +} + +// SKUName - The type of Redis cache to deploy. Valid values: (Basic, Standard, Premium) +type SKUName string + +const ( + SKUNameBasic SKUName = "Basic" + SKUNamePremium SKUName = "Premium" + SKUNameStandard SKUName = "Standard" +) + +// PossibleSKUNameValues returns the possible values for the SKUName const type. +func PossibleSKUNameValues() []SKUName { + return []SKUName{ + SKUNameBasic, + SKUNamePremium, + SKUNameStandard, + } +} + +// ToPtr returns a *SKUName pointing to the current value. +func (c SKUName) ToPtr() *SKUName { + return &c +} + +// TLSVersion - Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2') +type TLSVersion string + +const ( + TLSVersionOne0 TLSVersion = "1.0" + TLSVersionOne1 TLSVersion = "1.1" + TLSVersionOne2 TLSVersion = "1.2" +) + +// PossibleTLSVersionValues returns the possible values for the TLSVersion const type. +func PossibleTLSVersionValues() []TLSVersion { + return []TLSVersion{ + TLSVersionOne0, + TLSVersionOne1, + TLSVersionOne2, + } +} + +// ToPtr returns a *TLSVersion pointing to the current value. +func (c TLSVersion) ToPtr() *TLSVersion { + return &c +} diff --git a/sdk/redis/armredis/zz_generated_firewallrules_client.go b/sdk/redis/armredis/zz_generated_firewallrules_client.go new file mode 100644 index 000000000000..e6cbb2d859a7 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_firewallrules_client.go @@ -0,0 +1,295 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// FirewallRulesClient contains the methods for the FirewallRules group. +// Don't use this type directly, use NewFirewallRulesClient() instead. +type FirewallRulesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewFirewallRulesClient creates a new instance of FirewallRulesClient with the specified values. +func NewFirewallRulesClient(con *armcore.Connection, subscriptionID string) *FirewallRulesClient { + return &FirewallRulesClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or update a redis cache firewall rule +// If the operation fails it returns the *ErrorResponse error type. +func (client *FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, parameters RedisFirewallRule, options *FirewallRulesCreateOrUpdateOptions) (FirewallRulesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, cacheName, ruleName, parameters, options) + if err != nil { + return FirewallRulesCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return FirewallRulesCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return FirewallRulesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, parameters RedisFirewallRule, options *FirewallRulesCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules/{ruleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *FirewallRulesClient) createOrUpdateHandleResponse(resp *azcore.Response) (FirewallRulesCreateOrUpdateResponse, error) { + result := FirewallRulesCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisFirewallRule); err != nil { + return FirewallRulesCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *FirewallRulesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes a single firewall rule in a specified redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, options *FirewallRulesDeleteOptions) (FirewallRulesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, cacheName, ruleName, options) + if err != nil { + return FirewallRulesDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return FirewallRulesDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return FirewallRulesDeleteResponse{}, client.deleteHandleError(resp) + } + return FirewallRulesDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, options *FirewallRulesDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules/{ruleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *FirewallRulesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets a single firewall rule in a specified redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, options *FirewallRulesGetOptions) (FirewallRulesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, cacheName, ruleName, options) + if err != nil { + return FirewallRulesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return FirewallRulesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return FirewallRulesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *FirewallRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, options *FirewallRulesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules/{ruleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FirewallRulesClient) getHandleResponse(resp *azcore.Response) (FirewallRulesGetResponse, error) { + result := FirewallRulesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisFirewallRule); err != nil { + return FirewallRulesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *FirewallRulesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Gets all firewall rules in the specified redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *FirewallRulesClient) List(resourceGroupName string, cacheName string, options *FirewallRulesListOptions) FirewallRulesListPager { + return &firewallRulesListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, cacheName, options) + }, + advancer: func(ctx context.Context, resp FirewallRulesListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RedisFirewallRuleListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *FirewallRulesClient) listCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *FirewallRulesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *FirewallRulesClient) listHandleResponse(resp *azcore.Response) (FirewallRulesListResponse, error) { + result := FirewallRulesListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisFirewallRuleListResult); err != nil { + return FirewallRulesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *FirewallRulesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/redis/armredis/zz_generated_linkedserver_client.go b/sdk/redis/armredis/zz_generated_linkedserver_client.go new file mode 100644 index 000000000000..deb28c72fd22 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_linkedserver_client.go @@ -0,0 +1,335 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// LinkedServerClient contains the methods for the LinkedServer group. +// Don't use this type directly, use NewLinkedServerClient() instead. +type LinkedServerClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewLinkedServerClient creates a new instance of LinkedServerClient with the specified values. +func NewLinkedServerClient(con *armcore.Connection, subscriptionID string) *LinkedServerClient { + return &LinkedServerClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Adds a linked server to the Redis cache (requires Premium SKU). +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkedServerClient) BeginCreate(ctx context.Context, resourceGroupName string, name string, linkedServerName string, parameters RedisLinkedServerCreateParameters, options *LinkedServerBeginCreateOptions) (LinkedServerCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, name, linkedServerName, parameters, options) + if err != nil { + return LinkedServerCreatePollerResponse{}, err + } + result := LinkedServerCreatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("LinkedServerClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return LinkedServerCreatePollerResponse{}, err + } + poller := &linkedServerCreatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (LinkedServerCreateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new LinkedServerCreatePoller from the specified resume token. +// token - The value must come from a previous call to LinkedServerCreatePoller.ResumeToken(). +func (client *LinkedServerClient) ResumeCreate(ctx context.Context, token string) (LinkedServerCreatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("LinkedServerClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return LinkedServerCreatePollerResponse{}, err + } + poller := &linkedServerCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return LinkedServerCreatePollerResponse{}, err + } + result := LinkedServerCreatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (LinkedServerCreateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Adds a linked server to the Redis cache (requires Premium SKU). +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkedServerClient) create(ctx context.Context, resourceGroupName string, name string, linkedServerName string, parameters RedisLinkedServerCreateParameters, options *LinkedServerBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, name, linkedServerName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *LinkedServerClient) createCreateRequest(ctx context.Context, resourceGroupName string, name string, linkedServerName string, parameters RedisLinkedServerCreateParameters, options *LinkedServerBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers/{linkedServerName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if linkedServerName == "" { + return nil, errors.New("parameter linkedServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkedServerName}", url.PathEscape(linkedServerName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createHandleError handles the Create error response. +func (client *LinkedServerClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the linked server from a redis cache (requires Premium SKU). +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkedServerClient) Delete(ctx context.Context, resourceGroupName string, name string, linkedServerName string, options *LinkedServerDeleteOptions) (LinkedServerDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, name, linkedServerName, options) + if err != nil { + return LinkedServerDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LinkedServerDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return LinkedServerDeleteResponse{}, client.deleteHandleError(resp) + } + return LinkedServerDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *LinkedServerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, name string, linkedServerName string, options *LinkedServerDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers/{linkedServerName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if linkedServerName == "" { + return nil, errors.New("parameter linkedServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkedServerName}", url.PathEscape(linkedServerName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *LinkedServerClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the detailed information about a linked server of a redis cache (requires Premium SKU). +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkedServerClient) Get(ctx context.Context, resourceGroupName string, name string, linkedServerName string, options *LinkedServerGetOptions) (LinkedServerGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, name, linkedServerName, options) + if err != nil { + return LinkedServerGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LinkedServerGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LinkedServerGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LinkedServerClient) getCreateRequest(ctx context.Context, resourceGroupName string, name string, linkedServerName string, options *LinkedServerGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers/{linkedServerName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if linkedServerName == "" { + return nil, errors.New("parameter linkedServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkedServerName}", url.PathEscape(linkedServerName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LinkedServerClient) getHandleResponse(resp *azcore.Response) (LinkedServerGetResponse, error) { + result := LinkedServerGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisLinkedServerWithProperties); err != nil { + return LinkedServerGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LinkedServerClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Gets the list of linked servers associated with this redis cache (requires Premium SKU). +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkedServerClient) List(resourceGroupName string, name string, options *LinkedServerListOptions) LinkedServerListPager { + return &linkedServerListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, name, options) + }, + advancer: func(ctx context.Context, resp LinkedServerListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RedisLinkedServerWithPropertiesList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *LinkedServerClient) listCreateRequest(ctx context.Context, resourceGroupName string, name string, options *LinkedServerListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *LinkedServerClient) listHandleResponse(resp *azcore.Response) (LinkedServerListResponse, error) { + result := LinkedServerListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisLinkedServerWithPropertiesList); err != nil { + return LinkedServerListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *LinkedServerClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/redis/armredis/zz_generated_models.go b/sdk/redis/armredis/zz_generated_models.go new file mode 100644 index 000000000000..20a0309c04ff --- /dev/null +++ b/sdk/redis/armredis/zz_generated_models.go @@ -0,0 +1,1009 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// CheckNameAvailabilityParameters - Parameters body to pass for resource name availability check. +type CheckNameAvailabilityParameters struct { + // REQUIRED; Resource name. + Name *string `json:"name,omitempty"` + + // REQUIRED; Resource type. The only legal value of this property for checking redis cache name availability is 'Microsoft.Cache/redis'. + Type *string `json:"type,omitempty"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData +// error response format.). +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error object. + InnerError *ErrorDetail `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// ExportRDBParameters - Parameters for Redis export operation. +type ExportRDBParameters struct { + // REQUIRED; Container name to export to. + Container *string `json:"container,omitempty"` + + // REQUIRED; Prefix to use for exported files. + Prefix *string `json:"prefix,omitempty"` + + // File format. + Format *string `json:"format,omitempty"` +} + +// FirewallRulesCreateOrUpdateOptions contains the optional parameters for the FirewallRules.CreateOrUpdate method. +type FirewallRulesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// FirewallRulesDeleteOptions contains the optional parameters for the FirewallRules.Delete method. +type FirewallRulesDeleteOptions struct { + // placeholder for future optional parameters +} + +// FirewallRulesGetOptions contains the optional parameters for the FirewallRules.Get method. +type FirewallRulesGetOptions struct { + // placeholder for future optional parameters +} + +// FirewallRulesListOptions contains the optional parameters for the FirewallRules.List method. +type FirewallRulesListOptions struct { + // placeholder for future optional parameters +} + +// ImportRDBParameters - Parameters for Redis import operation. +type ImportRDBParameters struct { + // REQUIRED; files to import. + Files []*string `json:"files,omitempty"` + + // File format. + Format *string `json:"format,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImportRDBParameters. +func (i ImportRDBParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "files", i.Files) + populate(objectMap, "format", i.Format) + return json.Marshal(objectMap) +} + +// LinkedServerBeginCreateOptions contains the optional parameters for the LinkedServer.BeginCreate method. +type LinkedServerBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// LinkedServerDeleteOptions contains the optional parameters for the LinkedServer.Delete method. +type LinkedServerDeleteOptions struct { + // placeholder for future optional parameters +} + +// LinkedServerGetOptions contains the optional parameters for the LinkedServer.Get method. +type LinkedServerGetOptions struct { + // placeholder for future optional parameters +} + +// LinkedServerListOptions contains the optional parameters for the LinkedServer.List method. +type LinkedServerListOptions struct { + // placeholder for future optional parameters +} + +// NotificationListResponse - The response of listUpgradeNotifications. +type NotificationListResponse struct { + // List of all notifications. + Value []*UpgradeNotification `json:"value,omitempty"` + + // READ-ONLY; Link for next set of notifications. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationListResponse. +func (n NotificationListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// Operation - REST API operation +type Operation struct { + // The object that describes the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` +} + +// OperationDisplay - The object that describes the operation. +type OperationDisplay struct { + // Friendly name of the operation + Description *string `json:"description,omitempty"` + + // Operation type: read, write, delete, listKeys/action, etc. + Operation *string `json:"operation,omitempty"` + + // Friendly name of the resource provider + Provider *string `json:"provider,omitempty"` + + // Resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationListResult - Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. +type OperationListResult struct { + // List of operations supported by the resource provider. + Value []*Operation `json:"value,omitempty"` + + // READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// PatchSchedulesCreateOrUpdateOptions contains the optional parameters for the PatchSchedules.CreateOrUpdate method. +type PatchSchedulesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PatchSchedulesDeleteOptions contains the optional parameters for the PatchSchedules.Delete method. +type PatchSchedulesDeleteOptions struct { + // placeholder for future optional parameters +} + +// PatchSchedulesGetOptions contains the optional parameters for the PatchSchedules.Get method. +type PatchSchedulesGetOptions struct { + // placeholder for future optional parameters +} + +// PatchSchedulesListByRedisResourceOptions contains the optional parameters for the PatchSchedules.ListByRedisResource method. +type PatchSchedulesListByRedisResourceOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpoint - The Private Endpoint resource. +type PrivateEndpoint struct { + // READ-ONLY; The ARM identifier for Private Endpoint + ID *string `json:"id,omitempty" azure:"ro"` +} + +// PrivateEndpointConnection - The Private Endpoint Connection resource. +type PrivateEndpointConnection struct { + Resource + // Resource properties. + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnection. +func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionListResult - List of private endpoint connection associated with the specified storage account +type PrivateEndpointConnectionListResult struct { + // Array of private endpoint connections + Value []*PrivateEndpointConnection `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionProperties - Properties of the PrivateEndpointConnectProperties. +type PrivateEndpointConnectionProperties struct { + // REQUIRED; A collection of information about the state of the connection between service consumer and provider. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + + // The resource of private end point. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + + // READ-ONLY; The provisioning state of the private endpoint connection resource. + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// PrivateEndpointConnectionsBeginPutOptions contains the optional parameters for the PrivateEndpointConnections.BeginPut method. +type PrivateEndpointConnectionsBeginPutOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsDeleteOptions contains the optional parameters for the PrivateEndpointConnections.Delete method. +type PrivateEndpointConnectionsDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsGetOptions contains the optional parameters for the PrivateEndpointConnections.Get method. +type PrivateEndpointConnectionsGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsListOptions contains the optional parameters for the PrivateEndpointConnections.List method. +type PrivateEndpointConnectionsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResource - A private link resource +type PrivateLinkResource struct { + Resource + // Resource properties. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceListResult - A list of private link resources +type PrivateLinkResourceListResult struct { + // Array of private link resources + Value []*PrivateLinkResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceProperties - Properties of a private link resource. +type PrivateLinkResourceProperties struct { + // The private link resource Private link DNS zone name. + RequiredZoneNames []*string `json:"requiredZoneNames,omitempty"` + + // READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty" azure:"ro"` + + // READ-ONLY; The private link resource required member names. + RequiredMembers []*string `json:"requiredMembers,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// PrivateLinkResourcesListByRedisCacheOptions contains the optional parameters for the PrivateLinkResources.ListByRedisCache method. +type PrivateLinkResourcesListByRedisCacheOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer and provider. +type PrivateLinkServiceConnectionState struct { + // A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string `json:"actionsRequired,omitempty"` + + // The reason for approval/rejection of the connection. + Description *string `json:"description,omitempty"` + + // Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal() map[string]interface{} { + objectMap := p.Resource.marshalInternal() + return objectMap +} + +// RedisAccessKeys - Redis cache access keys. +type RedisAccessKeys struct { + // READ-ONLY; The current primary key that clients can use to authenticate with Redis cache. + PrimaryKey *string `json:"primaryKey,omitempty" azure:"ro"` + + // READ-ONLY; The current secondary key that clients can use to authenticate with Redis cache. + SecondaryKey *string `json:"secondaryKey,omitempty" azure:"ro"` +} + +// RedisBeginCreateOptions contains the optional parameters for the Redis.BeginCreate method. +type RedisBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// RedisBeginDeleteOptions contains the optional parameters for the Redis.BeginDelete method. +type RedisBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// RedisBeginExportDataOptions contains the optional parameters for the Redis.BeginExportData method. +type RedisBeginExportDataOptions struct { + // placeholder for future optional parameters +} + +// RedisBeginImportDataOptions contains the optional parameters for the Redis.BeginImportData method. +type RedisBeginImportDataOptions struct { + // placeholder for future optional parameters +} + +// RedisCheckNameAvailabilityOptions contains the optional parameters for the Redis.CheckNameAvailability method. +type RedisCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// RedisCommonProperties - Create/Update/Get common properties of the redis cache. +type RedisCommonProperties struct { + // Specifies whether the non-ssl Redis server port (6379) is enabled. + EnableNonSSLPort *bool `json:"enableNonSslPort,omitempty"` + + // Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2') + MinimumTLSVersion *TLSVersion `json:"minimumTlsVersion,omitempty"` + + // Whether or not public endpoint access is allowed for this cache. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', + // private endpoints are the exclusive access method. + // Default value is 'Enabled' + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + + // All Redis Settings. Few possible keys: + // rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value + // etc. + RedisConfiguration map[string]*string `json:"redisConfiguration,omitempty"` + + // Redis version. Only major version will be used in PUT/PATCH request with current valid values: (4, 6) + RedisVersion *string `json:"redisVersion,omitempty"` + + // The number of replicas to be created per primary. + ReplicasPerMaster *int32 `json:"replicasPerMaster,omitempty"` + + // The number of replicas to be created per primary. + ReplicasPerPrimary *int32 `json:"replicasPerPrimary,omitempty"` + + // The number of shards to be created on a Premium Cluster Cache. + ShardCount *int32 `json:"shardCount,omitempty"` + + // A dictionary of tenant settings + TenantSettings map[string]*string `json:"tenantSettings,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisCommonProperties. +func (r RedisCommonProperties) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r RedisCommonProperties) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "enableNonSslPort", r.EnableNonSSLPort) + populate(objectMap, "minimumTlsVersion", r.MinimumTLSVersion) + populate(objectMap, "publicNetworkAccess", r.PublicNetworkAccess) + populate(objectMap, "redisConfiguration", r.RedisConfiguration) + populate(objectMap, "redisVersion", r.RedisVersion) + populate(objectMap, "replicasPerMaster", r.ReplicasPerMaster) + populate(objectMap, "replicasPerPrimary", r.ReplicasPerPrimary) + populate(objectMap, "shardCount", r.ShardCount) + populate(objectMap, "tenantSettings", r.TenantSettings) + return objectMap +} + +// RedisCreateParameters - Parameters supplied to the Create Redis operation. +type RedisCreateParameters struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // REQUIRED; Redis cache properties. + Properties *RedisCreateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // A list of availability zones denoting where the resource needs to come from. + Zones []*string `json:"zones,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisCreateParameters. +func (r RedisCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", r.Location) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "zones", r.Zones) + return json.Marshal(objectMap) +} + +// RedisCreateProperties - Properties supplied to Create Redis operation. +type RedisCreateProperties struct { + RedisCommonProperties + // REQUIRED; The SKU of the Redis cache to deploy. + SKU *SKU `json:"sku,omitempty"` + + // Static IP address. Required when deploying a Redis cache inside an existing Azure Virtual Network. + StaticIP *string `json:"staticIP,omitempty"` + + // The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: + // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 + SubnetID *string `json:"subnetId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisCreateProperties. +func (r RedisCreateProperties) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r RedisCreateProperties) marshalInternal() map[string]interface{} { + objectMap := r.RedisCommonProperties.marshalInternal() + populate(objectMap, "sku", r.SKU) + populate(objectMap, "staticIP", r.StaticIP) + populate(objectMap, "subnetId", r.SubnetID) + return objectMap +} + +// RedisFirewallRule - A firewall rule on a redis cache has a name, and describes a contiguous range of IP addresses permitted to connect +type RedisFirewallRule struct { + ProxyResource + // REQUIRED; redis cache firewall rule properties + Properties *RedisFirewallRuleProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisFirewallRule. +func (r RedisFirewallRule) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r RedisFirewallRule) marshalInternal() map[string]interface{} { + objectMap := r.ProxyResource.marshalInternal() + populate(objectMap, "properties", r.Properties) + return objectMap +} + +// RedisFirewallRuleCreateParameters - Parameters required for creating a firewall rule on redis cache. (Note, you can just use the FirewallRule type instead +// now.) +type RedisFirewallRuleCreateParameters struct { + RedisFirewallRule +} + +// RedisFirewallRuleListResult - The response of list firewall rules Redis operation. +type RedisFirewallRuleListResult struct { + // Results of the list firewall rules operation. + Value []*RedisFirewallRule `json:"value,omitempty"` + + // READ-ONLY; Link for next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisFirewallRuleListResult. +func (r RedisFirewallRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RedisFirewallRuleProperties - Specifies a range of IP addresses permitted to connect to the cache +type RedisFirewallRuleProperties struct { + // REQUIRED; highest IP address included in the range + EndIP *string `json:"endIP,omitempty"` + + // REQUIRED; lowest IP address included in the range + StartIP *string `json:"startIP,omitempty"` +} + +// RedisForceRebootOptions contains the optional parameters for the Redis.ForceReboot method. +type RedisForceRebootOptions struct { + // placeholder for future optional parameters +} + +// RedisForceRebootResponse - Response to force reboot for Redis cache. +type RedisForceRebootResponse struct { + // READ-ONLY; Status message + Message *string `json:"message,omitempty" azure:"ro"` +} + +// RedisGetOptions contains the optional parameters for the Redis.Get method. +type RedisGetOptions struct { + // placeholder for future optional parameters +} + +// RedisInstanceDetails - Details of single instance of redis. +type RedisInstanceDetails struct { + // READ-ONLY; Specifies whether the instance is a primary node. + IsMaster *bool `json:"isMaster,omitempty" azure:"ro"` + + // READ-ONLY; Specifies whether the instance is a primary node. + IsPrimary *bool `json:"isPrimary,omitempty" azure:"ro"` + + // READ-ONLY; If enableNonSslPort is true, provides Redis instance Non-SSL port. + NonSSLPort *int32 `json:"nonSslPort,omitempty" azure:"ro"` + + // READ-ONLY; Redis instance SSL port. + SSLPort *int32 `json:"sslPort,omitempty" azure:"ro"` + + // READ-ONLY; If clustering is enabled, the Shard ID of Redis Instance + ShardID *int32 `json:"shardId,omitempty" azure:"ro"` + + // READ-ONLY; If the Cache uses availability zones, specifies availability zone where this instance is located. + Zone *string `json:"zone,omitempty" azure:"ro"` +} + +// RedisLinkedServer - Linked server Id +type RedisLinkedServer struct { + // READ-ONLY; Linked server Id. + ID *string `json:"id,omitempty" azure:"ro"` +} + +// RedisLinkedServerCreateParameters - Parameter required for creating a linked server to redis cache. +type RedisLinkedServerCreateParameters struct { + // REQUIRED; Properties required to create a linked server. + Properties *RedisLinkedServerCreateProperties `json:"properties,omitempty"` +} + +// RedisLinkedServerCreateProperties - Create properties for a linked server +type RedisLinkedServerCreateProperties struct { + // REQUIRED; Fully qualified resourceId of the linked redis cache. + LinkedRedisCacheID *string `json:"linkedRedisCacheId,omitempty"` + + // REQUIRED; Location of the linked redis cache. + LinkedRedisCacheLocation *string `json:"linkedRedisCacheLocation,omitempty"` + + // REQUIRED; Role of the linked server. + ServerRole *ReplicationRole `json:"serverRole,omitempty"` +} + +// RedisLinkedServerProperties - Properties of a linked server to be returned in get/put response +type RedisLinkedServerProperties struct { + RedisLinkedServerCreateProperties + // READ-ONLY; Terminal state of the link between primary and secondary redis cache. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// RedisLinkedServerWithProperties - Response to put/get linked server (with properties) for Redis cache. +type RedisLinkedServerWithProperties struct { + ProxyResource + // Properties of the linked server. + Properties *RedisLinkedServerProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisLinkedServerWithProperties. +func (r RedisLinkedServerWithProperties) MarshalJSON() ([]byte, error) { + objectMap := r.ProxyResource.marshalInternal() + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// RedisLinkedServerWithPropertiesList - List of linked servers (with properties) of a Redis cache. +type RedisLinkedServerWithPropertiesList struct { + // List of linked servers (with properties) of a Redis cache. + Value []*RedisLinkedServerWithProperties `json:"value,omitempty"` + + // READ-ONLY; Link for next set. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisLinkedServerWithPropertiesList. +func (r RedisLinkedServerWithPropertiesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RedisListByResourceGroupOptions contains the optional parameters for the Redis.ListByResourceGroup method. +type RedisListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// RedisListBySubscriptionOptions contains the optional parameters for the Redis.ListBySubscription method. +type RedisListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// RedisListKeysOptions contains the optional parameters for the Redis.ListKeys method. +type RedisListKeysOptions struct { + // placeholder for future optional parameters +} + +// RedisListResult - The response of list Redis operation. +type RedisListResult struct { + // List of Redis cache instances. + Value []*RedisResource `json:"value,omitempty"` + + // READ-ONLY; Link for next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisListResult. +func (r RedisListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RedisListUpgradeNotificationsOptions contains the optional parameters for the Redis.ListUpgradeNotifications method. +type RedisListUpgradeNotificationsOptions struct { + // placeholder for future optional parameters +} + +// RedisPatchSchedule - Response to put/get patch schedules for Redis cache. +type RedisPatchSchedule struct { + ProxyResource + // REQUIRED; List of patch schedules for a Redis cache. + Properties *ScheduleEntries `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisPatchSchedule. +func (r RedisPatchSchedule) MarshalJSON() ([]byte, error) { + objectMap := r.ProxyResource.marshalInternal() + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// RedisPatchScheduleListResult - The response of list patch schedules Redis operation. +type RedisPatchScheduleListResult struct { + // Results of the list patch schedules operation. + Value []*RedisPatchSchedule `json:"value,omitempty"` + + // READ-ONLY; Link for next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisPatchScheduleListResult. +func (r RedisPatchScheduleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RedisProperties - Properties of the redis cache. +type RedisProperties struct { + RedisCreateProperties + // READ-ONLY; The keys of the Redis cache - not set if this object is not the response to Create or Update redis cache + AccessKeys *RedisAccessKeys `json:"accessKeys,omitempty" azure:"ro"` + + // READ-ONLY; Redis host name. + HostName *string `json:"hostName,omitempty" azure:"ro"` + + // READ-ONLY; List of the Redis instances associated with the cache + Instances []*RedisInstanceDetails `json:"instances,omitempty" azure:"ro"` + + // READ-ONLY; List of the linked servers associated with the cache + LinkedServers []*RedisLinkedServer `json:"linkedServers,omitempty" azure:"ro"` + + // READ-ONLY; Redis non-SSL port. + Port *int32 `json:"port,omitempty" azure:"ro"` + + // READ-ONLY; List of private endpoint connection associated with the specified redis cache + PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + + // READ-ONLY; Redis instance provisioning status. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Redis SSL port. + SSLPort *int32 `json:"sslPort,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisProperties. +func (r RedisProperties) MarshalJSON() ([]byte, error) { + objectMap := r.RedisCreateProperties.marshalInternal() + populate(objectMap, "accessKeys", r.AccessKeys) + populate(objectMap, "hostName", r.HostName) + populate(objectMap, "instances", r.Instances) + populate(objectMap, "linkedServers", r.LinkedServers) + populate(objectMap, "port", r.Port) + populate(objectMap, "privateEndpointConnections", r.PrivateEndpointConnections) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "sslPort", r.SSLPort) + return json.Marshal(objectMap) +} + +// RedisRebootParameters - Specifies which Redis node(s) to reboot. +type RedisRebootParameters struct { + // A list of redis instances to reboot, specified by per-instance SSL ports or non-SSL ports. + Ports []*int32 `json:"ports,omitempty"` + + // Which Redis node(s) to reboot. Depending on this value data loss is possible. + RebootType *RebootType `json:"rebootType,omitempty"` + + // If clustering is enabled, the ID of the shard to be rebooted. + ShardID *int32 `json:"shardId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisRebootParameters. +func (r RedisRebootParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "ports", r.Ports) + populate(objectMap, "rebootType", r.RebootType) + populate(objectMap, "shardId", r.ShardID) + return json.Marshal(objectMap) +} + +// RedisRegenerateKeyOptions contains the optional parameters for the Redis.RegenerateKey method. +type RedisRegenerateKeyOptions struct { + // placeholder for future optional parameters +} + +// RedisRegenerateKeyParameters - Specifies which Redis access keys to reset. +type RedisRegenerateKeyParameters struct { + // REQUIRED; The Redis access key to regenerate. + KeyType *RedisKeyType `json:"keyType,omitempty"` +} + +// RedisResource - A single Redis item in List or Get Operation. +type RedisResource struct { + TrackedResource + // REQUIRED; Redis cache properties. + Properties *RedisProperties `json:"properties,omitempty"` + + // A list of availability zones denoting where the resource needs to come from. + Zones []*string `json:"zones,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisResource. +func (r RedisResource) MarshalJSON() ([]byte, error) { + objectMap := r.TrackedResource.marshalInternal() + populate(objectMap, "properties", r.Properties) + populate(objectMap, "zones", r.Zones) + return json.Marshal(objectMap) +} + +// RedisUpdateOptions contains the optional parameters for the Redis.Update method. +type RedisUpdateOptions struct { + // placeholder for future optional parameters +} + +// RedisUpdateParameters - Parameters supplied to the Update Redis operation. +type RedisUpdateParameters struct { + // Redis cache properties. + Properties *RedisUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisUpdateParameters. +func (r RedisUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// RedisUpdateProperties - Patchable properties of the redis cache. +type RedisUpdateProperties struct { + RedisCommonProperties + // The SKU of the Redis cache to deploy. + SKU *SKU `json:"sku,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RedisUpdateProperties. +func (r RedisUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := r.RedisCommonProperties.marshalInternal() + populate(objectMap, "sku", r.SKU) + return json.Marshal(objectMap) +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return objectMap +} + +// SKU parameters supplied to the create Redis operation. +type SKU struct { + // REQUIRED; The size of the Redis cache to deploy. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, + // 4). + Capacity *int32 `json:"capacity,omitempty"` + + // REQUIRED; The SKU family to use. Valid values: (C, P). (C = Basic/Standard, P = Premium). + Family *SKUFamily `json:"family,omitempty"` + + // REQUIRED; The type of Redis cache to deploy. Valid values: (Basic, Standard, Premium) + Name *SKUName `json:"name,omitempty"` +} + +// ScheduleEntries - List of patch schedules for a Redis cache. +type ScheduleEntries struct { + // REQUIRED; List of patch schedules for a Redis cache. + ScheduleEntries []*ScheduleEntry `json:"scheduleEntries,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScheduleEntries. +func (s ScheduleEntries) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "scheduleEntries", s.ScheduleEntries) + return json.Marshal(objectMap) +} + +// ScheduleEntry - Patch schedule entry for a Premium Redis Cache. +type ScheduleEntry struct { + // REQUIRED; Day of the week when a cache can be patched. + DayOfWeek *DayOfWeek `json:"dayOfWeek,omitempty"` + + // REQUIRED; Start hour after which cache patching can start. + StartHourUTC *int32 `json:"startHourUtc,omitempty"` + + // ISO8601 timespan specifying how much time cache patching can take. + MaintenanceWindow *string `json:"maintenanceWindow,omitempty"` +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := t.marshalInternal() + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal() map[string]interface{} { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) + return objectMap +} + +// UpgradeNotification - Properties of upgrade notification. +type UpgradeNotification struct { + // READ-ONLY; Name of upgrade notification. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Timestamp when upgrade notification occurred. + Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` + + // READ-ONLY; Details about this upgrade notification + UpsellNotification map[string]*string `json:"upsellNotification,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type UpgradeNotification. +func (u UpgradeNotification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", u.Name) + populate(objectMap, "timestamp", (*timeRFC3339)(u.Timestamp)) + populate(objectMap, "upsellNotification", u.UpsellNotification) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpgradeNotification. +func (u *UpgradeNotification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, &u.Name) + delete(rawMsg, key) + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + u.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "upsellNotification": + err = unpopulate(val, &u.UpsellNotification) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/redis/armredis/zz_generated_operations_client.go b/sdk/redis/armredis/zz_generated_operations_client.go new file mode 100644 index 000000000000..56bddc34057d --- /dev/null +++ b/sdk/redis/armredis/zz_generated_operations_client.go @@ -0,0 +1,78 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + con *armcore.Connection +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(con *armcore.Connection) *OperationsClient { + return &OperationsClient{con: con} +} + +// List - Lists all of the available REST API operations of the Microsoft.Cache provider. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) OperationsListPager { + return &operationsListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.Cache/operations" + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *azcore.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.OperationListResult); err != nil { + return OperationsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/redis/armredis/zz_generated_pagers.go b/sdk/redis/armredis/zz_generated_pagers.go new file mode 100644 index 000000000000..64dbf638d1d8 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_pagers.go @@ -0,0 +1,400 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "reflect" +) + +type FirewallRulesListPager interface { + azcore.Pager + // PageResponse returns the current FirewallRulesListResponse. + PageResponse() FirewallRulesListResponse +} + +type firewallRulesListPager struct { + client *FirewallRulesClient + current FirewallRulesListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, FirewallRulesListResponse) (*azcore.Request, error) +} + +func (p *firewallRulesListPager) Err() error { + return p.err +} + +func (p *firewallRulesListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RedisFirewallRuleListResult.NextLink == nil || len(*p.current.RedisFirewallRuleListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *firewallRulesListPager) PageResponse() FirewallRulesListResponse { + return p.current +} + +type LinkedServerListPager interface { + azcore.Pager + // PageResponse returns the current LinkedServerListResponse. + PageResponse() LinkedServerListResponse +} + +type linkedServerListPager struct { + client *LinkedServerClient + current LinkedServerListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, LinkedServerListResponse) (*azcore.Request, error) +} + +func (p *linkedServerListPager) Err() error { + return p.err +} + +func (p *linkedServerListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RedisLinkedServerWithPropertiesList.NextLink == nil || len(*p.current.RedisLinkedServerWithPropertiesList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *linkedServerListPager) PageResponse() LinkedServerListResponse { + return p.current +} + +type OperationsListPager interface { + azcore.Pager + // PageResponse returns the current OperationsListResponse. + PageResponse() OperationsListResponse +} + +type operationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, OperationsListResponse) (*azcore.Request, error) +} + +func (p *operationsListPager) Err() error { + return p.err +} + +func (p *operationsListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *operationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +type PatchSchedulesListByRedisResourcePager interface { + azcore.Pager + // PageResponse returns the current PatchSchedulesListByRedisResourceResponse. + PageResponse() PatchSchedulesListByRedisResourceResponse +} + +type patchSchedulesListByRedisResourcePager struct { + client *PatchSchedulesClient + current PatchSchedulesListByRedisResourceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, PatchSchedulesListByRedisResourceResponse) (*azcore.Request, error) +} + +func (p *patchSchedulesListByRedisResourcePager) Err() error { + return p.err +} + +func (p *patchSchedulesListByRedisResourcePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RedisPatchScheduleListResult.NextLink == nil || len(*p.current.RedisPatchScheduleListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByRedisResourceHandleError(resp) + return false + } + result, err := p.client.listByRedisResourceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *patchSchedulesListByRedisResourcePager) PageResponse() PatchSchedulesListByRedisResourceResponse { + return p.current +} + +type RedisListByResourceGroupPager interface { + azcore.Pager + // PageResponse returns the current RedisListByResourceGroupResponse. + PageResponse() RedisListByResourceGroupResponse +} + +type redisListByResourceGroupPager struct { + client *RedisClient + current RedisListByResourceGroupResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, RedisListByResourceGroupResponse) (*azcore.Request, error) +} + +func (p *redisListByResourceGroupPager) Err() error { + return p.err +} + +func (p *redisListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RedisListResult.NextLink == nil || len(*p.current.RedisListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *redisListByResourceGroupPager) PageResponse() RedisListByResourceGroupResponse { + return p.current +} + +type RedisListBySubscriptionPager interface { + azcore.Pager + // PageResponse returns the current RedisListBySubscriptionResponse. + PageResponse() RedisListBySubscriptionResponse +} + +type redisListBySubscriptionPager struct { + client *RedisClient + current RedisListBySubscriptionResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, RedisListBySubscriptionResponse) (*azcore.Request, error) +} + +func (p *redisListBySubscriptionPager) Err() error { + return p.err +} + +func (p *redisListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RedisListResult.NextLink == nil || len(*p.current.RedisListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *redisListBySubscriptionPager) PageResponse() RedisListBySubscriptionResponse { + return p.current +} + +type RedisListUpgradeNotificationsPager interface { + azcore.Pager + // PageResponse returns the current RedisListUpgradeNotificationsResponse. + PageResponse() RedisListUpgradeNotificationsResponse +} + +type redisListUpgradeNotificationsPager struct { + client *RedisClient + current RedisListUpgradeNotificationsResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, RedisListUpgradeNotificationsResponse) (*azcore.Request, error) +} + +func (p *redisListUpgradeNotificationsPager) Err() error { + return p.err +} + +func (p *redisListUpgradeNotificationsPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.NotificationListResponse.NextLink == nil || len(*p.current.NotificationListResponse.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listUpgradeNotificationsHandleError(resp) + return false + } + result, err := p.client.listUpgradeNotificationsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *redisListUpgradeNotificationsPager) PageResponse() RedisListUpgradeNotificationsResponse { + return p.current +} diff --git a/sdk/redis/armredis/zz_generated_patchschedules_client.go b/sdk/redis/armredis/zz_generated_patchschedules_client.go new file mode 100644 index 000000000000..4dc86de656f3 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_patchschedules_client.go @@ -0,0 +1,295 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// PatchSchedulesClient contains the methods for the PatchSchedules group. +// Don't use this type directly, use NewPatchSchedulesClient() instead. +type PatchSchedulesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPatchSchedulesClient creates a new instance of PatchSchedulesClient with the specified values. +func NewPatchSchedulesClient(con *armcore.Connection, subscriptionID string) *PatchSchedulesClient { + return &PatchSchedulesClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or replace the patching schedule for Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PatchSchedulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, name string, defaultParam DefaultName, parameters RedisPatchSchedule, options *PatchSchedulesCreateOrUpdateOptions) (PatchSchedulesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, name, defaultParam, parameters, options) + if err != nil { + return PatchSchedulesCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PatchSchedulesCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return PatchSchedulesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PatchSchedulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, name string, defaultParam DefaultName, parameters RedisPatchSchedule, options *PatchSchedulesCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/patchSchedules/{default}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if defaultParam == "" { + return nil, errors.New("parameter defaultParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{default}", url.PathEscape(string(defaultParam))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PatchSchedulesClient) createOrUpdateHandleResponse(resp *azcore.Response) (PatchSchedulesCreateOrUpdateResponse, error) { + result := PatchSchedulesCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisPatchSchedule); err != nil { + return PatchSchedulesCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PatchSchedulesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the patching schedule of a redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PatchSchedulesClient) Delete(ctx context.Context, resourceGroupName string, name string, defaultParam DefaultName, options *PatchSchedulesDeleteOptions) (PatchSchedulesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, name, defaultParam, options) + if err != nil { + return PatchSchedulesDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PatchSchedulesDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return PatchSchedulesDeleteResponse{}, client.deleteHandleError(resp) + } + return PatchSchedulesDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PatchSchedulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, name string, defaultParam DefaultName, options *PatchSchedulesDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/patchSchedules/{default}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if defaultParam == "" { + return nil, errors.New("parameter defaultParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{default}", url.PathEscape(string(defaultParam))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PatchSchedulesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the patching schedule of a redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PatchSchedulesClient) Get(ctx context.Context, resourceGroupName string, name string, defaultParam DefaultName, options *PatchSchedulesGetOptions) (PatchSchedulesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, name, defaultParam, options) + if err != nil { + return PatchSchedulesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PatchSchedulesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PatchSchedulesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PatchSchedulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, name string, defaultParam DefaultName, options *PatchSchedulesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/patchSchedules/{default}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if defaultParam == "" { + return nil, errors.New("parameter defaultParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{default}", url.PathEscape(string(defaultParam))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PatchSchedulesClient) getHandleResponse(resp *azcore.Response) (PatchSchedulesGetResponse, error) { + result := PatchSchedulesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisPatchSchedule); err != nil { + return PatchSchedulesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PatchSchedulesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByRedisResource - Gets all patch schedules in the specified redis cache (there is only one). +// If the operation fails it returns the *ErrorResponse error type. +func (client *PatchSchedulesClient) ListByRedisResource(resourceGroupName string, cacheName string, options *PatchSchedulesListByRedisResourceOptions) PatchSchedulesListByRedisResourcePager { + return &patchSchedulesListByRedisResourcePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByRedisResourceCreateRequest(ctx, resourceGroupName, cacheName, options) + }, + advancer: func(ctx context.Context, resp PatchSchedulesListByRedisResourceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RedisPatchScheduleListResult.NextLink) + }, + } +} + +// listByRedisResourceCreateRequest creates the ListByRedisResource request. +func (client *PatchSchedulesClient) listByRedisResourceCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *PatchSchedulesListByRedisResourceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/patchSchedules" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByRedisResourceHandleResponse handles the ListByRedisResource response. +func (client *PatchSchedulesClient) listByRedisResourceHandleResponse(resp *azcore.Response) (PatchSchedulesListByRedisResourceResponse, error) { + result := PatchSchedulesListByRedisResourceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisPatchScheduleListResult); err != nil { + return PatchSchedulesListByRedisResourceResponse{}, err + } + return result, nil +} + +// listByRedisResourceHandleError handles the ListByRedisResource error response. +func (client *PatchSchedulesClient) listByRedisResourceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/redis/armredis/zz_generated_pollers.go b/sdk/redis/armredis/zz_generated_pollers.go new file mode 100644 index 000000000000..cb874359c2fb --- /dev/null +++ b/sdk/redis/armredis/zz_generated_pollers.go @@ -0,0 +1,286 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "time" +) + +// LinkedServerCreatePoller provides polling facilities until the operation reaches a terminal state. +type LinkedServerCreatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final LinkedServerCreateResponse will be returned. + FinalResponse(ctx context.Context) (LinkedServerCreateResponse, error) +} + +type linkedServerCreatePoller struct { + pt *armcore.LROPoller +} + +func (p *linkedServerCreatePoller) Done() bool { + return p.pt.Done() +} + +func (p *linkedServerCreatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *linkedServerCreatePoller) FinalResponse(ctx context.Context) (LinkedServerCreateResponse, error) { + respType := LinkedServerCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.RedisLinkedServerWithProperties) + if err != nil { + return LinkedServerCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *linkedServerCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *linkedServerCreatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (LinkedServerCreateResponse, error) { + respType := LinkedServerCreateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.RedisLinkedServerWithProperties) + if err != nil { + return LinkedServerCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// PrivateEndpointConnectionsPutPoller provides polling facilities until the operation reaches a terminal state. +type PrivateEndpointConnectionsPutPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final PrivateEndpointConnectionsPutResponse will be returned. + FinalResponse(ctx context.Context) (PrivateEndpointConnectionsPutResponse, error) +} + +type privateEndpointConnectionsPutPoller struct { + pt *armcore.LROPoller +} + +func (p *privateEndpointConnectionsPutPoller) Done() bool { + return p.pt.Done() +} + +func (p *privateEndpointConnectionsPutPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *privateEndpointConnectionsPutPoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionsPutResponse, error) { + respType := PrivateEndpointConnectionsPutResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionsPutResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *privateEndpointConnectionsPutPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *privateEndpointConnectionsPutPoller) pollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionsPutResponse, error) { + respType := PrivateEndpointConnectionsPutResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionsPutResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// RedisCreatePoller provides polling facilities until the operation reaches a terminal state. +type RedisCreatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final RedisCreateResponse will be returned. + FinalResponse(ctx context.Context) (RedisCreateResponse, error) +} + +type redisCreatePoller struct { + pt *armcore.LROPoller +} + +func (p *redisCreatePoller) Done() bool { + return p.pt.Done() +} + +func (p *redisCreatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *redisCreatePoller) FinalResponse(ctx context.Context) (RedisCreateResponse, error) { + respType := RedisCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.RedisResource) + if err != nil { + return RedisCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *redisCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *redisCreatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (RedisCreateResponse, error) { + respType := RedisCreateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.RedisResource) + if err != nil { + return RedisCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// RedisDeletePoller provides polling facilities until the operation reaches a terminal state. +type RedisDeletePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final RedisDeleteResponse will be returned. + FinalResponse(ctx context.Context) (RedisDeleteResponse, error) +} + +type redisDeletePoller struct { + pt *armcore.LROPoller +} + +func (p *redisDeletePoller) Done() bool { + return p.pt.Done() +} + +func (p *redisDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *redisDeletePoller) FinalResponse(ctx context.Context) (RedisDeleteResponse, error) { + respType := RedisDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return RedisDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *redisDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *redisDeletePoller) pollUntilDone(ctx context.Context, freq time.Duration) (RedisDeleteResponse, error) { + respType := RedisDeleteResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return RedisDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// RedisExportDataPoller provides polling facilities until the operation reaches a terminal state. +type RedisExportDataPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final RedisExportDataResponse will be returned. + FinalResponse(ctx context.Context) (RedisExportDataResponse, error) +} + +type redisExportDataPoller struct { + pt *armcore.LROPoller +} + +func (p *redisExportDataPoller) Done() bool { + return p.pt.Done() +} + +func (p *redisExportDataPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *redisExportDataPoller) FinalResponse(ctx context.Context) (RedisExportDataResponse, error) { + respType := RedisExportDataResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return RedisExportDataResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *redisExportDataPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *redisExportDataPoller) pollUntilDone(ctx context.Context, freq time.Duration) (RedisExportDataResponse, error) { + respType := RedisExportDataResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return RedisExportDataResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// RedisImportDataPoller provides polling facilities until the operation reaches a terminal state. +type RedisImportDataPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final RedisImportDataResponse will be returned. + FinalResponse(ctx context.Context) (RedisImportDataResponse, error) +} + +type redisImportDataPoller struct { + pt *armcore.LROPoller +} + +func (p *redisImportDataPoller) Done() bool { + return p.pt.Done() +} + +func (p *redisImportDataPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *redisImportDataPoller) FinalResponse(ctx context.Context) (RedisImportDataResponse, error) { + respType := RedisImportDataResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return RedisImportDataResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *redisImportDataPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *redisImportDataPoller) pollUntilDone(ctx context.Context, freq time.Duration) (RedisImportDataResponse, error) { + respType := RedisImportDataResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return RedisImportDataResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} diff --git a/sdk/redis/armredis/zz_generated_privateendpointconnections_client.go b/sdk/redis/armredis/zz_generated_privateendpointconnections_client.go new file mode 100644 index 000000000000..5c5340eabf74 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_privateendpointconnections_client.go @@ -0,0 +1,338 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. +// Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. +type PrivateEndpointConnectionsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. +func NewPrivateEndpointConnectionsClient(con *armcore.Connection, subscriptionID string) *PrivateEndpointConnectionsClient { + return &PrivateEndpointConnectionsClient{con: con, subscriptionID: subscriptionID} +} + +// Delete - Deletes the specified private endpoint connection associated with the redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, cacheName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsDeleteOptions) (PrivateEndpointConnectionsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, cacheName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionsDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionsDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return PrivateEndpointConnectionsDeleteResponse{}, client.deleteHandleError(resp) + } + return PrivateEndpointConnectionsDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateEndpointConnections/{privateEndpointConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateEndpointConnectionsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the specified private endpoint connection associated with the redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, cacheName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, cacheName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateEndpointConnectionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateEndpointConnections/{privateEndpointConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionsGetResponse, error) { + result := PrivateEndpointConnectionsGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PrivateEndpointConnection); err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateEndpointConnectionsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - List all the private endpoint connections associated with the redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, cacheName string, options *PrivateEndpointConnectionsListOptions) (PrivateEndpointConnectionsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateEndpointConnectionsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *PrivateEndpointConnectionsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateEndpointConnections" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionsListResponse, error) { + result := PrivateEndpointConnectionsListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PrivateEndpointConnectionListResult); err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateEndpointConnectionsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginPut - Update the state of specified private endpoint connection associated with the redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) BeginPut(ctx context.Context, resourceGroupName string, cacheName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginPutOptions) (PrivateEndpointConnectionsPutPollerResponse, error) { + resp, err := client.put(ctx, resourceGroupName, cacheName, privateEndpointConnectionName, properties, options) + if err != nil { + return PrivateEndpointConnectionsPutPollerResponse{}, err + } + result := PrivateEndpointConnectionsPutPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PrivateEndpointConnectionsClient.Put", "", resp, client.con.Pipeline(), client.putHandleError) + if err != nil { + return PrivateEndpointConnectionsPutPollerResponse{}, err + } + poller := &privateEndpointConnectionsPutPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionsPutResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumePut creates a new PrivateEndpointConnectionsPutPoller from the specified resume token. +// token - The value must come from a previous call to PrivateEndpointConnectionsPutPoller.ResumeToken(). +func (client *PrivateEndpointConnectionsClient) ResumePut(ctx context.Context, token string) (PrivateEndpointConnectionsPutPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PrivateEndpointConnectionsClient.Put", token, client.con.Pipeline(), client.putHandleError) + if err != nil { + return PrivateEndpointConnectionsPutPollerResponse{}, err + } + poller := &privateEndpointConnectionsPutPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return PrivateEndpointConnectionsPutPollerResponse{}, err + } + result := PrivateEndpointConnectionsPutPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionsPutResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Put - Update the state of specified private endpoint connection associated with the redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) put(ctx context.Context, resourceGroupName string, cacheName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginPutOptions) (*azcore.Response, error) { + req, err := client.putCreateRequest(ctx, resourceGroupName, cacheName, privateEndpointConnectionName, properties, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusCreated) { + return nil, client.putHandleError(resp) + } + return resp, nil +} + +// putCreateRequest creates the Put request. +func (client *PrivateEndpointConnectionsClient) putCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginPutOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateEndpointConnections/{privateEndpointConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(properties) +} + +// putHandleError handles the Put error response. +func (client *PrivateEndpointConnectionsClient) putHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/redis/armredis/zz_generated_privatelinkresources_client.go b/sdk/redis/armredis/zz_generated_privatelinkresources_client.go new file mode 100644 index 000000000000..502cb9b50f63 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_privatelinkresources_client.go @@ -0,0 +1,97 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. +// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. +type PrivateLinkResourcesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. +func NewPrivateLinkResourcesClient(con *armcore.Connection, subscriptionID string) *PrivateLinkResourcesClient { + return &PrivateLinkResourcesClient{con: con, subscriptionID: subscriptionID} +} + +// ListByRedisCache - Gets the private link resources that need to be created for a redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateLinkResourcesClient) ListByRedisCache(ctx context.Context, resourceGroupName string, cacheName string, options *PrivateLinkResourcesListByRedisCacheOptions) (PrivateLinkResourcesListByRedisCacheResponse, error) { + req, err := client.listByRedisCacheCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return PrivateLinkResourcesListByRedisCacheResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PrivateLinkResourcesListByRedisCacheResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateLinkResourcesListByRedisCacheResponse{}, client.listByRedisCacheHandleError(resp) + } + return client.listByRedisCacheHandleResponse(resp) +} + +// listByRedisCacheCreateRequest creates the ListByRedisCache request. +func (client *PrivateLinkResourcesClient) listByRedisCacheCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *PrivateLinkResourcesListByRedisCacheOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateLinkResources" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByRedisCacheHandleResponse handles the ListByRedisCache response. +func (client *PrivateLinkResourcesClient) listByRedisCacheHandleResponse(resp *azcore.Response) (PrivateLinkResourcesListByRedisCacheResponse, error) { + result := PrivateLinkResourcesListByRedisCacheResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PrivateLinkResourceListResult); err != nil { + return PrivateLinkResourcesListByRedisCacheResponse{}, err + } + return result, nil +} + +// listByRedisCacheHandleError handles the ListByRedisCache error response. +func (client *PrivateLinkResourcesClient) listByRedisCacheHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/redis/armredis/zz_generated_redis_client.go b/sdk/redis/armredis/zz_generated_redis_client.go new file mode 100644 index 000000000000..04c9c7fd6635 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_redis_client.go @@ -0,0 +1,1010 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// RedisClient contains the methods for the Redis group. +// Don't use this type directly, use NewRedisClient() instead. +type RedisClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewRedisClient creates a new instance of RedisClient with the specified values. +func NewRedisClient(con *armcore.Connection, subscriptionID string) *RedisClient { + return &RedisClient{con: con, subscriptionID: subscriptionID} +} + +// CheckNameAvailability - Checks that the redis cache name is valid and is not already in use. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) CheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityParameters, options *RedisCheckNameAvailabilityOptions) (RedisCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, parameters, options) + if err != nil { + return RedisCheckNameAvailabilityResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RedisCheckNameAvailabilityResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RedisCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return RedisCheckNameAvailabilityResponse{RawResponse: resp.Response}, nil +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *RedisClient) checkNameAvailabilityCreateRequest(ctx context.Context, parameters CheckNameAvailabilityParameters, options *RedisCheckNameAvailabilityOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/CheckNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *RedisClient) checkNameAvailabilityHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginCreate - Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) BeginCreate(ctx context.Context, resourceGroupName string, name string, parameters RedisCreateParameters, options *RedisBeginCreateOptions) (RedisCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return RedisCreatePollerResponse{}, err + } + result := RedisCreatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RedisClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return RedisCreatePollerResponse{}, err + } + poller := &redisCreatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RedisCreateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new RedisCreatePoller from the specified resume token. +// token - The value must come from a previous call to RedisCreatePoller.ResumeToken(). +func (client *RedisClient) ResumeCreate(ctx context.Context, token string) (RedisCreatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RedisClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return RedisCreatePollerResponse{}, err + } + poller := &redisCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return RedisCreatePollerResponse{}, err + } + result := RedisCreatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RedisCreateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) create(ctx context.Context, resourceGroupName string, name string, parameters RedisCreateParameters, options *RedisBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *RedisClient) createCreateRequest(ctx context.Context, resourceGroupName string, name string, parameters RedisCreateParameters, options *RedisBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createHandleError handles the Create error response. +func (client *RedisClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) BeginDelete(ctx context.Context, resourceGroupName string, name string, options *RedisBeginDeleteOptions) (RedisDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, name, options) + if err != nil { + return RedisDeletePollerResponse{}, err + } + result := RedisDeletePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RedisClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return RedisDeletePollerResponse{}, err + } + poller := &redisDeletePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RedisDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new RedisDeletePoller from the specified resume token. +// token - The value must come from a previous call to RedisDeletePoller.ResumeToken(). +func (client *RedisClient) ResumeDelete(ctx context.Context, token string) (RedisDeletePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RedisClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return RedisDeletePollerResponse{}, err + } + poller := &redisDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return RedisDeletePollerResponse{}, err + } + result := RedisDeletePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RedisDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) deleteOperation(ctx context.Context, resourceGroupName string, name string, options *RedisBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, name, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *RedisClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, name string, options *RedisBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *RedisClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginExportData - Export data from the redis cache to blobs in a container. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) BeginExportData(ctx context.Context, resourceGroupName string, name string, parameters ExportRDBParameters, options *RedisBeginExportDataOptions) (RedisExportDataPollerResponse, error) { + resp, err := client.exportData(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return RedisExportDataPollerResponse{}, err + } + result := RedisExportDataPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RedisClient.ExportData", "", resp, client.con.Pipeline(), client.exportDataHandleError) + if err != nil { + return RedisExportDataPollerResponse{}, err + } + poller := &redisExportDataPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RedisExportDataResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeExportData creates a new RedisExportDataPoller from the specified resume token. +// token - The value must come from a previous call to RedisExportDataPoller.ResumeToken(). +func (client *RedisClient) ResumeExportData(ctx context.Context, token string) (RedisExportDataPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RedisClient.ExportData", token, client.con.Pipeline(), client.exportDataHandleError) + if err != nil { + return RedisExportDataPollerResponse{}, err + } + poller := &redisExportDataPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return RedisExportDataPollerResponse{}, err + } + result := RedisExportDataPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RedisExportDataResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ExportData - Export data from the redis cache to blobs in a container. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) exportData(ctx context.Context, resourceGroupName string, name string, parameters ExportRDBParameters, options *RedisBeginExportDataOptions) (*azcore.Response, error) { + req, err := client.exportDataCreateRequest(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.exportDataHandleError(resp) + } + return resp, nil +} + +// exportDataCreateRequest creates the ExportData request. +func (client *RedisClient) exportDataCreateRequest(ctx context.Context, resourceGroupName string, name string, parameters ExportRDBParameters, options *RedisBeginExportDataOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/export" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// exportDataHandleError handles the ExportData error response. +func (client *RedisClient) exportDataHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ForceReboot - Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) ForceReboot(ctx context.Context, resourceGroupName string, name string, parameters RedisRebootParameters, options *RedisForceRebootOptions) (RedisForceRebootResponseEnvelope, error) { + req, err := client.forceRebootCreateRequest(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return RedisForceRebootResponseEnvelope{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RedisForceRebootResponseEnvelope{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RedisForceRebootResponseEnvelope{}, client.forceRebootHandleError(resp) + } + return client.forceRebootHandleResponse(resp) +} + +// forceRebootCreateRequest creates the ForceReboot request. +func (client *RedisClient) forceRebootCreateRequest(ctx context.Context, resourceGroupName string, name string, parameters RedisRebootParameters, options *RedisForceRebootOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/forceReboot" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// forceRebootHandleResponse handles the ForceReboot response. +func (client *RedisClient) forceRebootHandleResponse(resp *azcore.Response) (RedisForceRebootResponseEnvelope, error) { + result := RedisForceRebootResponseEnvelope{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisForceRebootResponse); err != nil { + return RedisForceRebootResponseEnvelope{}, err + } + return result, nil +} + +// forceRebootHandleError handles the ForceReboot error response. +func (client *RedisClient) forceRebootHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets a Redis cache (resource description). +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) Get(ctx context.Context, resourceGroupName string, name string, options *RedisGetOptions) (RedisGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, name, options) + if err != nil { + return RedisGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RedisGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RedisGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *RedisClient) getCreateRequest(ctx context.Context, resourceGroupName string, name string, options *RedisGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RedisClient) getHandleResponse(resp *azcore.Response) (RedisGetResponse, error) { + result := RedisGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisResource); err != nil { + return RedisGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *RedisClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginImportData - Import data into Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) BeginImportData(ctx context.Context, resourceGroupName string, name string, parameters ImportRDBParameters, options *RedisBeginImportDataOptions) (RedisImportDataPollerResponse, error) { + resp, err := client.importData(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return RedisImportDataPollerResponse{}, err + } + result := RedisImportDataPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RedisClient.ImportData", "", resp, client.con.Pipeline(), client.importDataHandleError) + if err != nil { + return RedisImportDataPollerResponse{}, err + } + poller := &redisImportDataPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RedisImportDataResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeImportData creates a new RedisImportDataPoller from the specified resume token. +// token - The value must come from a previous call to RedisImportDataPoller.ResumeToken(). +func (client *RedisClient) ResumeImportData(ctx context.Context, token string) (RedisImportDataPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RedisClient.ImportData", token, client.con.Pipeline(), client.importDataHandleError) + if err != nil { + return RedisImportDataPollerResponse{}, err + } + poller := &redisImportDataPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return RedisImportDataPollerResponse{}, err + } + result := RedisImportDataPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RedisImportDataResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ImportData - Import data into Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) importData(ctx context.Context, resourceGroupName string, name string, parameters ImportRDBParameters, options *RedisBeginImportDataOptions) (*azcore.Response, error) { + req, err := client.importDataCreateRequest(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.importDataHandleError(resp) + } + return resp, nil +} + +// importDataCreateRequest creates the ImportData request. +func (client *RedisClient) importDataCreateRequest(ctx context.Context, resourceGroupName string, name string, parameters ImportRDBParameters, options *RedisBeginImportDataOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/import" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// importDataHandleError handles the ImportData error response. +func (client *RedisClient) importDataHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Lists all Redis caches in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) ListByResourceGroup(resourceGroupName string, options *RedisListByResourceGroupOptions) RedisListByResourceGroupPager { + return &redisListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp RedisListByResourceGroupResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RedisListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *RedisClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *RedisListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *RedisClient) listByResourceGroupHandleResponse(resp *azcore.Response) (RedisListByResourceGroupResponse, error) { + result := RedisListByResourceGroupResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisListResult); err != nil { + return RedisListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *RedisClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - Gets all Redis caches in the specified subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) ListBySubscription(options *RedisListBySubscriptionOptions) RedisListBySubscriptionPager { + return &redisListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp RedisListBySubscriptionResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RedisListResult.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *RedisClient) listBySubscriptionCreateRequest(ctx context.Context, options *RedisListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redis" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *RedisClient) listBySubscriptionHandleResponse(resp *azcore.Response) (RedisListBySubscriptionResponse, error) { + result := RedisListBySubscriptionResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisListResult); err != nil { + return RedisListBySubscriptionResponse{}, err + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *RedisClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListKeys - Retrieve a Redis cache's access keys. This operation requires write permission to the cache resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) ListKeys(ctx context.Context, resourceGroupName string, name string, options *RedisListKeysOptions) (RedisListKeysResponse, error) { + req, err := client.listKeysCreateRequest(ctx, resourceGroupName, name, options) + if err != nil { + return RedisListKeysResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RedisListKeysResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RedisListKeysResponse{}, client.listKeysHandleError(resp) + } + return client.listKeysHandleResponse(resp) +} + +// listKeysCreateRequest creates the ListKeys request. +func (client *RedisClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, name string, options *RedisListKeysOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/listKeys" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client *RedisClient) listKeysHandleResponse(resp *azcore.Response) (RedisListKeysResponse, error) { + result := RedisListKeysResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisAccessKeys); err != nil { + return RedisListKeysResponse{}, err + } + return result, nil +} + +// listKeysHandleError handles the ListKeys error response. +func (client *RedisClient) listKeysHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListUpgradeNotifications - Gets any upgrade notifications for a Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) ListUpgradeNotifications(resourceGroupName string, name string, history float64, options *RedisListUpgradeNotificationsOptions) RedisListUpgradeNotificationsPager { + return &redisListUpgradeNotificationsPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listUpgradeNotificationsCreateRequest(ctx, resourceGroupName, name, history, options) + }, + advancer: func(ctx context.Context, resp RedisListUpgradeNotificationsResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.NotificationListResponse.NextLink) + }, + } +} + +// listUpgradeNotificationsCreateRequest creates the ListUpgradeNotifications request. +func (client *RedisClient) listUpgradeNotificationsCreateRequest(ctx context.Context, resourceGroupName string, name string, history float64, options *RedisListUpgradeNotificationsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/listUpgradeNotifications" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + reqQP.Set("history", strconv.FormatFloat(history, 'f', -1, 64)) + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listUpgradeNotificationsHandleResponse handles the ListUpgradeNotifications response. +func (client *RedisClient) listUpgradeNotificationsHandleResponse(resp *azcore.Response) (RedisListUpgradeNotificationsResponse, error) { + result := RedisListUpgradeNotificationsResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.NotificationListResponse); err != nil { + return RedisListUpgradeNotificationsResponse{}, err + } + return result, nil +} + +// listUpgradeNotificationsHandleError handles the ListUpgradeNotifications error response. +func (client *RedisClient) listUpgradeNotificationsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// RegenerateKey - Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) RegenerateKey(ctx context.Context, resourceGroupName string, name string, parameters RedisRegenerateKeyParameters, options *RedisRegenerateKeyOptions) (RedisRegenerateKeyResponse, error) { + req, err := client.regenerateKeyCreateRequest(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return RedisRegenerateKeyResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RedisRegenerateKeyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RedisRegenerateKeyResponse{}, client.regenerateKeyHandleError(resp) + } + return client.regenerateKeyHandleResponse(resp) +} + +// regenerateKeyCreateRequest creates the RegenerateKey request. +func (client *RedisClient) regenerateKeyCreateRequest(ctx context.Context, resourceGroupName string, name string, parameters RedisRegenerateKeyParameters, options *RedisRegenerateKeyOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/regenerateKey" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// regenerateKeyHandleResponse handles the RegenerateKey response. +func (client *RedisClient) regenerateKeyHandleResponse(resp *azcore.Response) (RedisRegenerateKeyResponse, error) { + result := RedisRegenerateKeyResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisAccessKeys); err != nil { + return RedisRegenerateKeyResponse{}, err + } + return result, nil +} + +// regenerateKeyHandleError handles the RegenerateKey error response. +func (client *RedisClient) regenerateKeyHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Update an existing Redis cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RedisClient) Update(ctx context.Context, resourceGroupName string, name string, parameters RedisUpdateParameters, options *RedisUpdateOptions) (RedisUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, name, parameters, options) + if err != nil { + return RedisUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RedisUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RedisUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *RedisClient) updateCreateRequest(ctx context.Context, resourceGroupName string, name string, parameters RedisUpdateParameters, options *RedisUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *RedisClient) updateHandleResponse(resp *azcore.Response) (RedisUpdateResponse, error) { + result := RedisUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RedisResource); err != nil { + return RedisUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *RedisClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/redis/armredis/zz_generated_response_types.go b/sdk/redis/armredis/zz_generated_response_types.go new file mode 100644 index 000000000000..07292bb472e7 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_response_types.go @@ -0,0 +1,410 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "context" + "net/http" + "time" +) + +// FirewallRulesCreateOrUpdateResponse contains the response from method FirewallRules.CreateOrUpdate. +type FirewallRulesCreateOrUpdateResponse struct { + FirewallRulesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesCreateOrUpdateResult contains the result from method FirewallRules.CreateOrUpdate. +type FirewallRulesCreateOrUpdateResult struct { + RedisFirewallRule +} + +// FirewallRulesDeleteResponse contains the response from method FirewallRules.Delete. +type FirewallRulesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesGetResponse contains the response from method FirewallRules.Get. +type FirewallRulesGetResponse struct { + FirewallRulesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesGetResult contains the result from method FirewallRules.Get. +type FirewallRulesGetResult struct { + RedisFirewallRule +} + +// FirewallRulesListResponse contains the response from method FirewallRules.List. +type FirewallRulesListResponse struct { + FirewallRulesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesListResult contains the result from method FirewallRules.List. +type FirewallRulesListResult struct { + RedisFirewallRuleListResult +} + +// LinkedServerCreatePollerResponse contains the response from method LinkedServer.Create. +type LinkedServerCreatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (LinkedServerCreateResponse, error) + + // Poller contains an initialized poller. + Poller LinkedServerCreatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServerCreateResponse contains the response from method LinkedServer.Create. +type LinkedServerCreateResponse struct { + LinkedServerCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServerCreateResult contains the result from method LinkedServer.Create. +type LinkedServerCreateResult struct { + RedisLinkedServerWithProperties +} + +// LinkedServerDeleteResponse contains the response from method LinkedServer.Delete. +type LinkedServerDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServerGetResponse contains the response from method LinkedServer.Get. +type LinkedServerGetResponse struct { + LinkedServerGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServerGetResult contains the result from method LinkedServer.Get. +type LinkedServerGetResult struct { + RedisLinkedServerWithProperties +} + +// LinkedServerListResponse contains the response from method LinkedServer.List. +type LinkedServerListResponse struct { + LinkedServerListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServerListResult contains the result from method LinkedServer.List. +type LinkedServerListResult struct { + RedisLinkedServerWithPropertiesList +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// PatchSchedulesCreateOrUpdateResponse contains the response from method PatchSchedules.CreateOrUpdate. +type PatchSchedulesCreateOrUpdateResponse struct { + PatchSchedulesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PatchSchedulesCreateOrUpdateResult contains the result from method PatchSchedules.CreateOrUpdate. +type PatchSchedulesCreateOrUpdateResult struct { + RedisPatchSchedule +} + +// PatchSchedulesDeleteResponse contains the response from method PatchSchedules.Delete. +type PatchSchedulesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PatchSchedulesGetResponse contains the response from method PatchSchedules.Get. +type PatchSchedulesGetResponse struct { + PatchSchedulesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PatchSchedulesGetResult contains the result from method PatchSchedules.Get. +type PatchSchedulesGetResult struct { + RedisPatchSchedule +} + +// PatchSchedulesListByRedisResourceResponse contains the response from method PatchSchedules.ListByRedisResource. +type PatchSchedulesListByRedisResourceResponse struct { + PatchSchedulesListByRedisResourceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PatchSchedulesListByRedisResourceResult contains the result from method PatchSchedules.ListByRedisResource. +type PatchSchedulesListByRedisResourceResult struct { + RedisPatchScheduleListResult +} + +// PrivateEndpointConnectionsDeleteResponse contains the response from method PrivateEndpointConnections.Delete. +type PrivateEndpointConnectionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsGetResponse contains the response from method PrivateEndpointConnections.Get. +type PrivateEndpointConnectionsGetResponse struct { + PrivateEndpointConnectionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsGetResult contains the result from method PrivateEndpointConnections.Get. +type PrivateEndpointConnectionsGetResult struct { + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsListResponse contains the response from method PrivateEndpointConnections.List. +type PrivateEndpointConnectionsListResponse struct { + PrivateEndpointConnectionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsListResult contains the result from method PrivateEndpointConnections.List. +type PrivateEndpointConnectionsListResult struct { + PrivateEndpointConnectionListResult +} + +// PrivateEndpointConnectionsPutPollerResponse contains the response from method PrivateEndpointConnections.Put. +type PrivateEndpointConnectionsPutPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionsPutResponse, error) + + // Poller contains an initialized poller. + Poller PrivateEndpointConnectionsPutPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsPutResponse contains the response from method PrivateEndpointConnections.Put. +type PrivateEndpointConnectionsPutResponse struct { + PrivateEndpointConnectionsPutResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsPutResult contains the result from method PrivateEndpointConnections.Put. +type PrivateEndpointConnectionsPutResult struct { + PrivateEndpointConnection +} + +// PrivateLinkResourcesListByRedisCacheResponse contains the response from method PrivateLinkResources.ListByRedisCache. +type PrivateLinkResourcesListByRedisCacheResponse struct { + PrivateLinkResourcesListByRedisCacheResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourcesListByRedisCacheResult contains the result from method PrivateLinkResources.ListByRedisCache. +type PrivateLinkResourcesListByRedisCacheResult struct { + PrivateLinkResourceListResult +} + +// RedisCheckNameAvailabilityResponse contains the response from method Redis.CheckNameAvailability. +type RedisCheckNameAvailabilityResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisCreatePollerResponse contains the response from method Redis.Create. +type RedisCreatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (RedisCreateResponse, error) + + // Poller contains an initialized poller. + Poller RedisCreatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisCreateResponse contains the response from method Redis.Create. +type RedisCreateResponse struct { + RedisCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisCreateResult contains the result from method Redis.Create. +type RedisCreateResult struct { + RedisResource +} + +// RedisDeletePollerResponse contains the response from method Redis.Delete. +type RedisDeletePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (RedisDeleteResponse, error) + + // Poller contains an initialized poller. + Poller RedisDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisDeleteResponse contains the response from method Redis.Delete. +type RedisDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisExportDataPollerResponse contains the response from method Redis.ExportData. +type RedisExportDataPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (RedisExportDataResponse, error) + + // Poller contains an initialized poller. + Poller RedisExportDataPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisExportDataResponse contains the response from method Redis.ExportData. +type RedisExportDataResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisForceRebootResponseEnvelope contains the response from method Redis.ForceReboot. +type RedisForceRebootResponseEnvelope struct { + RedisForceRebootResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisForceRebootResult contains the result from method Redis.ForceReboot. +type RedisForceRebootResult struct { + RedisForceRebootResponse +} + +// RedisGetResponse contains the response from method Redis.Get. +type RedisGetResponse struct { + RedisGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisGetResult contains the result from method Redis.Get. +type RedisGetResult struct { + RedisResource +} + +// RedisImportDataPollerResponse contains the response from method Redis.ImportData. +type RedisImportDataPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (RedisImportDataResponse, error) + + // Poller contains an initialized poller. + Poller RedisImportDataPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisImportDataResponse contains the response from method Redis.ImportData. +type RedisImportDataResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisListByResourceGroupResponse contains the response from method Redis.ListByResourceGroup. +type RedisListByResourceGroupResponse struct { + RedisListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisListByResourceGroupResult contains the result from method Redis.ListByResourceGroup. +type RedisListByResourceGroupResult struct { + RedisListResult +} + +// RedisListBySubscriptionResponse contains the response from method Redis.ListBySubscription. +type RedisListBySubscriptionResponse struct { + RedisListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisListBySubscriptionResult contains the result from method Redis.ListBySubscription. +type RedisListBySubscriptionResult struct { + RedisListResult +} + +// RedisListKeysResponse contains the response from method Redis.ListKeys. +type RedisListKeysResponse struct { + RedisListKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisListKeysResult contains the result from method Redis.ListKeys. +type RedisListKeysResult struct { + RedisAccessKeys +} + +// RedisListUpgradeNotificationsResponse contains the response from method Redis.ListUpgradeNotifications. +type RedisListUpgradeNotificationsResponse struct { + RedisListUpgradeNotificationsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisListUpgradeNotificationsResult contains the result from method Redis.ListUpgradeNotifications. +type RedisListUpgradeNotificationsResult struct { + NotificationListResponse +} + +// RedisRegenerateKeyResponse contains the response from method Redis.RegenerateKey. +type RedisRegenerateKeyResponse struct { + RedisRegenerateKeyResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisRegenerateKeyResult contains the result from method Redis.RegenerateKey. +type RedisRegenerateKeyResult struct { + RedisAccessKeys +} + +// RedisUpdateResponse contains the response from method Redis.Update. +type RedisUpdateResponse struct { + RedisUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RedisUpdateResult contains the result from method Redis.Update. +type RedisUpdateResult struct { + RedisResource +} diff --git a/sdk/redis/armredis/zz_generated_time_rfc3339.go b/sdk/redis/armredis/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..3dc10bc27aa5 --- /dev/null +++ b/sdk/redis/armredis/zz_generated_time_rfc3339.go @@ -0,0 +1,57 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armredis + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +}