diff --git a/go.mod b/go.mod index 544fa1b0760..3de69a0de80 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2 v2.5.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 v2.2.1 github.com/Azure/go-autorest/autorest v0.11.29 diff --git a/go.sum b/go.sum index 7fc169f7237..4756661b150 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,8 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v1.8.0 h1:jBQA3cKT4L2rWMpgE7Yt3Hw github.com/Azure/azure-sdk-for-go/sdk/internal v1.8.0/go.mod h1:4OG6tQ9EOP/MT0NMjDlRzWoVFxfu9rN9B2X+tlSVktg= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2 v2.5.0 h1:FTNvxTFH/08JBmhcbL5lmLaGYVXokZM6Ni92Mqr+gSg= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2 v2.5.0/go.mod h1:T0ryqIz5h5qg4HOBni+VeRn24alSqOx1Se1IAwUByOk= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 h1:lpOxwrQ919lCZoNCd69rVt8u1eLZuMORrGXqy8sNf3c= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0/go.mod h1:fSvRkb8d26z9dbL40Uf/OO6Vo9iExtZK3D0ulRV+8M0= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.4.0 h1:HlZMUZW8S4P9oob1nCHxCCKrytxyLc+24nUJGssoEto= diff --git a/pkg/util/azureclient/azuresdk/armdns/generate.go b/pkg/util/azureclient/azuresdk/armdns/generate.go new file mode 100644 index 00000000000..d5dd32797c8 --- /dev/null +++ b/pkg/util/azureclient/azuresdk/armdns/generate.go @@ -0,0 +1,8 @@ +package armdns + +// Copyright (c) Microsoft Corporation. +// Licensed under the Apache License 2.0. + +//go:generate rm -rf ../../../../../pkg/util/mocks/azureclient/azuresdk/$GOPACKAGE +//go:generate go run ../../../../../vendor/github.com/golang/mock/mockgen -destination=../../../mocks/azureclient/azuresdk/$GOPACKAGE/$GOPACKAGE.go github.com/Azure/ARO-RP/pkg/util/azureclient/azuresdk/$GOPACKAGE RecordSetsClient,ZonesClient +//go:generate go run ../../../../../vendor/golang.org/x/tools/cmd/goimports -local=github.com/Azure/ARO-RP -e -w ../../../mocks/azureclient/azuresdk/$GOPACKAGE/$GOPACKAGE.go diff --git a/pkg/util/azureclient/azuresdk/armdns/recordsets.go b/pkg/util/azureclient/azuresdk/armdns/recordsets.go new file mode 100644 index 00000000000..13cebdf1c3c --- /dev/null +++ b/pkg/util/azureclient/azuresdk/armdns/recordsets.go @@ -0,0 +1,37 @@ +package armdns + +// Copyright (c) Microsoft Corporation. +// Licensed under the Apache License 2.0. + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + sdkdns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" +) + +// RecordSetsClient is a minimal interface for azure RecordSetsClient +type RecordSetsClient interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType sdkdns.RecordType, parameters sdkdns.RecordSet, options *sdkdns.RecordSetsClientCreateOrUpdateOptions) (sdkdns.RecordSetsClientCreateOrUpdateResponse, error) + Delete(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType sdkdns.RecordType, options *sdkdns.RecordSetsClientDeleteOptions) (sdkdns.RecordSetsClientDeleteResponse, error) + Get(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType sdkdns.RecordType, options *sdkdns.RecordSetsClientGetOptions) (sdkdns.RecordSetsClientGetResponse, error) +} + +type recordSetsClient struct { + sdkdns.RecordSetsClient +} + +var _ RecordSetsClient = &recordSetsClient{} + +// NewRecordSetsClient creates a new RecordSetsClient +func NewRecordSetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) RecordSetsClient { + clientFactory, err := sdkdns.NewClientFactory(subscriptionID, credential, options) + if err != nil { + return nil + } + client := clientFactory.NewRecordSetsClient() + return &recordSetsClient{ + RecordSetsClient: *client, + } +} diff --git a/pkg/util/azureclient/azuresdk/armdns/zones.go b/pkg/util/azureclient/azuresdk/armdns/zones.go new file mode 100644 index 00000000000..e005fe61777 --- /dev/null +++ b/pkg/util/azureclient/azuresdk/armdns/zones.go @@ -0,0 +1,35 @@ +package armdns + +// Copyright (c) Microsoft Corporation. +// Licensed under the Apache License 2.0. + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + sdkdns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" +) + +// ZonesClient is a minimal interface for azure ZonesClient +type ZonesClient interface { + Get(ctx context.Context, resourceGroupName string, zoneName string, options *sdkdns.ZonesClientGetOptions) (sdkdns.ZonesClientGetResponse, error) +} + +type zonesClient struct { + sdkdns.ZonesClient +} + +var _ ZonesClient = &zonesClient{} + +// NewZonesClient creates a new ZonesClient +func NewZonesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) ZonesClient { + clientFactory, err := sdkdns.NewClientFactory(subscriptionID, credential, options) + if err != nil { + return nil + } + client := clientFactory.NewZonesClient() + return &zonesClient{ + ZonesClient: *client, + } +} diff --git a/pkg/util/mocks/azureclient/azuresdk/armdns/armdns.go b/pkg/util/mocks/azureclient/azuresdk/armdns/armdns.go new file mode 100644 index 00000000000..47da3d61957 --- /dev/null +++ b/pkg/util/mocks/azureclient/azuresdk/armdns/armdns.go @@ -0,0 +1,119 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/Azure/ARO-RP/pkg/util/azureclient/azuresdk/armdns (interfaces: RecordSetsClient,ZonesClient) + +// Package mock_armdns is a generated GoMock package. +package mock_armdns + +import ( + context "context" + reflect "reflect" + + armdns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" + gomock "github.com/golang/mock/gomock" +) + +// MockRecordSetsClient is a mock of RecordSetsClient interface. +type MockRecordSetsClient struct { + ctrl *gomock.Controller + recorder *MockRecordSetsClientMockRecorder +} + +// MockRecordSetsClientMockRecorder is the mock recorder for MockRecordSetsClient. +type MockRecordSetsClientMockRecorder struct { + mock *MockRecordSetsClient +} + +// NewMockRecordSetsClient creates a new mock instance. +func NewMockRecordSetsClient(ctrl *gomock.Controller) *MockRecordSetsClient { + mock := &MockRecordSetsClient{ctrl: ctrl} + mock.recorder = &MockRecordSetsClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRecordSetsClient) EXPECT() *MockRecordSetsClientMockRecorder { + return m.recorder +} + +// CreateOrUpdate mocks base method. +func (m *MockRecordSetsClient) CreateOrUpdate(arg0 context.Context, arg1, arg2, arg3 string, arg4 armdns.RecordType, arg5 armdns.RecordSet, arg6 *armdns.RecordSetsClientCreateOrUpdateOptions) (armdns.RecordSetsClientCreateOrUpdateResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateOrUpdate", arg0, arg1, arg2, arg3, arg4, arg5, arg6) + ret0, _ := ret[0].(armdns.RecordSetsClientCreateOrUpdateResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateOrUpdate indicates an expected call of CreateOrUpdate. +func (mr *MockRecordSetsClientMockRecorder) CreateOrUpdate(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdate", reflect.TypeOf((*MockRecordSetsClient)(nil).CreateOrUpdate), arg0, arg1, arg2, arg3, arg4, arg5, arg6) +} + +// Delete mocks base method. +func (m *MockRecordSetsClient) Delete(arg0 context.Context, arg1, arg2, arg3 string, arg4 armdns.RecordType, arg5 *armdns.RecordSetsClientDeleteOptions) (armdns.RecordSetsClientDeleteResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", arg0, arg1, arg2, arg3, arg4, arg5) + ret0, _ := ret[0].(armdns.RecordSetsClientDeleteResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Delete indicates an expected call of Delete. +func (mr *MockRecordSetsClientMockRecorder) Delete(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRecordSetsClient)(nil).Delete), arg0, arg1, arg2, arg3, arg4, arg5) +} + +// Get mocks base method. +func (m *MockRecordSetsClient) Get(arg0 context.Context, arg1, arg2, arg3 string, arg4 armdns.RecordType, arg5 *armdns.RecordSetsClientGetOptions) (armdns.RecordSetsClientGetResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Get", arg0, arg1, arg2, arg3, arg4, arg5) + ret0, _ := ret[0].(armdns.RecordSetsClientGetResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get. +func (mr *MockRecordSetsClientMockRecorder) Get(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRecordSetsClient)(nil).Get), arg0, arg1, arg2, arg3, arg4, arg5) +} + +// MockZonesClient is a mock of ZonesClient interface. +type MockZonesClient struct { + ctrl *gomock.Controller + recorder *MockZonesClientMockRecorder +} + +// MockZonesClientMockRecorder is the mock recorder for MockZonesClient. +type MockZonesClientMockRecorder struct { + mock *MockZonesClient +} + +// NewMockZonesClient creates a new mock instance. +func NewMockZonesClient(ctrl *gomock.Controller) *MockZonesClient { + mock := &MockZonesClient{ctrl: ctrl} + mock.recorder = &MockZonesClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockZonesClient) EXPECT() *MockZonesClientMockRecorder { + return m.recorder +} + +// Get mocks base method. +func (m *MockZonesClient) Get(arg0 context.Context, arg1, arg2 string, arg3 *armdns.ZonesClientGetOptions) (armdns.ZonesClientGetResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Get", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(armdns.ZonesClientGetResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get. +func (mr *MockZonesClientMockRecorder) Get(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockZonesClient)(nil).Get), arg0, arg1, arg2, arg3) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/CHANGELOG.md new file mode 100644 index 00000000000..e9070946234 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/CHANGELOG.md @@ -0,0 +1,21 @@ +# Release History + +## 1.2.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + +## 1.0.0 (2022-05-17) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. + +To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/azsdk/go/mgmt/migration). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/LICENSE.txt b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/LICENSE.txt new file mode 100644 index 00000000000..dc0c2ffb3dc --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +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/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/README.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/README.md new file mode 100644 index 00000000000..00c981fabad --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/README.md @@ -0,0 +1,92 @@ +# Azure DNS Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns) + +The `armdns` module provides operations for working with Azure DNS. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/dns/armdns) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure DNS module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure DNS. 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). + +## Client Factory + +Azure DNS module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armdns.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armdns.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewRecordSetsClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## 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 `DNS` 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/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/autorest.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/autorest.md new file mode 100644 index 00000000000..e8c4371fad9 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/dns/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 1.2.0 + +``` \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/build.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/build.go new file mode 100644 index 00000000000..7a8403efa9a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/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 ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/dns/armdns + +package armdns diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/ci.yml b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/ci.yml new file mode 100644 index 00000000000..16c84989357 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/dns/armdns/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/dns/armdns/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/dns/armdns' diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/client_factory.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/client_factory.go new file mode 100644 index 00000000000..a844cbb964b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/client_factory.go @@ -0,0 +1,56 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +// NewRecordSetsClient creates a new instance of RecordSetsClient. +func (c *ClientFactory) NewRecordSetsClient() *RecordSetsClient { + subClient, _ := NewRecordSetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewResourceReferenceClient creates a new instance of ResourceReferenceClient. +func (c *ClientFactory) NewResourceReferenceClient() *ResourceReferenceClient { + subClient, _ := NewResourceReferenceClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewZonesClient creates a new instance of ZonesClient. +func (c *ClientFactory) NewZonesClient() *ZonesClient { + subClient, _ := NewZonesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/constants.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/constants.go new file mode 100644 index 00000000000..1dbee716be3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/constants.go @@ -0,0 +1,61 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" + moduleVersion = "v1.2.0" +) + +type RecordType string + +const ( + RecordTypeA RecordType = "A" + RecordTypeAAAA RecordType = "AAAA" + RecordTypeCAA RecordType = "CAA" + RecordTypeCNAME RecordType = "CNAME" + RecordTypeMX RecordType = "MX" + RecordTypeNS RecordType = "NS" + RecordTypePTR RecordType = "PTR" + RecordTypeSOA RecordType = "SOA" + RecordTypeSRV RecordType = "SRV" + RecordTypeTXT RecordType = "TXT" +) + +// PossibleRecordTypeValues returns the possible values for the RecordType const type. +func PossibleRecordTypeValues() []RecordType { + return []RecordType{ + RecordTypeA, + RecordTypeAAAA, + RecordTypeCAA, + RecordTypeCNAME, + RecordTypeMX, + RecordTypeNS, + RecordTypePTR, + RecordTypeSOA, + RecordTypeSRV, + RecordTypeTXT, + } +} + +// ZoneType - The type of this DNS zone (Public or Private). +type ZoneType string + +const ( + ZoneTypePrivate ZoneType = "Private" + ZoneTypePublic ZoneType = "Public" +) + +// PossibleZoneTypeValues returns the possible values for the ZoneType const type. +func PossibleZoneTypeValues() []ZoneType { + return []ZoneType{ + ZoneTypePrivate, + ZoneTypePublic, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/models.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/models.go new file mode 100644 index 00000000000..7b451eb222a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/models.go @@ -0,0 +1,311 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +// ARecord - An A record. +type ARecord struct { + // The IPv4 address of this A record. + IPv4Address *string +} + +// AaaaRecord - An AAAA record. +type AaaaRecord struct { + // The IPv6 address of this AAAA record. + IPv6Address *string +} + +// CaaRecord - A CAA record. +type CaaRecord struct { + // The flags for this CAA record as an integer between 0 and 255. + Flags *int32 + + // The tag for this CAA record. + Tag *string + + // The value for this CAA record. + Value *string +} + +// CnameRecord - A CNAME record. +type CnameRecord struct { + // The canonical name for this CNAME record. + Cname *string +} + +// MxRecord - An MX record. +type MxRecord struct { + // The domain name of the mail host for this MX record. + Exchange *string + + // The preference value for this MX record. + Preference *int32 +} + +// NsRecord - An NS record. +type NsRecord struct { + // The name server name for this NS record. + Nsdname *string +} + +// PtrRecord - A PTR record. +type PtrRecord struct { + // The PTR target domain name for this PTR record. + Ptrdname *string +} + +// RecordSet - Describes a DNS record set (a collection of DNS records with the same name and type). +type RecordSet struct { + // The etag of the record set. + Etag *string + + // The properties of the record set. + Properties *RecordSetProperties + + // READ-ONLY; The ID of the record set. + ID *string + + // READ-ONLY; The name of the record set. + Name *string + + // READ-ONLY; The type of the record set. + Type *string +} + +// RecordSetListResult - The response to a record set List operation. +type RecordSetListResult struct { + // Information about the record sets in the response. + Value []*RecordSet + + // READ-ONLY; The continuation token for the next page of results. + NextLink *string +} + +// RecordSetProperties - Represents the properties of the records in the record set. +type RecordSetProperties struct { + // The list of A records in the record set. + ARecords []*ARecord + + // The list of AAAA records in the record set. + AaaaRecords []*AaaaRecord + + // The list of CAA records in the record set. + CaaRecords []*CaaRecord + + // The CNAME record in the record set. + CnameRecord *CnameRecord + + // The metadata attached to the record set. + Metadata map[string]*string + + // The list of MX records in the record set. + MxRecords []*MxRecord + + // The list of NS records in the record set. + NsRecords []*NsRecord + + // The list of PTR records in the record set. + PtrRecords []*PtrRecord + + // The SOA record in the record set. + SoaRecord *SoaRecord + + // The list of SRV records in the record set. + SrvRecords []*SrvRecord + + // The TTL (time-to-live) of the records in the record set. + TTL *int64 + + // A reference to an azure resource from where the dns resource value is taken. + TargetResource *SubResource + + // The list of TXT records in the record set. + TxtRecords []*TxtRecord + + // READ-ONLY; Fully qualified domain name of the record set. + Fqdn *string + + // READ-ONLY; provisioning State of the record set. + ProvisioningState *string +} + +// RecordSetUpdateParameters - Parameters supplied to update a record set. +type RecordSetUpdateParameters struct { + // Specifies information about the record set being updated. + RecordSet *RecordSet +} + +// Resource - Common properties of an Azure Resource Manager resource +type Resource struct { + // REQUIRED; Resource location. + Location *string + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Resource ID. + ID *string + + // READ-ONLY; Resource name. + Name *string + + // READ-ONLY; Resource type. + Type *string +} + +// ResourceReference - Represents a single Azure resource and its referencing DNS records. +type ResourceReference struct { + // A list of dns Records + DNSResources []*SubResource + + // A reference to an azure resource from where the dns resource value is taken. + TargetResource *SubResource +} + +// ResourceReferenceRequest - Represents the properties of the Dns Resource Reference Request. +type ResourceReferenceRequest struct { + // The properties of the Resource Reference Request. + Properties *ResourceReferenceRequestProperties +} + +// ResourceReferenceRequestProperties - Represents the properties of the Dns Resource Reference Request. +type ResourceReferenceRequestProperties struct { + // A list of references to azure resources for which referencing dns records need to be queried. + TargetResources []*SubResource +} + +// ResourceReferenceResult - Represents the properties of the Dns Resource Reference Result. +type ResourceReferenceResult struct { + // The result of dns resource reference request. Returns a list of dns resource references for each of the azure resource + // in the request. + Properties *ResourceReferenceResultProperties +} + +// ResourceReferenceResultProperties - The result of dns resource reference request. Returns a list of dns resource references +// for each of the azure resource in the request. +type ResourceReferenceResultProperties struct { + // The result of dns resource reference request. A list of dns resource references for each of the azure resource in the request + DNSResourceReferences []*ResourceReference +} + +// SoaRecord - An SOA record. +type SoaRecord struct { + // The email contact for this SOA record. + Email *string + + // The expire time for this SOA record. + ExpireTime *int64 + + // The domain name of the authoritative name server for this SOA record. + Host *string + + // The minimum value for this SOA record. By convention this is used to determine the negative caching duration. + MinimumTTL *int64 + + // The refresh value for this SOA record. + RefreshTime *int64 + + // The retry time for this SOA record. + RetryTime *int64 + + // The serial number for this SOA record. + SerialNumber *int64 +} + +// SrvRecord - An SRV record. +type SrvRecord struct { + // The port value for this SRV record. + Port *int32 + + // The priority value for this SRV record. + Priority *int32 + + // The target domain name for this SRV record. + Target *string + + // The weight value for this SRV record. + Weight *int32 +} + +// SubResource - A reference to a another resource +type SubResource struct { + // Resource Id. + ID *string +} + +// TxtRecord - A TXT record. +type TxtRecord struct { + // The text value of this TXT record. + Value []*string +} + +// Zone - Describes a DNS zone. +type Zone struct { + // REQUIRED; Resource location. + Location *string + + // The etag of the zone. + Etag *string + + // The properties of the zone. + Properties *ZoneProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Resource ID. + ID *string + + // READ-ONLY; Resource name. + Name *string + + // READ-ONLY; Resource type. + Type *string +} + +// ZoneListResult - The response to a Zone List or ListAll operation. +type ZoneListResult struct { + // Information about the DNS zones. + Value []*Zone + + // READ-ONLY; The continuation token for the next page of results. + NextLink *string +} + +// ZoneProperties - Represents the properties of the zone. +type ZoneProperties struct { + // A list of references to virtual networks that register hostnames in this DNS zone. This is a only when ZoneType is Private. + RegistrationVirtualNetworks []*SubResource + + // A list of references to virtual networks that resolve records in this DNS zone. This is a only when ZoneType is Private. + ResolutionVirtualNetworks []*SubResource + + // The type of this DNS zone (Public or Private). + ZoneType *ZoneType + + // READ-ONLY; The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any + // attempt to set this value will be ignored. + MaxNumberOfRecordSets *int64 + + // READ-ONLY; The maximum number of records per record set that can be created in this DNS zone. This is a read-only property + // and any attempt to set this value will be ignored. + MaxNumberOfRecordsPerRecordSet *int64 + + // READ-ONLY; The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored. + NameServers []*string + + // READ-ONLY; The current number of record sets in this DNS zone. This is a read-only property and any attempt to set this + // value will be ignored. + NumberOfRecordSets *int64 +} + +// ZoneUpdate - Describes a request to update a DNS zone. +type ZoneUpdate struct { + // Resource tags. + Tags map[string]*string +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/models_serde.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/models_serde.go new file mode 100644 index 00000000000..b75889c40dd --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/models_serde.go @@ -0,0 +1,907 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ARecord. +func (a ARecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ipv4Address", a.IPv4Address) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ARecord. +func (a *ARecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ipv4Address": + err = unpopulate(val, "IPv4Address", &a.IPv4Address) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AaaaRecord. +func (a AaaaRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ipv6Address", a.IPv6Address) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AaaaRecord. +func (a *AaaaRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ipv6Address": + err = unpopulate(val, "IPv6Address", &a.IPv6Address) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CaaRecord. +func (c CaaRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "flags", c.Flags) + populate(objectMap, "tag", c.Tag) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CaaRecord. +func (c *CaaRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "flags": + err = unpopulate(val, "Flags", &c.Flags) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &c.Tag) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CnameRecord. +func (c CnameRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cname", c.Cname) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CnameRecord. +func (c *CnameRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cname": + err = unpopulate(val, "Cname", &c.Cname) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MxRecord. +func (m MxRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "exchange", m.Exchange) + populate(objectMap, "preference", m.Preference) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MxRecord. +func (m *MxRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "exchange": + err = unpopulate(val, "Exchange", &m.Exchange) + delete(rawMsg, key) + case "preference": + err = unpopulate(val, "Preference", &m.Preference) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NsRecord. +func (n NsRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nsdname", n.Nsdname) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NsRecord. +func (n *NsRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nsdname": + err = unpopulate(val, "Nsdname", &n.Nsdname) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PtrRecord. +func (p PtrRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ptrdname", p.Ptrdname) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PtrRecord. +func (p *PtrRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ptrdname": + err = unpopulate(val, "Ptrdname", &p.Ptrdname) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecordSet. +func (r RecordSet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecordSet. +func (r *RecordSet) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecordSetListResult. +func (r RecordSetListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecordSetListResult. +func (r *RecordSetListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecordSetProperties. +func (r RecordSetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ARecords", r.ARecords) + populate(objectMap, "AAAARecords", r.AaaaRecords) + populate(objectMap, "caaRecords", r.CaaRecords) + populate(objectMap, "CNAMERecord", r.CnameRecord) + populate(objectMap, "fqdn", r.Fqdn) + populate(objectMap, "metadata", r.Metadata) + populate(objectMap, "MXRecords", r.MxRecords) + populate(objectMap, "NSRecords", r.NsRecords) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "PTRRecords", r.PtrRecords) + populate(objectMap, "SOARecord", r.SoaRecord) + populate(objectMap, "SRVRecords", r.SrvRecords) + populate(objectMap, "TTL", r.TTL) + populate(objectMap, "targetResource", r.TargetResource) + populate(objectMap, "TXTRecords", r.TxtRecords) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecordSetProperties. +func (r *RecordSetProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ARecords": + err = unpopulate(val, "ARecords", &r.ARecords) + delete(rawMsg, key) + case "AAAARecords": + err = unpopulate(val, "AaaaRecords", &r.AaaaRecords) + delete(rawMsg, key) + case "caaRecords": + err = unpopulate(val, "CaaRecords", &r.CaaRecords) + delete(rawMsg, key) + case "CNAMERecord": + err = unpopulate(val, "CnameRecord", &r.CnameRecord) + delete(rawMsg, key) + case "fqdn": + err = unpopulate(val, "Fqdn", &r.Fqdn) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &r.Metadata) + delete(rawMsg, key) + case "MXRecords": + err = unpopulate(val, "MxRecords", &r.MxRecords) + delete(rawMsg, key) + case "NSRecords": + err = unpopulate(val, "NsRecords", &r.NsRecords) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "PTRRecords": + err = unpopulate(val, "PtrRecords", &r.PtrRecords) + delete(rawMsg, key) + case "SOARecord": + err = unpopulate(val, "SoaRecord", &r.SoaRecord) + delete(rawMsg, key) + case "SRVRecords": + err = unpopulate(val, "SrvRecords", &r.SrvRecords) + delete(rawMsg, key) + case "TTL": + err = unpopulate(val, "TTL", &r.TTL) + delete(rawMsg, key) + case "targetResource": + err = unpopulate(val, "TargetResource", &r.TargetResource) + delete(rawMsg, key) + case "TXTRecords": + err = unpopulate(val, "TxtRecords", &r.TxtRecords) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecordSetUpdateParameters. +func (r RecordSetUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "RecordSet", r.RecordSet) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecordSetUpdateParameters. +func (r *RecordSetUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "RecordSet": + err = unpopulate(val, "RecordSet", &r.RecordSet) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceReference. +func (r ResourceReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dnsResources", r.DNSResources) + populate(objectMap, "targetResource", r.TargetResource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReference. +func (r *ResourceReference) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dnsResources": + err = unpopulate(val, "DNSResources", &r.DNSResources) + delete(rawMsg, key) + case "targetResource": + err = unpopulate(val, "TargetResource", &r.TargetResource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceReferenceRequest. +func (r ResourceReferenceRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceRequest. +func (r *ResourceReferenceRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceReferenceRequestProperties. +func (r ResourceReferenceRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "targetResources", r.TargetResources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceRequestProperties. +func (r *ResourceReferenceRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "targetResources": + err = unpopulate(val, "TargetResources", &r.TargetResources) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceReferenceResult. +func (r ResourceReferenceResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceResult. +func (r *ResourceReferenceResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceReferenceResultProperties. +func (r ResourceReferenceResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dnsResourceReferences", r.DNSResourceReferences) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceResultProperties. +func (r *ResourceReferenceResultProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dnsResourceReferences": + err = unpopulate(val, "DNSResourceReferences", &r.DNSResourceReferences) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SoaRecord. +func (s SoaRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "email", s.Email) + populate(objectMap, "expireTime", s.ExpireTime) + populate(objectMap, "host", s.Host) + populate(objectMap, "minimumTTL", s.MinimumTTL) + populate(objectMap, "refreshTime", s.RefreshTime) + populate(objectMap, "retryTime", s.RetryTime) + populate(objectMap, "serialNumber", s.SerialNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SoaRecord. +func (s *SoaRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "email": + err = unpopulate(val, "Email", &s.Email) + delete(rawMsg, key) + case "expireTime": + err = unpopulate(val, "ExpireTime", &s.ExpireTime) + delete(rawMsg, key) + case "host": + err = unpopulate(val, "Host", &s.Host) + delete(rawMsg, key) + case "minimumTTL": + err = unpopulate(val, "MinimumTTL", &s.MinimumTTL) + delete(rawMsg, key) + case "refreshTime": + err = unpopulate(val, "RefreshTime", &s.RefreshTime) + delete(rawMsg, key) + case "retryTime": + err = unpopulate(val, "RetryTime", &s.RetryTime) + delete(rawMsg, key) + case "serialNumber": + err = unpopulate(val, "SerialNumber", &s.SerialNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SrvRecord. +func (s SrvRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "port", s.Port) + populate(objectMap, "priority", s.Priority) + populate(objectMap, "target", s.Target) + populate(objectMap, "weight", s.Weight) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SrvRecord. +func (s *SrvRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "port": + err = unpopulate(val, "Port", &s.Port) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &s.Priority) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &s.Target) + delete(rawMsg, key) + case "weight": + err = unpopulate(val, "Weight", &s.Weight) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubResource. +func (s SubResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubResource. +func (s *SubResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TxtRecord. +func (t TxtRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TxtRecord. +func (t *TxtRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Zone. +func (z Zone) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", z.Etag) + populate(objectMap, "id", z.ID) + populate(objectMap, "location", z.Location) + populate(objectMap, "name", z.Name) + populate(objectMap, "properties", z.Properties) + populate(objectMap, "tags", z.Tags) + populate(objectMap, "type", z.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Zone. +func (z *Zone) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &z.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &z.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &z.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &z.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &z.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &z.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &z.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ZoneListResult. +func (z ZoneListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", z.NextLink) + populate(objectMap, "value", z.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ZoneListResult. +func (z *ZoneListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &z.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &z.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ZoneProperties. +func (z ZoneProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "maxNumberOfRecordSets", z.MaxNumberOfRecordSets) + populate(objectMap, "maxNumberOfRecordsPerRecordSet", z.MaxNumberOfRecordsPerRecordSet) + populate(objectMap, "nameServers", z.NameServers) + populate(objectMap, "numberOfRecordSets", z.NumberOfRecordSets) + populate(objectMap, "registrationVirtualNetworks", z.RegistrationVirtualNetworks) + populate(objectMap, "resolutionVirtualNetworks", z.ResolutionVirtualNetworks) + populate(objectMap, "zoneType", z.ZoneType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ZoneProperties. +func (z *ZoneProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "maxNumberOfRecordSets": + err = unpopulate(val, "MaxNumberOfRecordSets", &z.MaxNumberOfRecordSets) + delete(rawMsg, key) + case "maxNumberOfRecordsPerRecordSet": + err = unpopulate(val, "MaxNumberOfRecordsPerRecordSet", &z.MaxNumberOfRecordsPerRecordSet) + delete(rawMsg, key) + case "nameServers": + err = unpopulate(val, "NameServers", &z.NameServers) + delete(rawMsg, key) + case "numberOfRecordSets": + err = unpopulate(val, "NumberOfRecordSets", &z.NumberOfRecordSets) + delete(rawMsg, key) + case "registrationVirtualNetworks": + err = unpopulate(val, "RegistrationVirtualNetworks", &z.RegistrationVirtualNetworks) + delete(rawMsg, key) + case "resolutionVirtualNetworks": + err = unpopulate(val, "ResolutionVirtualNetworks", &z.ResolutionVirtualNetworks) + delete(rawMsg, key) + case "zoneType": + err = unpopulate(val, "ZoneType", &z.ZoneType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ZoneUpdate. +func (z ZoneUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", z.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ZoneUpdate. +func (z *ZoneUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &z.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + 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, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/options.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/options.go new file mode 100644 index 00000000000..9275d5d7d7b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/options.go @@ -0,0 +1,121 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +// RecordSetsClientCreateOrUpdateOptions contains the optional parameters for the RecordSetsClient.CreateOrUpdate method. +type RecordSetsClientCreateOrUpdateOptions struct { + // The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value + // to prevent accidentally overwriting any concurrent changes. + IfMatch *string + + // Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be + // ignored. + IfNoneMatch *string +} + +// RecordSetsClientDeleteOptions contains the optional parameters for the RecordSetsClient.Delete method. +type RecordSetsClientDeleteOptions struct { + // The etag of the record set. Omit this value to always delete the current record set. Specify the last-seen etag value to + // prevent accidentally deleting any concurrent changes. + IfMatch *string +} + +// RecordSetsClientGetOptions contains the optional parameters for the RecordSetsClient.Get method. +type RecordSetsClientGetOptions struct { + // placeholder for future optional parameters +} + +// RecordSetsClientListAllByDNSZoneOptions contains the optional parameters for the RecordSetsClient.NewListAllByDNSZonePager +// method. +type RecordSetsClientListAllByDNSZoneOptions struct { + // The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is + // specified, Enumeration will return only records that end with . + RecordSetNameSuffix *string + + // The maximum number of record sets to return. If not specified, returns up to 100 record sets. + Top *int32 +} + +// RecordSetsClientListByDNSZoneOptions contains the optional parameters for the RecordSetsClient.NewListByDNSZonePager method. +type RecordSetsClientListByDNSZoneOptions struct { + // The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is + // specified, Enumeration will return only records that end with . + Recordsetnamesuffix *string + + // The maximum number of record sets to return. If not specified, returns up to 100 record sets. + Top *int32 +} + +// RecordSetsClientListByTypeOptions contains the optional parameters for the RecordSetsClient.NewListByTypePager method. +type RecordSetsClientListByTypeOptions struct { + // The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is + // specified, Enumeration will return only records that end with . + Recordsetnamesuffix *string + + // The maximum number of record sets to return. If not specified, returns up to 100 record sets. + Top *int32 +} + +// RecordSetsClientUpdateOptions contains the optional parameters for the RecordSetsClient.Update method. +type RecordSetsClientUpdateOptions struct { + // The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value + // to prevent accidentally overwriting concurrent changes. + IfMatch *string +} + +// ResourceReferenceClientGetByTargetResourcesOptions contains the optional parameters for the ResourceReferenceClient.GetByTargetResources +// method. +type ResourceReferenceClientGetByTargetResourcesOptions struct { + // placeholder for future optional parameters +} + +// ZonesClientBeginDeleteOptions contains the optional parameters for the ZonesClient.BeginDelete method. +type ZonesClientBeginDeleteOptions struct { + // The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent + // accidentally deleting any concurrent changes. + IfMatch *string + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ZonesClientCreateOrUpdateOptions contains the optional parameters for the ZonesClient.CreateOrUpdate method. +type ZonesClientCreateOrUpdateOptions struct { + // The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent + // accidentally overwriting any concurrent changes. + IfMatch *string + + // Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. + IfNoneMatch *string +} + +// ZonesClientGetOptions contains the optional parameters for the ZonesClient.Get method. +type ZonesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ZonesClientListByResourceGroupOptions contains the optional parameters for the ZonesClient.NewListByResourceGroupPager +// method. +type ZonesClientListByResourceGroupOptions struct { + // The maximum number of record sets to return. If not specified, returns up to 100 record sets. + Top *int32 +} + +// ZonesClientListOptions contains the optional parameters for the ZonesClient.NewListPager method. +type ZonesClientListOptions struct { + // The maximum number of DNS zones to return. If not specified, returns up to 100 zones. + Top *int32 +} + +// ZonesClientUpdateOptions contains the optional parameters for the ZonesClient.Update method. +type ZonesClientUpdateOptions struct { + // The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent + // accidentally overwriting any concurrent changes. + IfMatch *string +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/recordsets_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/recordsets_client.go new file mode 100644 index 00000000000..b1da1158b26 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/recordsets_client.go @@ -0,0 +1,560 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// RecordSetsClient contains the methods for the RecordSets group. +// Don't use this type directly, use NewRecordSetsClient() instead. +type RecordSetsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewRecordSetsClient creates a new instance of RecordSetsClient with the specified values. +// - subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewRecordSetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RecordSetsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RecordSetsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a record set within a DNS zone. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - relativeRecordSetName - The name of the record set, relative to the name of the zone. +// - recordType - The type of DNS record in this record set. Record sets of type SOA can be updated but not created (they are +// created when the DNS zone is created). +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - RecordSetsClientCreateOrUpdateOptions contains the optional parameters for the RecordSetsClient.CreateOrUpdate +// method. +func (client *RecordSetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, options *RecordSetsClientCreateOrUpdateOptions) (RecordSetsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "RecordSetsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, options) + if err != nil { + return RecordSetsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecordSetsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return RecordSetsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *RecordSetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, options *RecordSetsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + urlPath = strings.ReplaceAll(urlPath, "{relativeRecordSetName}", relativeRecordSetName) + if recordType == "" { + return nil, errors.New("parameter recordType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{recordType}", url.PathEscape(string(recordType))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if options != nil && options.IfNoneMatch != nil { + req.Raw().Header["If-None-Match"] = []string{*options.IfNoneMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *RecordSetsClient) createOrUpdateHandleResponse(resp *http.Response) (RecordSetsClientCreateOrUpdateResponse, error) { + result := RecordSetsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecordSet); err != nil { + return RecordSetsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a record set from a DNS zone. This operation cannot be undone. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - relativeRecordSetName - The name of the record set, relative to the name of the zone. +// - recordType - The type of DNS record in this record set. Record sets of type SOA cannot be deleted (they are deleted when +// the DNS zone is deleted). +// - options - RecordSetsClientDeleteOptions contains the optional parameters for the RecordSetsClient.Delete method. +func (client *RecordSetsClient) Delete(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, options *RecordSetsClientDeleteOptions) (RecordSetsClientDeleteResponse, error) { + var err error + const operationName = "RecordSetsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, options) + if err != nil { + return RecordSetsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecordSetsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return RecordSetsClientDeleteResponse{}, err + } + return RecordSetsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *RecordSetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, options *RecordSetsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + urlPath = strings.ReplaceAll(urlPath, "{relativeRecordSetName}", relativeRecordSetName) + if recordType == "" { + return nil, errors.New("parameter recordType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{recordType}", url.PathEscape(string(recordType))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a record set. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - relativeRecordSetName - The name of the record set, relative to the name of the zone. +// - recordType - The type of DNS record in this record set. +// - options - RecordSetsClientGetOptions contains the optional parameters for the RecordSetsClient.Get method. +func (client *RecordSetsClient) Get(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, options *RecordSetsClientGetOptions) (RecordSetsClientGetResponse, error) { + var err error + const operationName = "RecordSetsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, options) + if err != nil { + return RecordSetsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecordSetsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RecordSetsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RecordSetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, options *RecordSetsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + urlPath = strings.ReplaceAll(urlPath, "{relativeRecordSetName}", relativeRecordSetName) + if recordType == "" { + return nil, errors.New("parameter recordType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{recordType}", url.PathEscape(string(recordType))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RecordSetsClient) getHandleResponse(resp *http.Response) (RecordSetsClientGetResponse, error) { + result := RecordSetsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecordSet); err != nil { + return RecordSetsClientGetResponse{}, err + } + return result, nil +} + +// NewListAllByDNSZonePager - Lists all record sets in a DNS zone. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - options - RecordSetsClientListAllByDNSZoneOptions contains the optional parameters for the RecordSetsClient.NewListAllByDNSZonePager +// method. +func (client *RecordSetsClient) NewListAllByDNSZonePager(resourceGroupName string, zoneName string, options *RecordSetsClientListAllByDNSZoneOptions) *runtime.Pager[RecordSetsClientListAllByDNSZoneResponse] { + return runtime.NewPager(runtime.PagingHandler[RecordSetsClientListAllByDNSZoneResponse]{ + More: func(page RecordSetsClientListAllByDNSZoneResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RecordSetsClientListAllByDNSZoneResponse) (RecordSetsClientListAllByDNSZoneResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RecordSetsClient.NewListAllByDNSZonePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listAllByDNSZoneCreateRequest(ctx, resourceGroupName, zoneName, options) + }, nil) + if err != nil { + return RecordSetsClientListAllByDNSZoneResponse{}, err + } + return client.listAllByDNSZoneHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listAllByDNSZoneCreateRequest creates the ListAllByDNSZone request. +func (client *RecordSetsClient) listAllByDNSZoneCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, options *RecordSetsClientListAllByDNSZoneOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.RecordSetNameSuffix != nil { + reqQP.Set("$recordsetnamesuffix", *options.RecordSetNameSuffix) + } + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllByDNSZoneHandleResponse handles the ListAllByDNSZone response. +func (client *RecordSetsClient) listAllByDNSZoneHandleResponse(resp *http.Response) (RecordSetsClientListAllByDNSZoneResponse, error) { + result := RecordSetsClientListAllByDNSZoneResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecordSetListResult); err != nil { + return RecordSetsClientListAllByDNSZoneResponse{}, err + } + return result, nil +} + +// NewListByDNSZonePager - Lists all record sets in a DNS zone. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - options - RecordSetsClientListByDNSZoneOptions contains the optional parameters for the RecordSetsClient.NewListByDNSZonePager +// method. +func (client *RecordSetsClient) NewListByDNSZonePager(resourceGroupName string, zoneName string, options *RecordSetsClientListByDNSZoneOptions) *runtime.Pager[RecordSetsClientListByDNSZoneResponse] { + return runtime.NewPager(runtime.PagingHandler[RecordSetsClientListByDNSZoneResponse]{ + More: func(page RecordSetsClientListByDNSZoneResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RecordSetsClientListByDNSZoneResponse) (RecordSetsClientListByDNSZoneResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RecordSetsClient.NewListByDNSZonePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByDNSZoneCreateRequest(ctx, resourceGroupName, zoneName, options) + }, nil) + if err != nil { + return RecordSetsClientListByDNSZoneResponse{}, err + } + return client.listByDNSZoneHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByDNSZoneCreateRequest creates the ListByDNSZone request. +func (client *RecordSetsClient) listByDNSZoneCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, options *RecordSetsClientListByDNSZoneOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Recordsetnamesuffix != nil { + reqQP.Set("$recordsetnamesuffix", *options.Recordsetnamesuffix) + } + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDNSZoneHandleResponse handles the ListByDNSZone response. +func (client *RecordSetsClient) listByDNSZoneHandleResponse(resp *http.Response) (RecordSetsClientListByDNSZoneResponse, error) { + result := RecordSetsClientListByDNSZoneResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecordSetListResult); err != nil { + return RecordSetsClientListByDNSZoneResponse{}, err + } + return result, nil +} + +// NewListByTypePager - Lists the record sets of a specified type in a DNS zone. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - recordType - The type of record sets to enumerate. +// - options - RecordSetsClientListByTypeOptions contains the optional parameters for the RecordSetsClient.NewListByTypePager +// method. +func (client *RecordSetsClient) NewListByTypePager(resourceGroupName string, zoneName string, recordType RecordType, options *RecordSetsClientListByTypeOptions) *runtime.Pager[RecordSetsClientListByTypeResponse] { + return runtime.NewPager(runtime.PagingHandler[RecordSetsClientListByTypeResponse]{ + More: func(page RecordSetsClientListByTypeResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RecordSetsClientListByTypeResponse) (RecordSetsClientListByTypeResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RecordSetsClient.NewListByTypePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByTypeCreateRequest(ctx, resourceGroupName, zoneName, recordType, options) + }, nil) + if err != nil { + return RecordSetsClientListByTypeResponse{}, err + } + return client.listByTypeHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByTypeCreateRequest creates the ListByType request. +func (client *RecordSetsClient) listByTypeCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, options *RecordSetsClientListByTypeOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + if recordType == "" { + return nil, errors.New("parameter recordType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{recordType}", url.PathEscape(string(recordType))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Recordsetnamesuffix != nil { + reqQP.Set("$recordsetnamesuffix", *options.Recordsetnamesuffix) + } + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByTypeHandleResponse handles the ListByType response. +func (client *RecordSetsClient) listByTypeHandleResponse(resp *http.Response) (RecordSetsClientListByTypeResponse, error) { + result := RecordSetsClientListByTypeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecordSetListResult); err != nil { + return RecordSetsClientListByTypeResponse{}, err + } + return result, nil +} + +// Update - Updates a record set within a DNS zone. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - relativeRecordSetName - The name of the record set, relative to the name of the zone. +// - recordType - The type of DNS record in this record set. +// - parameters - Parameters supplied to the Update operation. +// - options - RecordSetsClientUpdateOptions contains the optional parameters for the RecordSetsClient.Update method. +func (client *RecordSetsClient) Update(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, options *RecordSetsClientUpdateOptions) (RecordSetsClientUpdateResponse, error) { + var err error + const operationName = "RecordSetsClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, options) + if err != nil { + return RecordSetsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecordSetsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RecordSetsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *RecordSetsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, options *RecordSetsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + urlPath = strings.ReplaceAll(urlPath, "{relativeRecordSetName}", relativeRecordSetName) + if recordType == "" { + return nil, errors.New("parameter recordType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{recordType}", url.PathEscape(string(recordType))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *RecordSetsClient) updateHandleResponse(resp *http.Response) (RecordSetsClientUpdateResponse, error) { + result := RecordSetsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecordSet); err != nil { + return RecordSetsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/resourcereference_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/resourcereference_client.go new file mode 100644 index 00000000000..215f43b1641 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/resourcereference_client.go @@ -0,0 +1,103 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ResourceReferenceClient contains the methods for the DNSResourceReference group. +// Don't use this type directly, use NewResourceReferenceClient() instead. +type ResourceReferenceClient struct { + internal *arm.Client + subscriptionID string +} + +// NewResourceReferenceClient creates a new instance of ResourceReferenceClient with the specified values. +// - subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewResourceReferenceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceReferenceClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ResourceReferenceClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// GetByTargetResources - Returns the DNS records specified by the referencing targetResourceIds. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - parameters - Properties for dns resource reference request. +// - options - ResourceReferenceClientGetByTargetResourcesOptions contains the optional parameters for the ResourceReferenceClient.GetByTargetResources +// method. +func (client *ResourceReferenceClient) GetByTargetResources(ctx context.Context, parameters ResourceReferenceRequest, options *ResourceReferenceClientGetByTargetResourcesOptions) (ResourceReferenceClientGetByTargetResourcesResponse, error) { + var err error + const operationName = "ResourceReferenceClient.GetByTargetResources" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByTargetResourcesCreateRequest(ctx, parameters, options) + if err != nil { + return ResourceReferenceClientGetByTargetResourcesResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ResourceReferenceClientGetByTargetResourcesResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceReferenceClientGetByTargetResourcesResponse{}, err + } + resp, err := client.getByTargetResourcesHandleResponse(httpResp) + return resp, err +} + +// getByTargetResourcesCreateRequest creates the GetByTargetResources request. +func (client *ResourceReferenceClient) getByTargetResourcesCreateRequest(ctx context.Context, parameters ResourceReferenceRequest, options *ResourceReferenceClientGetByTargetResourcesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// getByTargetResourcesHandleResponse handles the GetByTargetResources response. +func (client *ResourceReferenceClient) getByTargetResourcesHandleResponse(resp *http.Response) (ResourceReferenceClientGetByTargetResourcesResponse, error) { + result := ResourceReferenceClientGetByTargetResourcesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceReferenceResult); err != nil { + return ResourceReferenceClientGetByTargetResourcesResponse{}, err + } + return result, nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/response_types.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/response_types.go new file mode 100644 index 00000000000..ccf318d38be --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/response_types.go @@ -0,0 +1,91 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +// RecordSetsClientCreateOrUpdateResponse contains the response from method RecordSetsClient.CreateOrUpdate. +type RecordSetsClientCreateOrUpdateResponse struct { + // Describes a DNS record set (a collection of DNS records with the same name and type). + RecordSet +} + +// RecordSetsClientDeleteResponse contains the response from method RecordSetsClient.Delete. +type RecordSetsClientDeleteResponse struct { + // placeholder for future response values +} + +// RecordSetsClientGetResponse contains the response from method RecordSetsClient.Get. +type RecordSetsClientGetResponse struct { + // Describes a DNS record set (a collection of DNS records with the same name and type). + RecordSet +} + +// RecordSetsClientListAllByDNSZoneResponse contains the response from method RecordSetsClient.NewListAllByDNSZonePager. +type RecordSetsClientListAllByDNSZoneResponse struct { + // The response to a record set List operation. + RecordSetListResult +} + +// RecordSetsClientListByDNSZoneResponse contains the response from method RecordSetsClient.NewListByDNSZonePager. +type RecordSetsClientListByDNSZoneResponse struct { + // The response to a record set List operation. + RecordSetListResult +} + +// RecordSetsClientListByTypeResponse contains the response from method RecordSetsClient.NewListByTypePager. +type RecordSetsClientListByTypeResponse struct { + // The response to a record set List operation. + RecordSetListResult +} + +// RecordSetsClientUpdateResponse contains the response from method RecordSetsClient.Update. +type RecordSetsClientUpdateResponse struct { + // Describes a DNS record set (a collection of DNS records with the same name and type). + RecordSet +} + +// ResourceReferenceClientGetByTargetResourcesResponse contains the response from method ResourceReferenceClient.GetByTargetResources. +type ResourceReferenceClientGetByTargetResourcesResponse struct { + // Represents the properties of the Dns Resource Reference Result. + ResourceReferenceResult +} + +// ZonesClientCreateOrUpdateResponse contains the response from method ZonesClient.CreateOrUpdate. +type ZonesClientCreateOrUpdateResponse struct { + // Describes a DNS zone. + Zone +} + +// ZonesClientDeleteResponse contains the response from method ZonesClient.BeginDelete. +type ZonesClientDeleteResponse struct { + // placeholder for future response values +} + +// ZonesClientGetResponse contains the response from method ZonesClient.Get. +type ZonesClientGetResponse struct { + // Describes a DNS zone. + Zone +} + +// ZonesClientListByResourceGroupResponse contains the response from method ZonesClient.NewListByResourceGroupPager. +type ZonesClientListByResourceGroupResponse struct { + // The response to a Zone List or ListAll operation. + ZoneListResult +} + +// ZonesClientListResponse contains the response from method ZonesClient.NewListPager. +type ZonesClientListResponse struct { + // The response to a Zone List or ListAll operation. + ZoneListResult +} + +// ZonesClientUpdateResponse contains the response from method ZonesClient.Update. +type ZonesClientUpdateResponse struct { + // Describes a DNS zone. + Zone +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/zones_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/zones_client.go new file mode 100644 index 00000000000..08bdcbf42d9 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns/zones_client.go @@ -0,0 +1,452 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdns + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ZonesClient contains the methods for the Zones group. +// Don't use this type directly, use NewZonesClient() instead. +type ZonesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewZonesClient creates a new instance of ZonesClient with the specified values. +// - subscriptionID - Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewZonesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ZonesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ZonesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a DNS zone. Does not modify DNS records within the zone. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - parameters - Parameters supplied to the CreateOrUpdate operation. +// - options - ZonesClientCreateOrUpdateOptions contains the optional parameters for the ZonesClient.CreateOrUpdate method. +func (client *ZonesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, parameters Zone, options *ZonesClientCreateOrUpdateOptions) (ZonesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ZonesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, zoneName, parameters, options) + if err != nil { + return ZonesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ZonesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ZonesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ZonesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, parameters Zone, options *ZonesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if options != nil && options.IfNoneMatch != nil { + req.Raw().Header["If-None-Match"] = []string{*options.IfNoneMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ZonesClient) createOrUpdateHandleResponse(resp *http.Response) (ZonesClientCreateOrUpdateResponse, error) { + result := ZonesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Zone); err != nil { + return ZonesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - options - ZonesClientBeginDeleteOptions contains the optional parameters for the ZonesClient.BeginDelete method. +func (client *ZonesClient) BeginDelete(ctx context.Context, resourceGroupName string, zoneName string, options *ZonesClientBeginDeleteOptions) (*runtime.Poller[ZonesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, zoneName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ZonesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ZonesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +func (client *ZonesClient) deleteOperation(ctx context.Context, resourceGroupName string, zoneName string, options *ZonesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ZonesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, zoneName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ZonesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, options *ZonesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - options - ZonesClientGetOptions contains the optional parameters for the ZonesClient.Get method. +func (client *ZonesClient) Get(ctx context.Context, resourceGroupName string, zoneName string, options *ZonesClientGetOptions) (ZonesClientGetResponse, error) { + var err error + const operationName = "ZonesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, zoneName, options) + if err != nil { + return ZonesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ZonesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ZonesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ZonesClient) getCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, options *ZonesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ZonesClient) getHandleResponse(resp *http.Response) (ZonesClientGetResponse, error) { + result := ZonesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Zone); err != nil { + return ZonesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists the DNS zones in all resource groups in a subscription. +// +// Generated from API version 2018-05-01 +// - options - ZonesClientListOptions contains the optional parameters for the ZonesClient.NewListPager method. +func (client *ZonesClient) NewListPager(options *ZonesClientListOptions) *runtime.Pager[ZonesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ZonesClientListResponse]{ + More: func(page ZonesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ZonesClientListResponse) (ZonesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ZonesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return ZonesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ZonesClient) listCreateRequest(ctx context.Context, options *ZonesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ZonesClient) listHandleResponse(resp *http.Response) (ZonesClientListResponse, error) { + result := ZonesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ZoneListResult); err != nil { + return ZonesClientListResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists the DNS zones within a resource group. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - options - ZonesClientListByResourceGroupOptions contains the optional parameters for the ZonesClient.NewListByResourceGroupPager +// method. +func (client *ZonesClient) NewListByResourceGroupPager(resourceGroupName string, options *ZonesClientListByResourceGroupOptions) *runtime.Pager[ZonesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ZonesClientListByResourceGroupResponse]{ + More: func(page ZonesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ZonesClientListByResourceGroupResponse) (ZonesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ZonesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ZonesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ZonesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ZonesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" + 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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ZonesClient) listByResourceGroupHandleResponse(resp *http.Response) (ZonesClientListByResourceGroupResponse, error) { + result := ZonesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ZoneListResult); err != nil { + return ZonesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// Update - Updates a DNS zone. Does not modify DNS records within the zone. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2018-05-01 +// - resourceGroupName - The name of the resource group. +// - zoneName - The name of the DNS zone (without a terminating dot). +// - parameters - Parameters supplied to the Update operation. +// - options - ZonesClientUpdateOptions contains the optional parameters for the ZonesClient.Update method. +func (client *ZonesClient) Update(ctx context.Context, resourceGroupName string, zoneName string, parameters ZoneUpdate, options *ZonesClientUpdateOptions) (ZonesClientUpdateResponse, error) { + var err error + const operationName = "ZonesClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, zoneName, parameters, options) + if err != nil { + return ZonesClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ZonesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ZonesClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *ZonesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, zoneName string, parameters ZoneUpdate, options *ZonesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if zoneName == "" { + return nil, errors.New("parameter zoneName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{zoneName}", url.PathEscape(zoneName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2018-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *ZonesClient) updateHandleResponse(resp *http.Response) (ZonesClientUpdateResponse, error) { + result := ZonesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Zone); err != nil { + return ZonesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 26ca96fcbbb..5f8f95cea10 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,6 +60,9 @@ github.com/Azure/azure-sdk-for-go/sdk/internal/uuid # github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2 v2.5.0 ## explicit; go 1.18 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2 +# github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 +## explicit; go 1.18 +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns # github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.4.0 ## explicit; go 1.18 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault