Skip to content

Commit

Permalink
tools/importer-rest-api-specs: moving the commonids into a subpac…
Browse files Browse the repository at this point in the history
…kage

There's a bunch of these, and whilst these'll get replaced in time with #4017
but for now this cleans this up
  • Loading branch information
tombuildsstuff authored and manicminer committed Oct 1, 2024
1 parent 16086d0 commit d66f58a
Show file tree
Hide file tree
Showing 71 changed files with 238 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,116 +6,18 @@ package resourceids
import (
"github.com/hashicorp/pandora/tools/data-api-sdk/v1/helpers"
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
"github.com/hashicorp/pandora/tools/importer-rest-api-specs/components/parser/resourceids/commonids"
)

type commonIdMatcher interface {
// id returns the Resource ID for this Common ID
id() sdkModels.ResourceID
}

var commonIdTypes = []commonIdMatcher{
commonIdManagementGroupMatcher{},
commonIdResourceGroupMatcher{},
commonIdSubscriptionMatcher{},
commonIdScopeMatcher{},
commonIdUserAssignedIdentity{},

// Network ids
// "Core"
commonIdNetworkInterface{},
commonIdPublicIPAddress{},
commonIdSubnet{},
commonIdVirtualNetwork{},
commonIdVPNConnection{},

// Kusto
commonIdKustoCluster{},
commonIdKustoDatabase{},

// RP Specific
commonIdCloudServicesIPConfiguration{},
commonIdCloudServicesPublicIPAddress{},
commonIdExpressRouteCircuitPeering{},
commonIdNetworkInterfaceIPConfiguration{},
//commonIdP2sVPNGateway{},
commonIdVirtualHubBGPConnection{},
commonIdVirtualHubIPConfiguration{},
commonIdVirtualMachineScaleSetIPConfiguration{},
commonIdVirtualMachineScaleSetNetworkInterface{},
commonIdVirtualMachineScaleSetPublicIPAddress{},
commonIdVirtualRouterPeering{},
commonIdVirtualWANP2SVPNGateway{},

// https://github.com/hashicorp/pandora/pull/1962#issuecomment-1375005199
commonIdHyperVSiteJob{},
commonIdHyperVSiteMachine{},
commonIdHyperVSiteRunAsAccount{},
commonIdVMwareSiteJob{},
commonIdVMwareSiteMachine{},
commonIdVMwareSiteRunAsAccount{},

// Misc data fixes
commonIdAutomationCompilationJob{}, // (@stephybun) CompilationJobId segment is defined in three different ways `jobId`, `compilationJobId` and `compilationJobName`
commonIdProvisioningService{}, // (@jackofallops): Inconsistent user specified fields in the swagger - `provisioningServices/{resourceName}` vs `provisioningServices/{provisioningServiceName}`

// Bot Service
commonIdBotService{},
commonIdBotServiceChannel{},

// Chaos
commonIdChaosStudioCapability{},
commonIdChaosStudioTarget{},

// Compute
commonIdAvailabilitySet{},
commonIdDedicatedHost{},
commonIdDedicatedHostGroup{},
commonIdDiskEncryptionSet{},
commonIdManagedDisk{},
commonIdSharedImageGallery{},

// HDInsight
commonIdHDInsightCluster{},

// Key Vault
commonIdKeyVault{},
commonIdKeyVaultKey{},
commonIdKeyVaultKeyVersion{},
commonIdKeyVaultPrivateEndpointConnection{},

// Kubernetes
commonIdKubernetesCluster{},
//commonIdKubernetesFleet{},

// SQL
commonIdSqlDatabase{},
commonIdSqlElasticPool{},
commonIdSqlManagedInstance{},
commonIdSqlManagedInstanceDatabase{},
commonIdSqlServer{},

// Spring Cloud
commonIdSpringCloudService{},

// Storage
commonIdStorageAccount{},
commonIdStorageContainer{},

// Web / App Service
commonIdAppService{},
commonIdAppServiceEnvironment{},
commonIdAppServicePlan{},
}

func switchOutCommonResourceIDsAsNeeded(input []sdkModels.ResourceID) []sdkModels.ResourceID {
output := make([]sdkModels.ResourceID, 0)

for _, value := range input {
// TODO: we should expose a `[]CommonIDs` function from `hashicorp/go-azure-helpers` so that we can reuse these
// the types (intentionally) don't align but we have enough information here to map the data across
for _, commonId := range commonIdTypes {
if ResourceIdsMatch(commonId.id(), value) {
value = commonId.id()
for _, commonId := range commonids.CommonIDTypes {
if ResourceIdsMatch(commonId.ID(), value) {
value = commonId.ID()
value.ExampleValue = helpers.DisplayValueForResourceID(value)
break
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdAppService{}

type commonIdAppService struct{}

func (c commonIdAppService) id() sdkModels.ResourceID {
func (c commonIdAppService) ID() sdkModels.ResourceID {
name := "AppService"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdAppServiceEnvironment{}

type commonIdAppServiceEnvironment struct{}

func (c commonIdAppServiceEnvironment) id() sdkModels.ResourceID {
func (c commonIdAppServiceEnvironment) ID() sdkModels.ResourceID {
name := "AppServiceEnvironment"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdAppServicePlan{}

type commonIdAppServicePlan struct{}

func (c commonIdAppServicePlan) id() sdkModels.ResourceID {
func (c commonIdAppServicePlan) ID() sdkModels.ResourceID {
name := "AppServicePlan"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdAutomationCompilationJob{}

type commonIdAutomationCompilationJob struct{}

func (c commonIdAutomationCompilationJob) id() sdkModels.ResourceID {
func (c commonIdAutomationCompilationJob) ID() sdkModels.ResourceID {
name := "AutomationCompilationJob"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdAvailabilitySet{}

type commonIdAvailabilitySet struct{}

func (c commonIdAvailabilitySet) id() sdkModels.ResourceID {
func (c commonIdAvailabilitySet) ID() sdkModels.ResourceID {
name := "AvailabilitySet"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdBotService{}

type commonIdBotService struct{}

func (commonIdBotService) id() sdkModels.ResourceID {
func (commonIdBotService) ID() sdkModels.ResourceID {
name := "BotService"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdBotServiceChannel{}

type commonIdBotServiceChannel struct{}

func (commonIdBotServiceChannel) id() sdkModels.ResourceID {
func (commonIdBotServiceChannel) ID() sdkModels.ResourceID {
name := "BotServiceChannel"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdChaosStudioCapability{}

type commonIdChaosStudioCapability struct{}

func (commonIdChaosStudioCapability) id() sdkModels.ResourceID {
func (commonIdChaosStudioCapability) ID() sdkModels.ResourceID {
name := "ChaosStudioCapability"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdChaosStudioTarget{}

type commonIdChaosStudioTarget struct{}

func (commonIdChaosStudioTarget) id() sdkModels.ResourceID {
func (commonIdChaosStudioTarget) ID() sdkModels.ResourceID {
name := "ChaosStudioTarget"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdCloudServicesIPConfiguration{}

type commonIdCloudServicesIPConfiguration struct{}

func (c commonIdCloudServicesIPConfiguration) id() sdkModels.ResourceID {
func (c commonIdCloudServicesIPConfiguration) ID() sdkModels.ResourceID {
name := "CloudServicesIPConfiguration"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdCloudServicesPublicIPAddress{}

type commonIdCloudServicesPublicIPAddress struct{}

func (c commonIdCloudServicesPublicIPAddress) id() sdkModels.ResourceID {
func (c commonIdCloudServicesPublicIPAddress) ID() sdkModels.ResourceID {
name := "CloudServicesPublicIPAddress"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdDedicatedHost{}

type commonIdDedicatedHost struct{}

func (c commonIdDedicatedHost) id() sdkModels.ResourceID {
func (c commonIdDedicatedHost) ID() sdkModels.ResourceID {
name := "DedicatedHost"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdDedicatedHostGroup{}

type commonIdDedicatedHostGroup struct{}

func (c commonIdDedicatedHostGroup) id() sdkModels.ResourceID {
func (c commonIdDedicatedHostGroup) ID() sdkModels.ResourceID {
name := "DedicatedHostGroup"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdDiskEncryptionSet{}

type commonIdDiskEncryptionSet struct{}

func (c commonIdDiskEncryptionSet) id() sdkModels.ResourceID {
func (c commonIdDiskEncryptionSet) ID() sdkModels.ResourceID {
name := "DiskEncryptionSet"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package resourceids
package commonids

import (
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
Expand All @@ -11,7 +11,7 @@ var _ commonIdMatcher = commonIdExpressRouteCircuitPeering{}

type commonIdExpressRouteCircuitPeering struct{}

func (c commonIdExpressRouteCircuitPeering) id() sdkModels.ResourceID {
func (c commonIdExpressRouteCircuitPeering) ID() sdkModels.ResourceID {
name := "ExpressRouteCircuitPeering"
return sdkModels.ResourceID{
CommonIDAlias: &name,
Expand Down
Loading

0 comments on commit d66f58a

Please sign in to comment.