Skip to content

Commit

Permalink
fix: remove JSON converter
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed Dec 26, 2024
1 parent a7c35e0 commit bbeedb6
Show file tree
Hide file tree
Showing 79 changed files with 819 additions and 1,757 deletions.
20 changes: 8 additions & 12 deletions provider/describer/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ func getDataLakeAnalyticsAccount(ctx context.Context, account *armdatalakeanalyt
ID: *account.ID,
Name: *account.Name,
Location: *account.Location,
Description: JSONAllFieldsMarshaller{
Value: model.DataLakeAnalyticsAccountDescription{
DataLakeAnalyticsAccount: accountGetOp.Account,
DiagnosticSettingsResource: &accountListOp,
ResourceGroup: resourceGroup,
},
Description: model.DataLakeAnalyticsAccountDescription{
DataLakeAnalyticsAccount: accountGetOp.Account,
DiagnosticSettingsResource: &accountListOp,
ResourceGroup: resourceGroup,
},
}
return &resource, nil
Expand Down Expand Up @@ -162,12 +160,10 @@ func getDataLakeStore(ctx context.Context, account *armdatalakestore.AccountBasi
ID: *account.ID,
Name: name,
Location: "",
Description: JSONAllFieldsMarshaller{
Value: model.DataLakeStoreDescription{
DataLakeStoreAccount: accountGetOp.Account,
DiagnosticSettingsResource: &accountListOp,
ResourceGroup: resourceGroup,
},
Description: model.DataLakeStoreDescription{
DataLakeStoreAccount: accountGetOp.Account,
DiagnosticSettingsResource: &accountListOp,
ResourceGroup: resourceGroup,
},
}
return &resource, nil
Expand Down
8 changes: 3 additions & 5 deletions provider/describer/alertmanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ func getAlertManagement(_ context.Context, alert *armalertsmanagement.Alert) *mo
return &models.Resource{
ID: *alert.ID,
Name: *alert.Name,
Description: JSONAllFieldsMarshaller{
Value: model.AlertManagementDescription{
Alert: *alert,
ResourceGroup: resourceGroup,
},
Description: model.AlertManagementDescription{
Alert: *alert,
ResourceGroup: resourceGroup,
},
}
}
8 changes: 3 additions & 5 deletions provider/describer/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ func getAnalysisService(ctx context.Context, server *armanalysisservices.Server)
ID: *server.ID,
Name: *server.Name,
Location: *server.Location,
Description: JSONAllFieldsMarshaller{
Value: model.AnalysisServiceServerDescription{
Server: *server,
ResourceGroup: resourceGroupName,
},
Description: model.AnalysisServiceServerDescription{
Server: *server,
ResourceGroup: resourceGroupName,
},
}
return &resource
Expand Down
20 changes: 8 additions & 12 deletions provider/describer/apimanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ func getAPIMangement(ctx context.Context, diagnosticClient *armmonitor.Diagnosti
ID: *apiManagement.ID,
Name: *apiManagement.Name,
Location: *apiManagement.Location,
Description: JSONAllFieldsMarshaller{
Value: model.APIManagementDescription{
APIManagement: *apiManagement,
DiagnosticSettingsResources: &op,
ResourceGroup: resourceGroup,
},
Description: model.APIManagementDescription{
APIManagement: *apiManagement,
DiagnosticSettingsResources: &op,
ResourceGroup: resourceGroup,
},
}
return &resource, nil
Expand Down Expand Up @@ -141,12 +139,10 @@ func GetAPIManagementBackend(ctx context.Context, service *armapimanagement.Serv
resource := models.Resource{
ID: *backend.ID,
Name: *backend.Name,
Description: JSONAllFieldsMarshaller{
Value: model.APIManagementBackendDescription{
APIManagementBackend: *backend,
ServiceName: *service.Name,
ResourceGroup: resourceGroup,
},
Description: model.APIManagementBackendDescription{
APIManagementBackend: *backend,
ServiceName: *service.Name,
ResourceGroup: resourceGroup,
},
}
return &resource
Expand Down
10 changes: 4 additions & 6 deletions provider/describer/appconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ func getAppConfiguration(ctx context.Context, diagnosticClient *armmonitor.Diagn
ID: *config.ID,
Name: *config.Name,
Location: *config.Location,
Description: JSONAllFieldsMarshaller{
Value: model.AppConfigurationDescription{
ConfigurationStore: *config,
DiagnosticSettingsResources: &op,
ResourceGroup: resourceGroup,
},
Description: model.AppConfigurationDescription{
ConfigurationStore: *config,
DiagnosticSettingsResources: &op,
ResourceGroup: resourceGroup,
},
}
return &resource, nil
Expand Down
8 changes: 3 additions & 5 deletions provider/describer/applicationinsights.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ func GetApplicationInsights(ctx context.Context, component *armapplicationinsigh
ID: *component.ID,
Name: *component.Name,
Location: *component.Location,
Description: JSONAllFieldsMarshaller{
Value: model.ApplicationInsightsComponentDescription{
Component: *component,
ResourceGroup: resourceGroup,
},
Description: model.ApplicationInsightsComponentDescription{
Component: *component,
ResourceGroup: resourceGroup,
},
}
return &resource
Expand Down
12 changes: 5 additions & 7 deletions provider/describer/appplatform.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ func getSpringCloudService(ctx context.Context, service *armspringappdiscovery.S
ID: *service.ID,
Name: *service.Name,
Location: *site.Location,
Description: JSONAllFieldsMarshaller{
Value: model.SpringCloudServiceDescription{
App: *service,
Site: site,
DiagnosticSettingsResource: nil, // TODO: Arta fix this =)))
ResourceGroup: resourceGroup,
},
Description: model.SpringCloudServiceDescription{
App: *service,
Site: site,
DiagnosticSettingsResource: nil, // TODO: Arta fix this =)))
ResourceGroup: resourceGroup,
},
}
return &resource, nil
Expand Down
80 changes: 34 additions & 46 deletions provider/describer/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ func getRoleAssignment(ctx context.Context, v *armauthorization.RoleAssignment)
ID: *v.ID,
Name: *v.Name,
Location: "global",
Description: JSONAllFieldsMarshaller{
Value: model.RoleAssignmentDescription{
RoleAssignment: *v,
},
Description: model.RoleAssignmentDescription{
RoleAssignment: *v,
},
}
}
Expand Down Expand Up @@ -87,10 +85,8 @@ func getRoleDefinition(ctx context.Context, v *armauthorization.RoleDefinition)
ID: *v.ID,
Name: *v.Name,
Location: "global",
Description: JSONAllFieldsMarshaller{
Value: model.RoleDefinitionDescription{
RoleDefinition: *v,
},
Description: model.RoleDefinitionDescription{
RoleDefinition: *v,
},
}
}
Expand Down Expand Up @@ -133,11 +129,9 @@ func getPolicyDefinition(ctx context.Context, subscription string, definition *a
ID: *definition.ID,
Name: *definition.Name,
Location: "global",
Description: JSONAllFieldsMarshaller{
Value: model.PolicyDefinitionDescription{
Definition: *definition,
TurboData: turbotData,
},
Description: model.PolicyDefinitionDescription{
Definition: *definition,
TurboData: turbotData,
},
}
}
Expand Down Expand Up @@ -175,17 +169,15 @@ func UserEffectiveAccess(ctx context.Context, cred *azidentity.ClientSecretCrede
ID: id,
Name: *roleAssignment.Name,
Location: "global",
Description: JSONAllFieldsMarshaller{
Value: model.UserEffectiveAccessDescription{
RoleAssignment: *roleAssignment,
PrincipalName: *m.GetDisplayName(),
PrincipalId: *m.GetId(),
PrincipalType: armauthorization.PrincipalTypeUser,
Scope: *roleAssignment.Properties.Scope,
ScopeType: getScopeType(*roleAssignment.Properties.Scope),
AssignmentType: "GroupAssignment",
ParentPrincipalId: roleAssignment.Properties.PrincipalID,
},
Description: model.UserEffectiveAccessDescription{
RoleAssignment: *roleAssignment,
PrincipalName: *m.GetDisplayName(),
PrincipalId: *m.GetId(),
PrincipalType: armauthorization.PrincipalTypeUser,
Scope: *roleAssignment.Properties.Scope,
ScopeType: getScopeType(*roleAssignment.Properties.Scope),
AssignmentType: "GroupAssignment",
ParentPrincipalId: roleAssignment.Properties.PrincipalID,
},
}
if stream != nil {
Expand All @@ -209,17 +201,15 @@ func UserEffectiveAccess(ctx context.Context, cred *azidentity.ClientSecretCrede
ID: id,
Name: *roleAssignment.Name,
Location: "global",
Description: JSONAllFieldsMarshaller{
Value: model.UserEffectiveAccessDescription{
RoleAssignment: *roleAssignment,
PrincipalId: *roleAssignment.Properties.PrincipalID,
PrincipalName: *user.GetDisplayName(),
PrincipalType: armauthorization.PrincipalTypeUser,
Scope: *roleAssignment.Properties.Scope,
ScopeType: getScopeType(*roleAssignment.Properties.Scope),
AssignmentType: "Explicit",
ParentPrincipalId: nil,
},
Description: model.UserEffectiveAccessDescription{
RoleAssignment: *roleAssignment,
PrincipalId: *roleAssignment.Properties.PrincipalID,
PrincipalName: *user.GetDisplayName(),
PrincipalType: armauthorization.PrincipalTypeUser,
Scope: *roleAssignment.Properties.Scope,
ScopeType: getScopeType(*roleAssignment.Properties.Scope),
AssignmentType: "Explicit",
ParentPrincipalId: nil,
},
}
if stream != nil {
Expand All @@ -242,17 +232,15 @@ func UserEffectiveAccess(ctx context.Context, cred *azidentity.ClientSecretCrede
ID: id,
Name: *roleAssignment.Name,
Location: "global",
Description: JSONAllFieldsMarshaller{
Value: model.UserEffectiveAccessDescription{
RoleAssignment: *roleAssignment,
PrincipalId: *roleAssignment.Properties.PrincipalID,
PrincipalName: *spn.GetDisplayName(),
PrincipalType: armauthorization.PrincipalTypeServicePrincipal,
Scope: *roleAssignment.Properties.Scope,
ScopeType: getScopeType(*roleAssignment.Properties.Scope),
AssignmentType: "Explicit",
ParentPrincipalId: nil,
},
Description: model.UserEffectiveAccessDescription{
RoleAssignment: *roleAssignment,
PrincipalId: *roleAssignment.Properties.PrincipalID,
PrincipalName: *spn.GetDisplayName(),
PrincipalType: armauthorization.PrincipalTypeServicePrincipal,
Scope: *roleAssignment.Properties.Scope,
ScopeType: getScopeType(*roleAssignment.Properties.Scope),
AssignmentType: "Explicit",
ParentPrincipalId: nil,
},
}
if stream != nil {
Expand Down
18 changes: 7 additions & 11 deletions provider/describer/automation.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ func getAutomationAccount(ctx context.Context, account *armautomation.Account) *
ID: *account.ID,
Name: *account.Name,
Location: *account.Location,
Description: JSONAllFieldsMarshaller{
Value: model.AutomationAccountsDescription{
Automation: *account,
ResourceGroup: resourceGroup,
},
Description: model.AutomationAccountsDescription{
Automation: *account,
ResourceGroup: resourceGroup,
},
}
return &resource
Expand Down Expand Up @@ -116,12 +114,10 @@ func GetAutomationVariable(ctx context.Context, account *armautomation.Account,
resource := models.Resource{
ID: *v.ID,
Name: *v.Name,
Description: JSONAllFieldsMarshaller{
Value: model.AutomationVariablesDescription{
Automation: *v,
AccountName: *account.Name,
ResourceGroup: resourceGroup,
},
Description: model.AutomationVariablesDescription{
Automation: *v,
AccountName: *account.Name,
ResourceGroup: resourceGroup,
},
}
return &resource
Expand Down
10 changes: 4 additions & 6 deletions provider/describer/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@ func getBatchAccount(ctx context.Context, account *armbatch.Account, diagnosticC
ID: *account.ID,
Name: *account.Name,
Location: *account.Location,
Description: JSONAllFieldsMarshaller{
Value: model.BatchAccountDescription{
Account: *account,
DiagnosticSettingsResources: &batchListOp,
ResourceGroup: resourceGroup,
},
Description: model.BatchAccountDescription{
Account: *account,
DiagnosticSettingsResources: &batchListOp,
ResourceGroup: resourceGroup,
},
}
return &resource, nil
Expand Down
6 changes: 3 additions & 3 deletions provider/describer/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func BlueprintArtifact(ctx context.Context, cred *azidentity.ClientSecretCredent
func getBluePrintArtifact(ctx context.Context, v armblueprint.ArtifactClassification) *models.Resource {
return &models.Resource{
ID: *v.GetArtifact().ID,
Description: JSONAllFieldsMarshaller{Value: v.GetArtifact()},
Description: v.GetArtifact(),
}
}

Expand Down Expand Up @@ -94,9 +94,9 @@ func getBlueprintBlueprint(ctx context.Context, blueprint *armblueprint.Blueprin
resourceGroupName := strings.Split(*blueprint.ID, "/")[4]
return &models.Resource{
ID: *blueprint.ID,
Description: JSONAllFieldsMarshaller{Value: model.BlueprintDescription{
Description: model.BlueprintDescription{
Blueprint: *blueprint,
ResourceGroup: resourceGroupName,
}},
},
}
}
4 changes: 2 additions & 2 deletions provider/describer/botservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func getBotServiceBot(ctx context.Context, bot *armbotservice.Bot) *models.Resou
resourceGroupName := strings.Split(string(*bot.ID), "/")[4]
return &models.Resource{
ID: *bot.ID,
Description: JSONAllFieldsMarshaller{Value: model.BotServiceBotDescription{
Description: model.BotServiceBotDescription{
Bot: *bot,
ResourceGroup: resourceGroupName,
}},
},
}
}
16 changes: 6 additions & 10 deletions provider/describer/cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ func getCdnProfiles(ctx context.Context, v *armcdn.Profile) *models.Resource {
ID: *v.ID,
Name: *v.Name,
Location: *v.Location,
Description: JSONAllFieldsMarshaller{
Value: model.CDNProfileDescription{
Profile: *v,
ResourceGroup: resourceGroup,
},
Description: model.CDNProfileDescription{
Profile: *v,
ResourceGroup: resourceGroup,
},
}
return &resource
Expand Down Expand Up @@ -114,11 +112,9 @@ func getCdnEndpoint(ctx context.Context, v *armcdn.Profile, endpoint *armcdn.End
ID: *v.ID,
Name: *v.Name,
Location: *v.Location,
Description: JSONAllFieldsMarshaller{
Value: model.CDNEndpointDescription{
Endpoint: *endpoint,
ResourceGroup: resourceGroup,
},
Description: model.CDNEndpointDescription{
Endpoint: *endpoint,
ResourceGroup: resourceGroup,
},
}
}
4 changes: 2 additions & 2 deletions provider/describer/cognitiveservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func getCognitiveAccount(ctx context.Context, diagnosticsClient *armmonitor.Diag
}
return &models.Resource{
ID: *account.ID,
Description: JSONAllFieldsMarshaller{Value: model.CognitiveAccountDescription{
Description: model.CognitiveAccountDescription{
Account: *account,
DiagnosticSettingsResources: diagnosticSettings,
ResourceGroup: resourceGroupName,
}},
},
}, nil
}
Loading

0 comments on commit bbeedb6

Please sign in to comment.