Skip to content

Commit

Permalink
privatelinkservices
Browse files Browse the repository at this point in the history
  • Loading branch information
bitoku committed Jul 3, 2024
1 parent 4f5b046 commit 032ec5b
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/util/azureclient/azuresdk/armnetwork/privatelinkservices.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package armnetwork

// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.

import (
"context"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2"

"github.com/Azure/ARO-RP/pkg/util/azureclient/azuresdk/azcore"
)

// PrivateLinkServicesClient is a minimal interface for azure PrivateLinkServicesClient
type PrivateLinkServicesClient interface {
Get(ctx context.Context, resourceGroupName string, serviceName string, options *armnetwork.PrivateLinkServicesClientGetOptions) (armnetwork.PrivateLinkServicesClientGetResponse, error)
UpdatePrivateEndpointConnection(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, parameters armnetwork.PrivateEndpointConnection, options *armnetwork.PrivateLinkServicesClientUpdatePrivateEndpointConnectionOptions) (armnetwork.PrivateLinkServicesClientUpdatePrivateEndpointConnectionResponse, error)
PrivateLinkServicesClientAddons
}

type privateLinkServicesClient struct {
*armnetwork.PrivateLinkServicesClient
}

// NewPrivateLinkServicesClient creates a new PrivateLinkServicesClient
func NewPrivateLinkServicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (PrivateLinkServicesClient, error) {
clientFactory, err := armnetwork.NewClientFactory(subscriptionID, credential, options)
if err != nil {
return nil, err
}
return &privateLinkServicesClient{PrivateLinkServicesClient: clientFactory.NewPrivateLinkServicesClient()}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package armnetwork

// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.

import (
"context"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2"
)

// PrivateLinkServicesClientAddons contains addons for PrivateLinkServicesClient
type PrivateLinkServicesClientAddons interface {
List(ctx context.Context, resourceGroupName string, options *armnetwork.PrivateLinkServicesClientListOptions) ([]*armnetwork.PrivateLinkService, error)
DeletePrivateEndpointConnectionAndWait(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, options *armnetwork.PrivateLinkServicesClientBeginDeletePrivateEndpointConnectionOptions) error
}

func (c *privateLinkServicesClient) List(ctx context.Context, resourceGroupName string, options *armnetwork.PrivateLinkServicesClientListOptions) (result []*armnetwork.PrivateLinkService, err error) {
pager := c.PrivateLinkServicesClient.NewListPager(resourceGroupName, options)

for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
return nil, err
}
result = append(result, page.Value...)
}
return result, nil
}

func (c *privateLinkServicesClient) DeletePrivateEndpointConnectionAndWait(ctx context.Context, resourceGroupName string, serviceName string, peConnectionName string, options *armnetwork.PrivateLinkServicesClientBeginDeletePrivateEndpointConnectionOptions) error {
poller, err := c.PrivateLinkServicesClient.BeginDeletePrivateEndpointConnection(ctx, resourceGroupName, serviceName, peConnectionName, options)
if err != nil {
return err
}
_, err = poller.PollUntilDone(ctx, nil)
return err
}

0 comments on commit 032ec5b

Please sign in to comment.