-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
pkg/util/azureclient/azuresdk/armnetwork/privatelinkservices.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
38 changes: 38 additions & 0 deletions
38
pkg/util/azureclient/azuresdk/armnetwork/privatelinkservices_addons.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |