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

tools/importer-rest-api-specs: detecting the Common IDs for Bot Service #3576

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package resourceids

import (
"github.com/hashicorp/pandora/tools/importer-rest-api-specs/models"
"github.com/hashicorp/pandora/tools/sdk/resourcemanager"
)

var _ commonIdMatcher = commonIdBotService{}

type commonIdBotService struct{}

func (commonIdBotService) id() models.ParsedResourceId {
name := "BotService"
return models.ParsedResourceId{
CommonAlias: &name,
Constants: map[string]resourcemanager.ConstantDetails{},
Segments: []resourcemanager.ResourceIdSegment{
models.StaticResourceIDSegment("staticSubscriptions", "subscriptions"),
models.SubscriptionIDResourceIDSegment("subscriptionId"),
models.StaticResourceIDSegment("staticResourceGroups", "resourceGroups"),
models.ResourceGroupResourceIDSegment("resourceGroupName"),
models.StaticResourceIDSegment("staticProviders", "providers"),
models.ResourceProviderResourceIDSegment("staticMicrosoftBotService", "Microsoft.BotService"),
models.StaticResourceIDSegment("staticBotServices", "botServices"),
models.UserSpecifiedResourceIDSegment("botServiceName"),
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package resourceids

import (
"github.com/hashicorp/pandora/tools/importer-rest-api-specs/models"
"github.com/hashicorp/pandora/tools/sdk/resourcemanager"
)

var _ commonIdMatcher = commonIdBotServiceChannel{}

type commonIdBotServiceChannel struct{}

func (commonIdBotServiceChannel) id() models.ParsedResourceId {
name := "BotServiceChannel"
return models.ParsedResourceId{
CommonAlias: &name,
Constants: map[string]resourcemanager.ConstantDetails{},
Segments: []resourcemanager.ResourceIdSegment{
models.StaticResourceIDSegment("staticSubscriptions", "subscriptions"),
models.SubscriptionIDResourceIDSegment("subscriptionId"),
models.StaticResourceIDSegment("staticResourceGroups", "resourceGroups"),
models.ResourceGroupResourceIDSegment("resourceGroupName"),
models.StaticResourceIDSegment("staticProviders", "providers"),
models.ResourceProviderResourceIDSegment("staticMicrosoftBotService", "Microsoft.BotService"),
models.StaticResourceIDSegment("staticBotServices", "botServices"),
models.UserSpecifiedResourceIDSegment("botServiceName"),
models.StaticResourceIDSegment("staticChannels", "channels"),
models.ConstantResourceIDSegment("channelType", "BotServiceChannelType"),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ var commonIdTypes = []commonIdMatcher{
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{},

// HDInsight
commonIdHDInsightCluster{},

Expand All @@ -65,7 +69,7 @@ var commonIdTypes = []commonIdMatcher{
commonIdSqlManagedInstanceDatabase{},
commonIdSqlServer{},

// Spring Cloud
// Spring Cloud
commonIdSpringCloudService{},

// Storage
Expand Down
7 changes: 4 additions & 3 deletions tools/importer-rest-api-specs/models/resource_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ func (pri ParsedResourceId) Matches(other ParsedResourceId) bool {
if first.ConstantReference == nil && second.ConstantReference != nil {
return false
}
if first.ConstantReference != nil && second.ConstantReference != nil && *first.ConstantReference != *second.ConstantReference {
return false
}

// We're intentionally not checking the constants involved, since both the name and values could differ
// between different operations due to data issues - however when either happens we'd end up using a
// Common ID to resolve this - therefore presuming the rest of the Resource ID matches we should be good.

continue
}
Expand Down
Loading