diff --git a/pkg/azclient/Makefile b/pkg/azclient/Makefile index 6fa4b463ce..8ef8fe6756 100644 --- a/pkg/azclient/Makefile +++ b/pkg/azclient/Makefile @@ -102,6 +102,7 @@ generatecode: build ## Generate client $(TYPESCAFFOLD) --package github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9 --package-alias armnetwork --resource PrivateLinkService --client-name PrivateLinkServicesClient --verbs get,createorupdate,delete,list --expand --ratelimitkey privateLinkServiceRateLimit $(TYPESCAFFOLD) --package github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9 --package-alias armnetwork --resource IPGroup --client-name IPGroupsClient --verbs get,createorupdate,delete,listbyrg --expand --ratelimitkey ipGroupRateLimit $(TYPESCAFFOLD) --package github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9 --package-alias armnetwork --resource NatGateway --client-name NatGatewaysClient --verbs get,createorupdate,delete,list --expand --ratelimitkey natGatewayRateLimit + $(TYPESCAFFOLD) --package github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9 --package-alias armnetwork --resource ServiceGateway --client-name ServiceGatewaysClient --verbs get,createorupdate,delete,list --ratelimitkey serviceGatewayRateLimit $(TYPESCAFFOLD) --package github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage --package-alias armstorage --resource Account --client-name AccountsClient --verbs listbyrg --expand --ratelimitkey storageAccountRateLimit $(TYPESCAFFOLD) --package github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns --package-alias armprivatedns --resource PrivateZone --client-name PrivateZonesClient --verbs get,createorupdate --ratelimitkey privateDNSRateLimit $(TYPESCAFFOLD) --package github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns --package-alias armprivatedns --resource PrivateZone --subresource VirtualNetworkLink --client-name VirtualNetworkLinksClient --verbs get,createorupdate --ratelimitkey virtualNetworkRateLimit diff --git a/pkg/azclient/factory.go b/pkg/azclient/factory.go index e294b520b2..184800f070 100644 --- a/pkg/azclient/factory.go +++ b/pkg/azclient/factory.go @@ -46,6 +46,7 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/azclient/routetableclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/secretclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/securitygroupclient" + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/servicegatewayclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/snapshotclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/sshpublickeyresourceclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/subnetclient" @@ -92,6 +93,7 @@ type ClientFactory interface { GetRouteTableClient() routetableclient.Interface GetSecretClient() secretclient.Interface GetSecurityGroupClient() securitygroupclient.Interface + GetServiceGatewayClient() servicegatewayclient.Interface GetSnapshotClient() snapshotclient.Interface GetSnapshotClientForSub(subscriptionID string) (snapshotclient.Interface, error) GetSSHPublicKeyResourceClient() sshpublickeyresourceclient.Interface diff --git a/pkg/azclient/factory_gen.go b/pkg/azclient/factory_gen.go index e46fc1cdc2..d257d66460 100644 --- a/pkg/azclient/factory_gen.go +++ b/pkg/azclient/factory_gen.go @@ -55,6 +55,7 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/azclient/routetableclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/secretclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/securitygroupclient" + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/servicegatewayclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/snapshotclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/sshpublickeyresourceclient" "sigs.k8s.io/cloud-provider-azure/pkg/azclient/subnetclient" @@ -101,6 +102,7 @@ type ClientFactoryImpl struct { routetableclientInterface routetableclient.Interface secretclientInterface secretclient.Interface securitygroupclientInterface securitygroupclient.Interface + servicegatewayclientInterface servicegatewayclient.Interface snapshotclientInterface sync.Map sshpublickeyresourceclientInterface sshpublickeyresourceclient.Interface subnetclientInterface subnetclient.Interface @@ -298,6 +300,12 @@ func NewClientFactory(config *ClientFactoryConfig, armConfig *ARMClientConfig, c return nil, err } + //initialize servicegatewayclient + factory.servicegatewayclientInterface, err = factory.createServiceGatewayClient(config.SubscriptionID) + if err != nil { + return nil, err + } + //initialize snapshotclient _, err = factory.GetSnapshotClientForSub(config.SubscriptionID) if err != nil { @@ -1138,6 +1146,31 @@ func (factory *ClientFactoryImpl) GetSecurityGroupClient() securitygroupclient.I return factory.securitygroupclientInterface } +func (factory *ClientFactoryImpl) createServiceGatewayClient(subscription string) (servicegatewayclient.Interface, error) { + //initialize servicegatewayclient + options, err := GetDefaultResourceClientOption(factory.armConfig) + if err != nil { + return nil, err + } + options.Cloud = factory.cloudConfig + //add ratelimit policy + ratelimitOption := factory.factoryConfig.GetRateLimitConfig("serviceGatewayRateLimit") + rateLimitPolicy := ratelimit.NewRateLimitPolicy(ratelimitOption) + if rateLimitPolicy != nil { + options.ClientOptions.PerCallPolicies = append(options.ClientOptions.PerCallPolicies, rateLimitPolicy) + } + for _, optionMutFn := range factory.clientOptionsMutFn { + if optionMutFn != nil { + optionMutFn(options) + } + } + return servicegatewayclient.New(subscription, factory.cred, options) +} + +func (factory *ClientFactoryImpl) GetServiceGatewayClient() servicegatewayclient.Interface { + return factory.servicegatewayclientInterface +} + func (factory *ClientFactoryImpl) createSnapshotClient(subscription string) (snapshotclient.Interface, error) { //initialize snapshotclient options, err := GetDefaultResourceClientOption(factory.armConfig) diff --git a/pkg/azclient/factory_test.go b/pkg/azclient/factory_test.go index 4d6ed42648..11748e58ee 100644 --- a/pkg/azclient/factory_test.go +++ b/pkg/azclient/factory_test.go @@ -221,6 +221,13 @@ var _ = ginkgo.Describe("Factory", func() { client := factory.GetSecurityGroupClient() gomega.Expect(client).NotTo(gomega.BeNil()) }) + ginkgo.It("should create factory instance without painc - ServiceGateway", func() { + factory, err := NewClientFactory(nil, nil, cloud.AzurePublic, nil) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + gomega.Expect(factory).NotTo(gomega.BeNil()) + client := factory.GetServiceGatewayClient() + gomega.Expect(client).NotTo(gomega.BeNil()) + }) ginkgo.It("should create factory instance without painc - Snapshot", func() { factory, err := NewClientFactory(nil, nil, cloud.AzurePublic, nil) gomega.Expect(err).NotTo(gomega.HaveOccurred()) diff --git a/pkg/azclient/mock_azclient/interface.go b/pkg/azclient/mock_azclient/interface.go index f50584f291..ee7a6046ac 100644 --- a/pkg/azclient/mock_azclient/interface.go +++ b/pkg/azclient/mock_azclient/interface.go @@ -59,6 +59,7 @@ import ( routetableclient "sigs.k8s.io/cloud-provider-azure/pkg/azclient/routetableclient" secretclient "sigs.k8s.io/cloud-provider-azure/pkg/azclient/secretclient" securitygroupclient "sigs.k8s.io/cloud-provider-azure/pkg/azclient/securitygroupclient" + servicegatewayclient "sigs.k8s.io/cloud-provider-azure/pkg/azclient/servicegatewayclient" snapshotclient "sigs.k8s.io/cloud-provider-azure/pkg/azclient/snapshotclient" sshpublickeyresourceclient "sigs.k8s.io/cloud-provider-azure/pkg/azclient/sshpublickeyresourceclient" subnetclient "sigs.k8s.io/cloud-provider-azure/pkg/azclient/subnetclient" @@ -590,6 +591,20 @@ func (mr *MockClientFactoryMockRecorder) GetSecurityGroupClient() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSecurityGroupClient", reflect.TypeOf((*MockClientFactory)(nil).GetSecurityGroupClient)) } +// GetServiceGatewayClient mocks base method. +func (m *MockClientFactory) GetServiceGatewayClient() servicegatewayclient.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetServiceGatewayClient") + ret0, _ := ret[0].(servicegatewayclient.Interface) + return ret0 +} + +// GetServiceGatewayClient indicates an expected call of GetServiceGatewayClient. +func (mr *MockClientFactoryMockRecorder) GetServiceGatewayClient() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServiceGatewayClient", reflect.TypeOf((*MockClientFactory)(nil).GetServiceGatewayClient)) +} + // GetSnapshotClient mocks base method. func (m *MockClientFactory) GetSnapshotClient() snapshotclient.Interface { m.ctrl.T.Helper() diff --git a/pkg/azclient/servicegatewayclient/custom.go b/pkg/azclient/servicegatewayclient/custom.go new file mode 100644 index 0000000000..c6a3f26c11 --- /dev/null +++ b/pkg/azclient/servicegatewayclient/custom.go @@ -0,0 +1,104 @@ +/* +Copyright 2026 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package servicegatewayclient + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9" + + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/metrics" + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/utils" +) + +const UpdateTagsOperationName = "ServiceGatewaysClient.UpdateTags" + +// UpdateTags updates the tags of a ServiceGateway. +func (client *Client) UpdateTags(ctx context.Context, resourceGroupName string, serviceGatewayName string, parameters armnetwork.TagsObject) (result *armnetwork.ServiceGateway, err error) { + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "update_tags") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, UpdateTagsOperationName, client.tracer, nil) + defer endSpan(err) + resp, err := client.ServiceGatewaysClient.UpdateTags(ctx, resourceGroupName, serviceGatewayName, parameters, nil) + if err != nil { + return nil, err + } + return &resp.ServiceGateway, nil +} + +const GetAddressLocationsOperationName = "ServiceGatewaysClient.GetAddressLocations" + +// GetAddressLocations gets the address locations of a ServiceGateway. +func (client *Client) GetAddressLocations(ctx context.Context, resourceGroupName string, serviceGatewayName string) (result []*armnetwork.ServiceGatewayAddressLocationResponse, err error) { + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "get_address_locations") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, GetAddressLocationsOperationName, client.tracer, nil) + defer endSpan(err) + pager := client.NewGetAddressLocationsPager(resourceGroupName, serviceGatewayName, nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + return nil, err + } + result = append(result, nextResult.Value...) + } + return result, nil +} + +const GetServicesOperationName = "ServiceGatewaysClient.GetServices" + +// GetServices gets the services of a ServiceGateway. +func (client *Client) GetServices(ctx context.Context, resourceGroupName string, serviceGatewayName string) (result []*armnetwork.ServiceGatewayService, err error) { + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "get_services") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, GetServicesOperationName, client.tracer, nil) + defer endSpan(err) + pager := client.NewGetServicesPager(resourceGroupName, serviceGatewayName, nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + return nil, err + } + result = append(result, nextResult.Value...) + } + return result, nil +} + +const UpdateAddressLocationsOperationName = "ServiceGatewaysClient.UpdateAddressLocations" + +// UpdateAddressLocations updates the address locations of a ServiceGateway. +func (client *Client) UpdateAddressLocations(ctx context.Context, resourceGroupName string, serviceGatewayName string, parameters armnetwork.ServiceGatewayUpdateAddressLocationsRequest) (err error) { + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "update_address_locations") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, UpdateAddressLocationsOperationName, client.tracer, nil) + defer endSpan(err) + _, err = utils.NewPollerWrapper(client.BeginUpdateAddressLocations(ctx, resourceGroupName, serviceGatewayName, parameters, nil)).WaitforPollerResp(ctx) + return err +} + +const UpdateServicesOperationName = "ServiceGatewaysClient.UpdateServices" + +// UpdateServices updates the services of a ServiceGateway. +func (client *Client) UpdateServices(ctx context.Context, resourceGroupName string, serviceGatewayName string, parameters armnetwork.ServiceGatewayUpdateServicesRequest) (err error) { + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "update_services") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, UpdateServicesOperationName, client.tracer, nil) + defer endSpan(err) + _, err = utils.NewPollerWrapper(client.BeginUpdateServices(ctx, resourceGroupName, serviceGatewayName, parameters, nil)).WaitforPollerResp(ctx) + return err +} diff --git a/pkg/azclient/servicegatewayclient/interface.go b/pkg/azclient/servicegatewayclient/interface.go new file mode 100644 index 0000000000..ce658ac7cb --- /dev/null +++ b/pkg/azclient/servicegatewayclient/interface.go @@ -0,0 +1,39 @@ +/* +Copyright 2026 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +azure:enableclientgen:=true +package servicegatewayclient + +import ( + "context" + + armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9" + + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/utils" +) + +// +azure:client:verbs=get;createorupdate;delete;list,resource=ServiceGateway,packageName=github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9,packageAlias=armnetwork,clientName=ServiceGatewaysClient,expand=false,rateLimitKey=serviceGatewayRateLimit +type Interface interface { + utils.GetFunc[armnetwork.ServiceGateway] + utils.CreateOrUpdateFunc[armnetwork.ServiceGateway] + utils.DeleteFunc[armnetwork.ServiceGateway] + utils.ListFunc[armnetwork.ServiceGateway] + UpdateTags(ctx context.Context, resourceGroupName string, serviceGatewayName string, parameters armnetwork.TagsObject) (*armnetwork.ServiceGateway, error) + GetAddressLocations(ctx context.Context, resourceGroupName string, serviceGatewayName string) ([]*armnetwork.ServiceGatewayAddressLocationResponse, error) + GetServices(ctx context.Context, resourceGroupName string, serviceGatewayName string) ([]*armnetwork.ServiceGatewayService, error) + UpdateAddressLocations(ctx context.Context, resourceGroupName string, serviceGatewayName string, parameters armnetwork.ServiceGatewayUpdateAddressLocationsRequest) error + UpdateServices(ctx context.Context, resourceGroupName string, serviceGatewayName string, parameters armnetwork.ServiceGatewayUpdateServicesRequest) error +} diff --git a/pkg/azclient/servicegatewayclient/interface_gomock.go b/pkg/azclient/servicegatewayclient/interface_gomock.go new file mode 100644 index 0000000000..6bb7e7859b --- /dev/null +++ b/pkg/azclient/servicegatewayclient/interface_gomock.go @@ -0,0 +1,25 @@ +// /* +// Copyright The Kubernetes Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// */ + +// Code generated by client-gen. DO NOT EDIT. +package servicegatewayclient + +import ( + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/servicegatewayclient/mock_servicegatewayclient" +) + +// Code generated by MockGen. DO NOT EDIT. +var _ Interface = &mock_servicegatewayclient.MockInterface{} diff --git a/pkg/azclient/servicegatewayclient/mock_servicegatewayclient/interface.go b/pkg/azclient/servicegatewayclient/mock_servicegatewayclient/interface.go new file mode 100644 index 0000000000..90172abac2 --- /dev/null +++ b/pkg/azclient/servicegatewayclient/mock_servicegatewayclient/interface.go @@ -0,0 +1,409 @@ +// /* +// Copyright The Kubernetes Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// */ +// + +// Code generated by MockGen. DO NOT EDIT. +// Source: servicegatewayclient/interface.go +// +// Generated by this command: +// +// mockgen -package mock_servicegatewayclient -source servicegatewayclient/interface.go -typed -write_generate_directive -copyright_file ../../hack/boilerplate/boilerplate.generatego.txt +// + +// Package mock_servicegatewayclient is a generated GoMock package. +package mock_servicegatewayclient + +import ( + context "context" + reflect "reflect" + + armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9" + gomock "go.uber.org/mock/gomock" +) + +//go:generate mockgen -package mock_servicegatewayclient -source servicegatewayclient/interface.go -typed -write_generate_directive -copyright_file ../../hack/boilerplate/boilerplate.generatego.txt + +// MockInterface is a mock of Interface interface. +type MockInterface struct { + ctrl *gomock.Controller + recorder *MockInterfaceMockRecorder + isgomock struct{} +} + +// MockInterfaceMockRecorder is the mock recorder for MockInterface. +type MockInterfaceMockRecorder struct { + mock *MockInterface +} + +// NewMockInterface creates a new mock instance. +func NewMockInterface(ctrl *gomock.Controller) *MockInterface { + mock := &MockInterface{ctrl: ctrl} + mock.recorder = &MockInterfaceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder { + return m.recorder +} + +// CreateOrUpdate mocks base method. +func (m *MockInterface) CreateOrUpdate(ctx context.Context, resourceGroupName, resourceName string, resourceParam armnetwork.ServiceGateway) (*armnetwork.ServiceGateway, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateOrUpdate", ctx, resourceGroupName, resourceName, resourceParam) + ret0, _ := ret[0].(*armnetwork.ServiceGateway) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateOrUpdate indicates an expected call of CreateOrUpdate. +func (mr *MockInterfaceMockRecorder) CreateOrUpdate(ctx, resourceGroupName, resourceName, resourceParam any) *MockInterfaceCreateOrUpdateCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdate", reflect.TypeOf((*MockInterface)(nil).CreateOrUpdate), ctx, resourceGroupName, resourceName, resourceParam) + return &MockInterfaceCreateOrUpdateCall{Call: call} +} + +// MockInterfaceCreateOrUpdateCall wrap *gomock.Call +type MockInterfaceCreateOrUpdateCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceCreateOrUpdateCall) Return(arg0 *armnetwork.ServiceGateway, arg1 error) *MockInterfaceCreateOrUpdateCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceCreateOrUpdateCall) Do(f func(context.Context, string, string, armnetwork.ServiceGateway) (*armnetwork.ServiceGateway, error)) *MockInterfaceCreateOrUpdateCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceCreateOrUpdateCall) DoAndReturn(f func(context.Context, string, string, armnetwork.ServiceGateway) (*armnetwork.ServiceGateway, error)) *MockInterfaceCreateOrUpdateCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Delete mocks base method. +func (m *MockInterface) Delete(ctx context.Context, resourceGroupName, resourceName string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", ctx, resourceGroupName, resourceName) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockInterfaceMockRecorder) Delete(ctx, resourceGroupName, resourceName any) *MockInterfaceDeleteCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockInterface)(nil).Delete), ctx, resourceGroupName, resourceName) + return &MockInterfaceDeleteCall{Call: call} +} + +// MockInterfaceDeleteCall wrap *gomock.Call +type MockInterfaceDeleteCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceDeleteCall) Return(arg0 error) *MockInterfaceDeleteCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceDeleteCall) Do(f func(context.Context, string, string) error) *MockInterfaceDeleteCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceDeleteCall) DoAndReturn(f func(context.Context, string, string) error) *MockInterfaceDeleteCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Get mocks base method. +func (m *MockInterface) Get(ctx context.Context, resourceGroupName, resourceName string) (*armnetwork.ServiceGateway, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Get", ctx, resourceGroupName, resourceName) + ret0, _ := ret[0].(*armnetwork.ServiceGateway) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get. +func (mr *MockInterfaceMockRecorder) Get(ctx, resourceGroupName, resourceName any) *MockInterfaceGetCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockInterface)(nil).Get), ctx, resourceGroupName, resourceName) + return &MockInterfaceGetCall{Call: call} +} + +// MockInterfaceGetCall wrap *gomock.Call +type MockInterfaceGetCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceGetCall) Return(result *armnetwork.ServiceGateway, rerr error) *MockInterfaceGetCall { + c.Call = c.Call.Return(result, rerr) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceGetCall) Do(f func(context.Context, string, string) (*armnetwork.ServiceGateway, error)) *MockInterfaceGetCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceGetCall) DoAndReturn(f func(context.Context, string, string) (*armnetwork.ServiceGateway, error)) *MockInterfaceGetCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetAddressLocations mocks base method. +func (m *MockInterface) GetAddressLocations(ctx context.Context, resourceGroupName, serviceGatewayName string) ([]*armnetwork.ServiceGatewayAddressLocationResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAddressLocations", ctx, resourceGroupName, serviceGatewayName) + ret0, _ := ret[0].([]*armnetwork.ServiceGatewayAddressLocationResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAddressLocations indicates an expected call of GetAddressLocations. +func (mr *MockInterfaceMockRecorder) GetAddressLocations(ctx, resourceGroupName, serviceGatewayName any) *MockInterfaceGetAddressLocationsCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAddressLocations", reflect.TypeOf((*MockInterface)(nil).GetAddressLocations), ctx, resourceGroupName, serviceGatewayName) + return &MockInterfaceGetAddressLocationsCall{Call: call} +} + +// MockInterfaceGetAddressLocationsCall wrap *gomock.Call +type MockInterfaceGetAddressLocationsCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceGetAddressLocationsCall) Return(arg0 []*armnetwork.ServiceGatewayAddressLocationResponse, arg1 error) *MockInterfaceGetAddressLocationsCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceGetAddressLocationsCall) Do(f func(context.Context, string, string) ([]*armnetwork.ServiceGatewayAddressLocationResponse, error)) *MockInterfaceGetAddressLocationsCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceGetAddressLocationsCall) DoAndReturn(f func(context.Context, string, string) ([]*armnetwork.ServiceGatewayAddressLocationResponse, error)) *MockInterfaceGetAddressLocationsCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetServices mocks base method. +func (m *MockInterface) GetServices(ctx context.Context, resourceGroupName, serviceGatewayName string) ([]*armnetwork.ServiceGatewayService, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetServices", ctx, resourceGroupName, serviceGatewayName) + ret0, _ := ret[0].([]*armnetwork.ServiceGatewayService) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetServices indicates an expected call of GetServices. +func (mr *MockInterfaceMockRecorder) GetServices(ctx, resourceGroupName, serviceGatewayName any) *MockInterfaceGetServicesCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServices", reflect.TypeOf((*MockInterface)(nil).GetServices), ctx, resourceGroupName, serviceGatewayName) + return &MockInterfaceGetServicesCall{Call: call} +} + +// MockInterfaceGetServicesCall wrap *gomock.Call +type MockInterfaceGetServicesCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceGetServicesCall) Return(arg0 []*armnetwork.ServiceGatewayService, arg1 error) *MockInterfaceGetServicesCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceGetServicesCall) Do(f func(context.Context, string, string) ([]*armnetwork.ServiceGatewayService, error)) *MockInterfaceGetServicesCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceGetServicesCall) DoAndReturn(f func(context.Context, string, string) ([]*armnetwork.ServiceGatewayService, error)) *MockInterfaceGetServicesCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// List mocks base method. +func (m *MockInterface) List(ctx context.Context, resourceGroupName string) ([]*armnetwork.ServiceGateway, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "List", ctx, resourceGroupName) + ret0, _ := ret[0].([]*armnetwork.ServiceGateway) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockInterfaceMockRecorder) List(ctx, resourceGroupName any) *MockInterfaceListCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockInterface)(nil).List), ctx, resourceGroupName) + return &MockInterfaceListCall{Call: call} +} + +// MockInterfaceListCall wrap *gomock.Call +type MockInterfaceListCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceListCall) Return(result []*armnetwork.ServiceGateway, rerr error) *MockInterfaceListCall { + c.Call = c.Call.Return(result, rerr) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceListCall) Do(f func(context.Context, string) ([]*armnetwork.ServiceGateway, error)) *MockInterfaceListCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceListCall) DoAndReturn(f func(context.Context, string) ([]*armnetwork.ServiceGateway, error)) *MockInterfaceListCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// UpdateAddressLocations mocks base method. +func (m *MockInterface) UpdateAddressLocations(ctx context.Context, resourceGroupName, serviceGatewayName string, parameters armnetwork.ServiceGatewayUpdateAddressLocationsRequest) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateAddressLocations", ctx, resourceGroupName, serviceGatewayName, parameters) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateAddressLocations indicates an expected call of UpdateAddressLocations. +func (mr *MockInterfaceMockRecorder) UpdateAddressLocations(ctx, resourceGroupName, serviceGatewayName, parameters any) *MockInterfaceUpdateAddressLocationsCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAddressLocations", reflect.TypeOf((*MockInterface)(nil).UpdateAddressLocations), ctx, resourceGroupName, serviceGatewayName, parameters) + return &MockInterfaceUpdateAddressLocationsCall{Call: call} +} + +// MockInterfaceUpdateAddressLocationsCall wrap *gomock.Call +type MockInterfaceUpdateAddressLocationsCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceUpdateAddressLocationsCall) Return(arg0 error) *MockInterfaceUpdateAddressLocationsCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceUpdateAddressLocationsCall) Do(f func(context.Context, string, string, armnetwork.ServiceGatewayUpdateAddressLocationsRequest) error) *MockInterfaceUpdateAddressLocationsCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceUpdateAddressLocationsCall) DoAndReturn(f func(context.Context, string, string, armnetwork.ServiceGatewayUpdateAddressLocationsRequest) error) *MockInterfaceUpdateAddressLocationsCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// UpdateServices mocks base method. +func (m *MockInterface) UpdateServices(ctx context.Context, resourceGroupName, serviceGatewayName string, parameters armnetwork.ServiceGatewayUpdateServicesRequest) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateServices", ctx, resourceGroupName, serviceGatewayName, parameters) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateServices indicates an expected call of UpdateServices. +func (mr *MockInterfaceMockRecorder) UpdateServices(ctx, resourceGroupName, serviceGatewayName, parameters any) *MockInterfaceUpdateServicesCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateServices", reflect.TypeOf((*MockInterface)(nil).UpdateServices), ctx, resourceGroupName, serviceGatewayName, parameters) + return &MockInterfaceUpdateServicesCall{Call: call} +} + +// MockInterfaceUpdateServicesCall wrap *gomock.Call +type MockInterfaceUpdateServicesCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceUpdateServicesCall) Return(arg0 error) *MockInterfaceUpdateServicesCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceUpdateServicesCall) Do(f func(context.Context, string, string, armnetwork.ServiceGatewayUpdateServicesRequest) error) *MockInterfaceUpdateServicesCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceUpdateServicesCall) DoAndReturn(f func(context.Context, string, string, armnetwork.ServiceGatewayUpdateServicesRequest) error) *MockInterfaceUpdateServicesCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// UpdateTags mocks base method. +func (m *MockInterface) UpdateTags(ctx context.Context, resourceGroupName, serviceGatewayName string, parameters armnetwork.TagsObject) (*armnetwork.ServiceGateway, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateTags", ctx, resourceGroupName, serviceGatewayName, parameters) + ret0, _ := ret[0].(*armnetwork.ServiceGateway) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateTags indicates an expected call of UpdateTags. +func (mr *MockInterfaceMockRecorder) UpdateTags(ctx, resourceGroupName, serviceGatewayName, parameters any) *MockInterfaceUpdateTagsCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateTags", reflect.TypeOf((*MockInterface)(nil).UpdateTags), ctx, resourceGroupName, serviceGatewayName, parameters) + return &MockInterfaceUpdateTagsCall{Call: call} +} + +// MockInterfaceUpdateTagsCall wrap *gomock.Call +type MockInterfaceUpdateTagsCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceUpdateTagsCall) Return(arg0 *armnetwork.ServiceGateway, arg1 error) *MockInterfaceUpdateTagsCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceUpdateTagsCall) Do(f func(context.Context, string, string, armnetwork.TagsObject) (*armnetwork.ServiceGateway, error)) *MockInterfaceUpdateTagsCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceUpdateTagsCall) DoAndReturn(f func(context.Context, string, string, armnetwork.TagsObject) (*armnetwork.ServiceGateway, error)) *MockInterfaceUpdateTagsCall { + c.Call = c.Call.DoAndReturn(f) + return c +} diff --git a/pkg/azclient/servicegatewayclient/servicegatewayclient_suite_test.go b/pkg/azclient/servicegatewayclient/servicegatewayclient_suite_test.go new file mode 100644 index 0000000000..a23256aa0e --- /dev/null +++ b/pkg/azclient/servicegatewayclient/servicegatewayclient_suite_test.go @@ -0,0 +1,97 @@ +// /* +// Copyright The Kubernetes Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// */ + +// Code generated by client-gen. DO NOT EDIT. +package servicegatewayclient + +import ( + "context" + "testing" + + "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/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/recording" + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/utils" +) + +func TestClient(t *testing.T) { + gomega.RegisterFailHandler(ginkgo.Fail) + ginkgo.RunSpecs(t, "Client Suite") +} + +var resourceGroupName = "aks-cit-ServiceGateway" +var resourceName = "testResource" + +var subscriptionID string +var location string +var resourceGroupClient *armresources.ResourceGroupsClient +var err error +var recorder *recording.Recorder +var cloudConfig *cloud.Configuration +var realClient Interface +var clientOption azcore.ClientOptions + +var _ = ginkgo.BeforeSuite(func(ctx context.Context) { + recorder, cloudConfig, location, err = recording.NewRecorder() + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + subscriptionID = recorder.SubscriptionID() + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + cred := recorder.TokenCredential() + clientOption = azcore.ClientOptions{ + Transport: recorder.HTTPClient(), + TracingProvider: utils.TracingProvider, + Telemetry: policy.TelemetryOptions{ + ApplicationID: "ccm-resource-group-client", + }, + Cloud: *cloudConfig, + } + rgClientOption := clientOption + rgClientOption.Telemetry.ApplicationID = "ccm-resource-group-client" + resourceGroupClient, err = armresources.NewResourceGroupsClient(subscriptionID, cred, &arm.ClientOptions{ + ClientOptions: rgClientOption, + }) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + realClientOption := clientOption + realClientOption.Telemetry.ApplicationID = "ccm-ServiceGateway-client" + realClient, err = New(subscriptionID, recorder.TokenCredential(), &arm.ClientOptions{ + ClientOptions: realClientOption, + }) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + _, err = resourceGroupClient.CreateOrUpdate( + ctx, + resourceGroupName, + armresources.ResourceGroup{ + Location: to.Ptr(location), + }, + nil) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) +}) + +var _ = ginkgo.AfterSuite(func(ctx context.Context) { + poller, err := resourceGroupClient.BeginDelete(ctx, resourceGroupName, nil) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + _, err = poller.PollUntilDone(ctx, nil) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + err = recorder.Stop() + gomega.Expect(err).ToNot(gomega.HaveOccurred()) +}) diff --git a/pkg/azclient/servicegatewayclient/servicegatewayclient_test.go b/pkg/azclient/servicegatewayclient/servicegatewayclient_test.go new file mode 100644 index 0000000000..6dbf5ebf23 --- /dev/null +++ b/pkg/azclient/servicegatewayclient/servicegatewayclient_test.go @@ -0,0 +1,103 @@ +// /* +// Copyright The Kubernetes Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// */ + +// Code generated by client-gen. DO NOT EDIT. +package servicegatewayclient + +import ( + "context" + "strings" + + armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" +) + +var beforeAllFunc func(context.Context) +var afterAllFunc func(context.Context) +var additionalTestCases func() +var newResource *armnetwork.ServiceGateway = &armnetwork.ServiceGateway{} + +var _ = ginkgo.Describe("ServiceGatewaysClient", ginkgo.Ordered, func() { + + if beforeAllFunc != nil { + ginkgo.BeforeAll(beforeAllFunc) + } + + if additionalTestCases != nil { + additionalTestCases() + } + + ginkgo.When("creation requests are raised", func() { + ginkgo.It("should not return error", func(ctx context.Context) { + newResource, err := realClient.CreateOrUpdate(ctx, resourceGroupName, resourceName, *newResource) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + gomega.Expect(newResource).NotTo(gomega.BeNil()) + gomega.Expect(strings.EqualFold(*newResource.Name, resourceName)).To(gomega.BeTrue()) + }) + }) + + ginkgo.When("get requests are raised", func() { + ginkgo.It("should not return error", func(ctx context.Context) { + newResource, err := realClient.Get(ctx, resourceGroupName, resourceName) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + gomega.Expect(newResource).NotTo(gomega.BeNil()) + }) + }) + ginkgo.When("invalid get requests are raised", func() { + ginkgo.It("should return 404 error", func(ctx context.Context) { + newResource, err := realClient.Get(ctx, resourceGroupName, resourceName+"notfound") + gomega.Expect(err).To(gomega.HaveOccurred()) + gomega.Expect(newResource).To(gomega.BeNil()) + }) + }) + + ginkgo.When("update requests are raised", func() { + ginkgo.It("should not return error", func(ctx context.Context) { + newResource, err := realClient.CreateOrUpdate(ctx, resourceGroupName, resourceName, *newResource) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + gomega.Expect(newResource).NotTo(gomega.BeNil()) + }) + }) + + ginkgo.When("list requests are raised", func() { + ginkgo.It("should not return error", func(ctx context.Context) { + resourceList, err := realClient.List(ctx, resourceGroupName) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + gomega.Expect(resourceList).NotTo(gomega.BeNil()) + gomega.Expect(len(resourceList)).To(gomega.Equal(1)) + gomega.Expect(strings.EqualFold(*resourceList[0].Name, resourceName)).To(gomega.BeTrue()) + }) + }) + ginkgo.When("invalid list requests are raised", func() { + ginkgo.It("should return error", func(ctx context.Context) { + resourceList, err := realClient.List(ctx, resourceGroupName+"notfound") + gomega.Expect(err).To(gomega.HaveOccurred()) + gomega.Expect(resourceList).To(gomega.BeNil()) + }) + }) + + ginkgo.When("deletion requests are raised", func() { + ginkgo.It("should not return error", func(ctx context.Context) { + err = realClient.Delete(ctx, resourceGroupName, resourceName) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + }) + }) + + if afterAllFunc != nil { + ginkgo.AfterAll(afterAllFunc) + } +}) diff --git a/pkg/azclient/servicegatewayclient/testdata/AZURECHINACLOUD.yaml b/pkg/azclient/servicegatewayclient/testdata/AZURECHINACLOUD.yaml new file mode 100644 index 0000000000..2033a5e328 --- /dev/null +++ b/pkg/azclient/servicegatewayclient/testdata/AZURECHINACLOUD.yaml @@ -0,0 +1,703 @@ +interactions: +- id: 0 + request: + body: '{"location": "chinaeast2"}' + content_length: 26 + form: {} + headers: + Accept: + - application/json + Content-Length: + - '26' + Content-Type: + - application/json + User-Agent: + - ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: PUT + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/aks-cit-ServiceGateway?api-version=2021-04-01 + response: + body: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway", "name": "aks-cit-ServiceGateway", "type": "Microsoft.Resources/resourceGroups", "location": "chinaeast2", "properties": {"provisioningState": "Succeeded"}}' + code: 201 + content_length: 255 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '255' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 201 Created + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 1 + request: + body: '{}' + content_length: 2 + form: {} + headers: + Accept: + - application/json + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: PUT + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"chinaeast2","properties":{"provisioningState":"Updating"}}' + code: 201 + content_length: 290 + duration: 200ms + headers: + Azure-Asyncoperation: + - https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/chinaeast2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + Cache-Control: + - no-cache + Content-Length: + - '290' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 201 Created + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 2 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/chinaeast2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + response: + body: '{"status":"Succeeded"}' + code: 200 + content_length: 22 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 3 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"chinaeast2","properties":{"provisioningState":"Succeeded"}}' + code: 200 + content_length: 291 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '291' + Content-Type: + - application/json; charset=utf-8 + Etag: + - W/"00000000-0000-0000-0000-000000000000" + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 4 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"chinaeast2","properties":{"provisioningState":"Succeeded"}}' + code: 200 + content_length: 291 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '291' + Content-Type: + - application/json; charset=utf-8 + Etag: + - W/"00000000-0000-0000-0000-000000000000" + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 5 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResourcenotfound?api-version=2025-05-01 + response: + body: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Network/serviceGateways/testResourcenotfound'' under resource group ''aks-cit-ServiceGateway'' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}' + code: 404 + content_length: 248 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '248' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Ms-Failure-Cause: + - gateway + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 404 Not Found + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 6 + request: + body: '{}' + content_length: 2 + form: {} + headers: + Accept: + - application/json + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: PUT + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"chinaeast2","properties":{"provisioningState":"Succeeded"}}' + code: 200 + content_length: 291 + duration: 200ms + headers: + Azure-Asyncoperation: + - https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/chinaeast2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + Cache-Control: + - no-cache + Content-Length: + - '291' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 7 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"chinaeast2","properties":{"provisioningState":"Succeeded"}}' + code: 200 + content_length: 291 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '291' + Content-Type: + - application/json; charset=utf-8 + Etag: + - W/"00000000-0000-0000-0000-000000000000" + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 8 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways?api-version=2025-05-01 + response: + body: '{"value":[{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"chinaeast2","properties":{"provisioningState":"Succeeded"}}]}' + code: 200 + content_length: 303 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '303' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 9 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGatewaynotfound/providers/Microsoft.Network/serviceGateways?api-version=2025-05-01 + response: + body: '{"error":{"code":"ResourceGroupNotFound","message":"Resource group ''aks-cit-ServiceGatewaynotfound'' could not be found."}}' + code: 404 + content_length: 122 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '122' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Ms-Failure-Cause: + - gateway + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 404 Not Found + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 10 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: DELETE + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '' + code: 202 + content_length: 0 + duration: 200ms + headers: + Azure-Asyncoperation: + - https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/chinaeast2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + Cache-Control: + - no-cache + Content-Length: + - '0' + Expires: + - '-1' + Location: + - https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/chinaeast2/operationResults/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 202 Accepted + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 11 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/chinaeast2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + response: + body: '{"status":"Succeeded"}' + code: 200 + content_length: 22 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 12 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: DELETE + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/aks-cit-ServiceGateway?api-version=2021-04-01 + response: + body: '' + code: 202 + content_length: 0 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '0' + Expires: + - '-1' + Location: + - https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BS1M6MkRDSVQ6MkRTRUNVUklUWUdST1VQLUNISU5BRUFTVDIiLCJqb2JMb2NhdGlvbiI6ImNoaW5hZWFzdDIifQ?api-version=2021-04-01&c=c&h=h&s=s&t=t + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 202 Accepted + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 13 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.24.0; linux) + host: management.chinacloudapi.cn + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.chinacloudapi.cn/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BS1M6MkRDSVQ6MkRTRUNVUklUWUdST1VQLUNISU5BRUFTVDIiLCJqb2JMb2NhdGlvbiI6ImNoaW5hZWFzdDIifQ?api-version=2021-04-01&c=c&h=h&s=s&t=t + response: + body: '' + code: 200 + content_length: 0 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '0' + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +version: 2 diff --git a/pkg/azclient/servicegatewayclient/testdata/AZURECLOUD.yaml b/pkg/azclient/servicegatewayclient/testdata/AZURECLOUD.yaml new file mode 100644 index 0000000000..2d14da9fed --- /dev/null +++ b/pkg/azclient/servicegatewayclient/testdata/AZURECLOUD.yaml @@ -0,0 +1,734 @@ +interactions: +- id: 0 + request: + body: '{"location": "eastus2"}' + content_length: 23 + form: {} + headers: + Accept: + - application/json + Content-Length: + - '23' + Content-Type: + - application/json + User-Agent: + - ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.2; linux) + host: management.azure.com + method: PUT + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/aks-cit-ServiceGateway?api-version=2021-04-01 + response: + body: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway", "name": "aks-cit-ServiceGateway", "type": "Microsoft.Resources/resourceGroups", "location": "eastus2", "properties": {"provisioningState": "Succeeded"}}' + code: 201 + content_length: 252 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '252' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Writes: + - '11999' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 201 Created + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 1 + request: + body: '{}' + content_length: 2 + form: {} + headers: + Accept: + - application/json + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: PUT + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"eastus2","properties":{"provisioningState":"Updating"}}' + code: 201 + content_length: 287 + duration: 200ms + headers: + Azure-Asyncnotification: + - Enabled + Azure-Asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + Cache-Control: + - no-cache + Content-Length: + - '287' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Writes: + - '11999' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 201 Created + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 2 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + response: + body: '{"status":"Succeeded"}' + code: 200 + content_length: 22 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Reads: + - '16499' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 3 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"eastus2","properties":{"provisioningState":"Succeeded"}}' + code: 200 + content_length: 288 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '288' + Content-Type: + - application/json; charset=utf-8 + Etag: + - W/"00000000-0000-0000-0000-000000000000" + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Reads: + - '16498' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 4 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"eastus2","properties":{"provisioningState":"Succeeded"}}' + code: 200 + content_length: 288 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '288' + Content-Type: + - application/json; charset=utf-8 + Etag: + - W/"00000000-0000-0000-0000-000000000000" + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Reads: + - '16499' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 5 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResourcenotfound?api-version=2025-05-01 + response: + body: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Network/serviceGateways/testResourcenotfound'' under resource group ''aks-cit-ServiceGateway'' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}' + code: 404 + content_length: 248 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '248' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Failure-Cause: + - gateway + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 404 Not Found + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 6 + request: + body: '{}' + content_length: 2 + form: {} + headers: + Accept: + - application/json + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: PUT + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"eastus2","properties":{"provisioningState":"Succeeded"}}' + code: 200 + content_length: 288 + duration: 200ms + headers: + Azure-Asyncnotification: + - Enabled + Azure-Asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + Cache-Control: + - no-cache + Content-Length: + - '288' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Writes: + - '11999' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 7 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"eastus2","properties":{"provisioningState":"Succeeded"}}' + code: 200 + content_length: 288 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '288' + Content-Type: + - application/json; charset=utf-8 + Etag: + - W/"00000000-0000-0000-0000-000000000000" + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Reads: + - '16499' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 8 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways?api-version=2025-05-01 + response: + body: '{"value":[{"name":"testResource","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource","type":"Microsoft.Network/serviceGateways","location":"eastus2","properties":{"provisioningState":"Succeeded"}}]}' + code: 200 + content_length: 300 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '300' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Reads: + - '16499' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 9 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGatewaynotfound/providers/Microsoft.Network/serviceGateways?api-version=2025-05-01 + response: + body: '{"error":{"code":"ResourceGroupNotFound","message":"Resource group ''aks-cit-ServiceGatewaynotfound'' could not be found."}}' + code: 404 + content_length: 122 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '122' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Failure-Cause: + - gateway + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 404 Not Found + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 10 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: DELETE + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-ServiceGateway/providers/Microsoft.Network/serviceGateways/testResource?api-version=2025-05-01 + response: + body: '' + code: 202 + content_length: 0 + duration: 200ms + headers: + Azure-Asyncnotification: + - Enabled + Azure-Asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + Cache-Control: + - no-cache + Content-Length: + - '0' + Expires: + - '-1' + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2/operationResults/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Deletes: + - '11999' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 202 Accepted + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 11 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-ServiceGateway-client azsdk-go-armnetwork/v9.0.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-05-01&c=c&h=h&s=s&t=t + response: + body: '{"status":"Succeeded"}' + code: 200 + content_length: 22 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Reads: + - '16498' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 12 + request: + body: '' + content_length: 0 + form: {} + headers: + Accept: + - application/json + User-Agent: + - ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.2; linux) + host: management.azure.com + method: DELETE + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/aks-cit-ServiceGateway?api-version=2021-04-01 + response: + body: '' + code: 202 + content_length: 0 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '0' + Expires: + - '-1' + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BS1M6MkRDSVQ6MkRTRUNVUklUWUdST1VQLUVBU1RVUyIsImpvYkxvY2F0aW9uIjoiZWFzdHVzIn0?api-version=2021-04-01&c=c&h=h&s=s&t=t + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Deletes: + - '11999' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 202 Accepted + trailer: {} + transfer_encoding: [] + uncompressed: false +- id: 13 + request: + body: '' + content_length: 0 + form: {} + headers: + User-Agent: + - ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.2; linux) + host: management.azure.com + method: GET + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + remote_addr: '' + request_uri: '' + trailer: {} + transfer_encoding: [] + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BS1M6MkRDSVQ6MkRTRUNVUklUWUdST1VQLUVBU1RVUyIsImpvYkxvY2F0aW9uIjoiZWFzdHVzIn0?api-version=2021-04-01&c=c&h=h&s=s&t=t + response: + body: '' + code: 200 + content_length: 0 + duration: 200ms + headers: + Cache-Control: + - no-cache + Content-Length: + - '0' + Expires: + - '-1' + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Ratelimit-Remaining-Subscription-Global-Reads: + - '16499' + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + status: 200 OK + trailer: {} + transfer_encoding: [] + uncompressed: false +version: 2 diff --git a/pkg/azclient/servicegatewayclient/zz_generated_client.go b/pkg/azclient/servicegatewayclient/zz_generated_client.go new file mode 100644 index 0000000000..2d2abdaea0 --- /dev/null +++ b/pkg/azclient/servicegatewayclient/zz_generated_client.go @@ -0,0 +1,120 @@ +// /* +// Copyright The Kubernetes Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// */ + +// Code generated by client-gen. DO NOT EDIT. +package servicegatewayclient + +import ( + "context" + + "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/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/tracing" + armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9" + + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/metrics" + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/utils" +) + +type Client struct { + *armnetwork.ServiceGatewaysClient + subscriptionID string + tracer tracing.Tracer +} + +func New(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (Interface, error) { + if options == nil { + options = utils.GetDefaultOption() + } + tr := options.TracingProvider.NewTracer(utils.ModuleName, utils.ModuleVersion) + + client, err := armnetwork.NewServiceGatewaysClient(subscriptionID, credential, options) + if err != nil { + return nil, err + } + return &Client{ + ServiceGatewaysClient: client, + subscriptionID: subscriptionID, + tracer: tr, + }, nil +} + +const GetOperationName = "ServiceGatewaysClient.Get" + +// Get gets the ServiceGateway +func (client *Client) Get(ctx context.Context, resourceGroupName string, servicegatewayName string) (result *armnetwork.ServiceGateway, err error) { + + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "get") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, GetOperationName, client.tracer, nil) + defer endSpan(err) + resp, err := client.ServiceGatewaysClient.Get(ctx, resourceGroupName, servicegatewayName, nil) + if err != nil { + return nil, err + } + //handle statuscode + return &resp.ServiceGateway, nil +} + +const CreateOrUpdateOperationName = "ServiceGatewaysClient.Create" + +// CreateOrUpdate creates or updates a ServiceGateway. +func (client *Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, servicegatewayName string, resource armnetwork.ServiceGateway) (result *armnetwork.ServiceGateway, err error) { + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "create_or_update") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, CreateOrUpdateOperationName, client.tracer, nil) + defer endSpan(err) + resp, err := utils.NewPollerWrapper(client.ServiceGatewaysClient.BeginCreateOrUpdate(ctx, resourceGroupName, servicegatewayName, resource, nil)).WaitforPollerResp(ctx) + if err != nil { + return nil, err + } + if resp != nil { + return &resp.ServiceGateway, nil + } + return nil, nil +} + +const DeleteOperationName = "ServiceGatewaysClient.Delete" + +// Delete deletes a ServiceGateway by name. +func (client *Client) Delete(ctx context.Context, resourceGroupName string, servicegatewayName string) (err error) { + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "delete") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, DeleteOperationName, client.tracer, nil) + defer endSpan(err) + _, err = utils.NewPollerWrapper(client.BeginDelete(ctx, resourceGroupName, servicegatewayName, nil)).WaitforPollerResp(ctx) + return err +} + +const ListOperationName = "ServiceGatewaysClient.List" + +// List gets a list of ServiceGateway in the resource group. +func (client *Client) List(ctx context.Context, resourceGroupName string) (result []*armnetwork.ServiceGateway, err error) { + metricsCtx := metrics.BeginARMRequest(client.subscriptionID, resourceGroupName, "ServiceGateway", "list") + defer func() { metricsCtx.Observe(ctx, err) }() + ctx, endSpan := runtime.StartSpan(ctx, ListOperationName, client.tracer, nil) + defer endSpan(err) + pager := client.ServiceGatewaysClient.NewListPager(resourceGroupName, nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + return nil, err + } + result = append(result, nextResult.Value...) + } + return result, nil +}