-
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
66 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
pkg/util/azureclient/azuresdk/armnetwork/privateendpoints.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,32 @@ | ||
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" | ||
) | ||
|
||
// PrivateEndpointsClient is a minimal interface for azure PrivateEndpointsClient | ||
type PrivateEndpointsClient interface { | ||
Get(ctx context.Context, resourceGroupName string, privateEndpointName string, options *armnetwork.PrivateEndpointsClientGetOptions) (armnetwork.PrivateEndpointsClientGetResponse, error) | ||
PrivateEndpointsClientAddons | ||
} | ||
|
||
type privateEndpointsClient struct { | ||
*armnetwork.PrivateEndpointsClient | ||
} | ||
|
||
// NewPrivateEndpointsClient creates a new PrivateEndpointsClient | ||
func NewPrivateEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (PrivateEndpointsClient, error) { | ||
clientFactory, err := armnetwork.NewClientFactory(subscriptionID, credential, options) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &privateEndpointsClient{PrivateEndpointsClient: clientFactory.NewPrivateEndpointsClient()}, nil | ||
} |
34 changes: 34 additions & 0 deletions
34
pkg/util/azureclient/azuresdk/armnetwork/privateendpoints_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,34 @@ | ||
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" | ||
) | ||
|
||
// PrivateEndpointsClientAddons contains addons for PrivateEndpointsClient | ||
type PrivateEndpointsClientAddons interface { | ||
CreateOrUpdateAndWait(ctx context.Context, resourceGroupName string, privateEndpointName string, parameters armnetwork.PrivateEndpoint, options *armnetwork.PrivateEndpointsClientBeginCreateOrUpdateOptions) error | ||
DeleteAndWait(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *armnetwork.PrivateEndpointsClientBeginDeleteOptions) error | ||
} | ||
|
||
func (c *privateEndpointsClient) CreateOrUpdateAndWait(ctx context.Context, resourceGroupName string, privateEndpointName string, parameters armnetwork.PrivateEndpoint, options *armnetwork.PrivateEndpointsClientBeginCreateOrUpdateOptions) error { | ||
poller, err := c.PrivateEndpointsClient.BeginCreateOrUpdate(ctx, resourceGroupName, privateEndpointName, parameters, options) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = poller.PollUntilDone(ctx, nil) | ||
return err | ||
} | ||
|
||
func (c *privateEndpointsClient) DeleteAndWait(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *armnetwork.PrivateEndpointsClientBeginDeleteOptions) error { | ||
poller, err := c.PrivateEndpointsClient.BeginDelete(ctx, resourceGroupName, publicIPAddressName, options) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = poller.PollUntilDone(ctx, nil) | ||
return err | ||
} |