Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Private Endpoint Connection details in table azure_data_factory closes #285 #298

Merged
merged 7 commits into from
Sep 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions azure/table_azure_data_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package azure

import (
"context"
"strings"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
"github.com/turbot/steampipe-plugin-sdk/grpc/proto"
Expand Down Expand Up @@ -99,6 +100,13 @@ func tableAzureDataFactory(_ context.Context) *plugin.Table {
Type: proto.ColumnType_JSON,
Transform: transform.FromField("FactoryProperties.GlobalParameters"),
},
{
Name: "private_connections",
bigdatasourav marked this conversation as resolved.
Show resolved Hide resolved
Description: "List of private connections for factory.",
Type: proto.ColumnType_JSON,
Hydrate: getDataFactoryPrivateConnections,
bigdatasourav marked this conversation as resolved.
Show resolved Hide resolved
Transform: transform.FromValue(),
},

// Steampipe standard columns
{
Expand Down Expand Up @@ -205,3 +213,48 @@ func getDataFactory(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateD

return op, nil
}

func getDataFactoryPrivateConnections(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
plugin.Logger(ctx).Trace("getDataFactoryPrivateConnections")
factory := h.Item.(datafactory.Factory)
factoryName := factory.Name
resourceGroup := strings.Split(*factory.ID, "/")[4]

// Create session
session, err := GetNewSession(ctx, d, "MANAGEMENT")
if err != nil {
plugin.Logger(ctx).Trace("getDataFactoryPrivateConnections", "connection", err)
return nil, err
}
subscriptionID := session.SubscriptionID

connClient := datafactory.NewPrivateEndPointConnectionsClient(subscriptionID)
connClient.Authorizer = session.Authorizer

op, err := connClient.ListByFactory(ctx, resourceGroup, *factoryName)
if err != nil {
return nil, err
}

var connections []PrivateConnection
for _, connection := range op.Values() {
plugin.Logger(ctx).Trace("Private Connections =>", connection)
connections = append(connections, PrivateConnection{
Properties: connection.Properties,
Id: connection.ID,
Name: connection.Name,
Type: connection.Type,
Etag: connection.Etag,
})
}

return connections, nil
}

type PrivateConnection struct {
Properties interface{}
bigdatasourav marked this conversation as resolved.
Show resolved Hide resolved
Id *string
Name *string
Type *string
Etag *string
}