From 4557e29629cd252739540fcb2c79bfbc443a4b7d Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 5 Oct 2023 10:23:23 +0530 Subject: [PATCH 01/12] Add table azure_backup_jobs Closes #663 --- azure/plugin.go | 1 + azure/table_azure_backup_job.go | 166 ++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 azure/table_azure_backup_job.go diff --git a/azure/plugin.go b/azure/plugin.go index 5b25c049..e1c010ed 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -43,6 +43,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_application_security_group": tableAzureApplicationSecurityGroup(ctx), "azure_automation_account": tableAzureApAutomationAccount(ctx), "azure_automation_variable": tableAzureApAutomationVariable(ctx), + "azure_backup_job": tableAzureBackupJob(ctx), "azure_bastion_host": tableAzureBastionHost(ctx), "azure_batch_account": tableAzureBatchAccount(ctx), "azure_cognitive_account": tableAzureCognitiveAccount(ctx), diff --git a/azure/table_azure_backup_job.go b/azure/table_azure_backup_job.go new file mode 100644 index 00000000..50211157 --- /dev/null +++ b/azure/table_azure_backup_job.go @@ -0,0 +1,166 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources" + "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-01-01/backup" + "github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/v5/plugin" + "github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform" +) + +//// TABLE DEFINITION //// + +func tableAzureBackupJob(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_backup_job", + Description: "Azure Backup Job", + List: &plugin.ListConfig{ + ParentHydrate: listResourceGroups, + Hydrate: listAzureBackupJobs, + KeyColumns: plugin.KeyColumnSlice{ + { + Name: "vault_name", + Require: plugin.Required, + }, + { + Name: "resource_group", + Require: plugin.Optional, + }, + }, + }, + Columns: azureColumns([]*plugin.Column{ + { + Name: "name", + Description: "Resource name associated with the resource.", + Type: proto.ColumnType_STRING, + }, + { + Name: "vault_name", + Description: "The recovery vault name.", + Type: proto.ColumnType_STRING, + }, + { + Name: "id", + Description: "Resource Id represents the complete path to the resource.", + Type: proto.ColumnType_STRING, + Transform: transform.FromGo(), + }, + { + Name: "type", + Description: "Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/...", + Type: proto.ColumnType_STRING, + }, + { + Name: "type", + Description: "Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/...", + Type: proto.ColumnType_STRING, + }, + { + Name: "etag", + Description: "Optional ETag.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ETag"), + }, + { + Name: "time_created", + Description: "The time when the disk was created", + Type: proto.ColumnType_TIMESTAMP, + Transform: transform.FromField("DiskProperties.TimeCreated").Transform(convertDateToTime), + }, + + // Steampipe standard columns + { + Name: "title", + Description: ColumnDescriptionTitle, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Name"), + }, + { + Name: "tags", + Description: ColumnDescriptionTags, + Type: proto.ColumnType_JSON, + }, + { + Name: "akas", + Description: ColumnDescriptionAkas, + Type: proto.ColumnType_JSON, + Transform: transform.FromField("ID").Transform(idToAkas), + }, + + // Azure standard columns + { + Name: "region", + Description: ColumnDescriptionRegion, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Location").Transform(toLower), + }, + { + Name: "resource_group", + Description: ColumnDescriptionResourceGroup, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ID").Transform(extractResourceGroupFromID), + }, + }), + } +} + +//// LIST FUNCTION //// + +func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + + resourceGroup := h.Item.(resources.Group) + + vaultName := d.EqualsQualString("vault_name") + rgName := d.EqualsQualString("resource_group") + + if vaultName == "" { + return nil, nil + } + + if rgName != "" { + if rgName != *resourceGroup.Name { + return nil, nil + } + } + + subscriptionID := session.SubscriptionID + client := backup.NewJobsClientWithBaseURI(session.ResourceManagerEndpoint, subscriptionID) + client.Authorizer = session.Authorizer + result, err := client.List(ctx, vaultName, *resourceGroup.Name, "", "") + if err != nil { + return nil, err + } + + for _, job := range result.Values() { + d.StreamListItem(ctx, job) + // Check if context has been cancelled or if the limit has been hit (if specified) + // if there is a limit, it will return the number of rows required to reach this limit + if d.RowsRemaining(ctx) == 0 { + return nil, nil + } + } + + for result.NotDone() { + err = result.NextWithContext(ctx) + if err != nil { + return nil, err + } + + for _, job := range result.Values() { + d.StreamListItem(ctx, job) + // Check if context has been cancelled or if the limit has been hit (if specified) + // if there is a limit, it will return the number of rows required to reach this limit + if d.RowsRemaining(ctx) == 0 { + return nil, nil + } + } + } + + return nil, nil +} From c7009dc880942425985ff8a3a3542fe09b114e6a Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 5 Oct 2023 13:56:15 +0530 Subject: [PATCH 02/12] Removed the duplicate column and handled the not found error code --- azure/plugin.go | 32 ++++++++++++++++---------------- azure/table_azure_backup_job.go | 17 ++++++++++++----- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/azure/plugin.go b/azure/plugin.go index e1c010ed..8f9b1f3c 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -51,30 +51,30 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_disk": tableAzureComputeDisk(ctx), "azure_compute_disk_access": tableAzureComputeDiskAccess(ctx), "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), - "azure_compute_disk_metric_read_ops": tableAzureComputeDiskMetricReadOps(ctx), - "azure_compute_disk_metric_read_ops_daily": tableAzureComputeDiskMetricReadOpsDaily(ctx), - "azure_compute_disk_metric_read_ops_hourly": tableAzureComputeDiskMetricReadOpsHourly(ctx), - "azure_compute_disk_metric_write_ops": tableAzureComputeDiskMetricWriteOps(ctx), - "azure_compute_disk_metric_write_ops_daily": tableAzureComputeDiskMetricWriteOpsDaily(ctx), - "azure_compute_disk_metric_write_ops_hourly": tableAzureComputeDiskMetricWriteOpsHourly(ctx), + // "azure_compute_disk_metric_read_ops": tableAzureComputeDiskMetricReadOps(ctx), + // "azure_compute_disk_metric_read_ops_daily": tableAzureComputeDiskMetricReadOpsDaily(ctx), + // "azure_compute_disk_metric_read_ops_hourly": tableAzureComputeDiskMetricReadOpsHourly(ctx), + // "azure_compute_disk_metric_write_ops": tableAzureComputeDiskMetricWriteOps(ctx), + // "azure_compute_disk_metric_write_ops_daily": tableAzureComputeDiskMetricWriteOpsDaily(ctx), + // "azure_compute_disk_metric_write_ops_hourly": tableAzureComputeDiskMetricWriteOpsHourly(ctx), "azure_compute_image": tableAzureComputeImage(ctx), "azure_compute_resource_sku": tableAzureResourceSku(ctx), "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), "azure_compute_ssh_key": tableAzureComputeSshKey(ctx), "azure_compute_virtual_machine": tableAzureComputeVirtualMachine(ctx), - "azure_compute_virtual_machine_metric_cpu_utilization": tableAzureComputeVirtualMachineMetricCpuUtilization(ctx), - "azure_compute_virtual_machine_metric_cpu_utilization_daily": tableAzureComputeVirtualMachineMetricCpuUtilizationDaily(ctx), - "azure_compute_virtual_machine_metric_cpu_utilization_hourly": tableAzureComputeVirtualMachineMetricCpuUtilizationHourly(ctx), + // "azure_compute_virtual_machine_metric_cpu_utilization": tableAzureComputeVirtualMachineMetricCpuUtilization(ctx), + // "azure_compute_virtual_machine_metric_cpu_utilization_daily": tableAzureComputeVirtualMachineMetricCpuUtilizationDaily(ctx), + // "azure_compute_virtual_machine_metric_cpu_utilization_hourly": tableAzureComputeVirtualMachineMetricCpuUtilizationHourly(ctx), "azure_compute_virtual_machine_scale_set": tableAzureComputeVirtualMachineScaleSet(ctx), "azure_compute_virtual_machine_scale_set_network_interface": tableAzureComputeVirtualMachineScaleSetNetworkInterface(ctx), "azure_compute_virtual_machine_scale_set_vm": tableAzureComputeVirtualMachineScaleSetVm(ctx), "azure_container_group": tableAzureContainerGroup(ctx), - "azure_container_registry": tableAzureContainerRegistry(ctx), + // "azure_container_registry": tableAzureContainerRegistry(ctx), "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), "azure_cosmosdb_mongo_collection": tableAzureCosmosDBMongoCollection(ctx), "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), "azure_cosmosdb_restorable_database_account": tableAzureCosmosDBRestorableDatabaseAccount(ctx), - "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), + // "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), "azure_data_factory": tableAzureDataFactory(ctx), "azure_data_factory_dataset": tableAzureDataFactoryDataset(ctx), "azure_data_factory_pipeline": tableAzureDataFactoryPipeline(ctx), @@ -120,9 +120,9 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_management_group": tableAzureManagementGroup(ctx), "azure_management_lock": tableAzureManagementLock(ctx), "azure_mariadb_server": tableAzureMariaDBServer(ctx), - "azure_mssql_elasticpool": tableAzureMSSQLElasticPool(ctx), + // "azure_mssql_elasticpool": tableAzureMSSQLElasticPool(ctx), "azure_mssql_managed_instance": tableAzureMSSQLManagedInstance(ctx), - "azure_mssql_virtual_machine": tableAzureMSSQLVirtualMachine(ctx), + // "azure_mssql_virtual_machine": tableAzureMSSQLVirtualMachine(ctx), "azure_mysql_flexible_server": tableAzureMySQLFlexibleServer(ctx), "azure_mysql_server": tableAzureMySQLServer(ctx), "azure_nat_gateway": tableAzureNatGateway(ctx), @@ -145,13 +145,13 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_role_definition": tableAzureIamRoleDefinition(ctx), "azure_route_table": tableAzureRouteTable(ctx), "azure_search_service": tableAzureSearchService(ctx), - "azure_security_center_automation": tableAzureSecurityCenterAutomation(ctx), + // "azure_security_center_automation": tableAzureSecurityCenterAutomation(ctx), "azure_security_center_auto_provisioning": tableAzureSecurityCenterAutoProvisioning(ctx), "azure_security_center_contact": tableAzureSecurityCenterContact(ctx), "azure_security_center_jit_network_access_policy": tableAzureSecurityCenterJITNetworkAccessPolicy(ctx), - "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), + // "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), "azure_security_center_sub_assessment": tableAzureSecurityCenterSubAssessment(ctx), - "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), + // "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), "azure_service_fabric_cluster": tableAzureServiceFabricCluster(ctx), "azure_servicebus_namespace": tableAzureServiceBusNamespace(ctx), "azure_signalr_service": tableAzureSignalRService(ctx), diff --git a/azure/table_azure_backup_job.go b/azure/table_azure_backup_job.go index 50211157..0b221e3e 100644 --- a/azure/table_azure_backup_job.go +++ b/azure/table_azure_backup_job.go @@ -2,6 +2,7 @@ package azure import ( "context" + "strings" "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-01-01/backup" @@ -19,6 +20,9 @@ func tableAzureBackupJob(_ context.Context) *plugin.Table { List: &plugin.ListConfig{ ParentHydrate: listResourceGroups, Hydrate: listAzureBackupJobs, + IgnoreConfig: &plugin.IgnoreConfig{ + ShouldIgnoreErrorFunc: isNotFoundError([]string{"ResourceNotFound", "404"}), + }, KeyColumns: plugin.KeyColumnSlice{ { Name: "vault_name", @@ -40,6 +44,7 @@ func tableAzureBackupJob(_ context.Context) *plugin.Table { Name: "vault_name", Description: "The recovery vault name.", Type: proto.ColumnType_STRING, + Transform: transform.FromQual("vault_name"), }, { Name: "id", @@ -52,11 +57,6 @@ func tableAzureBackupJob(_ context.Context) *plugin.Table { Description: "Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/...", Type: proto.ColumnType_STRING, }, - { - Name: "type", - Description: "Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/...", - Type: proto.ColumnType_STRING, - }, { Name: "etag", Description: "Optional ETag.", @@ -134,11 +134,15 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd client.Authorizer = session.Authorizer result, err := client.List(ctx, vaultName, *resourceGroup.Name, "", "") if err != nil { + if strings.Contains(err.Error(), "ResourceNotFound") { + return nil, nil + } return nil, err } for _, job := range result.Values() { d.StreamListItem(ctx, job) + // Check if context has been cancelled or if the limit has been hit (if specified) // if there is a limit, it will return the number of rows required to reach this limit if d.RowsRemaining(ctx) == 0 { @@ -149,6 +153,9 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd for result.NotDone() { err = result.NextWithContext(ctx) if err != nil { + if strings.Contains(err.Error(), "ResourceNotFound") { + return nil, nil + } return nil, err } From 8610947dcaf768f3693f5cd86da828d0305838a7 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Fri, 6 Oct 2023 12:54:03 +0530 Subject: [PATCH 03/12] Updated go package and added the doc --- azure/table_azure_backup_job.go | 95 ++++++++++++++++++++++----------- docs/tables/azure_backup_job.md | 42 +++++++++++++++ go.mod | 16 ++++-- go.sum | 38 +++++++------ 4 files changed, 138 insertions(+), 53 deletions(-) create mode 100644 docs/tables/azure_backup_job.md diff --git a/azure/table_azure_backup_job.go b/azure/table_azure_backup_job.go index 0b221e3e..2d29af0f 100644 --- a/azure/table_azure_backup_job.go +++ b/azure/table_azure_backup_job.go @@ -2,10 +2,10 @@ package azure import ( "context" - "strings" "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources" - "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-01-01/backup" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicesbackup/v3" "github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/v5/plugin" "github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform" @@ -63,11 +63,13 @@ func tableAzureBackupJob(_ context.Context) *plugin.Table { Type: proto.ColumnType_STRING, Transform: transform.FromField("ETag"), }, + + // JSON fields { - Name: "time_created", - Description: "The time when the disk was created", - Type: proto.ColumnType_TIMESTAMP, - Transform: transform.FromField("DiskProperties.TimeCreated").Transform(convertDateToTime), + Name: "properties", + Description: "JobResource properties.", + Type: proto.ColumnType_JSON, + Transform: transform.From(backupJobProperties), }, // Steampipe standard columns @@ -114,6 +116,12 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd return nil, err } + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + plugin.Logger(ctx).Error("azure_backup_job.listAzureBackupJobs", "NewDefaultAzureCredential", err) + return nil, err + } + resourceGroup := h.Item.(resources.Group) vaultName := d.EqualsQualString("vault_name") @@ -130,37 +138,24 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd } subscriptionID := session.SubscriptionID - client := backup.NewJobsClientWithBaseURI(session.ResourceManagerEndpoint, subscriptionID) - client.Authorizer = session.Authorizer - result, err := client.List(ctx, vaultName, *resourceGroup.Name, "", "") + clientFactory, err := armrecoveryservicesbackup.NewBackupJobsClient(subscriptionID, cred, nil) if err != nil { - if strings.Contains(err.Error(), "ResourceNotFound") { - return nil, nil - } - return nil, err + plugin.Logger(ctx).Error("azure_backup_job.listAzureBackupJobs", "NewBackupJobsClient", err) + return nil, nil } - - for _, job := range result.Values() { - d.StreamListItem(ctx, job) - - // Check if context has been cancelled or if the limit has been hit (if specified) - // if there is a limit, it will return the number of rows required to reach this limit - if d.RowsRemaining(ctx) == 0 { + pager := clientFactory.NewListPager(vaultName, *resourceGroup.Name, &armrecoveryservicesbackup.BackupJobsClientListOptions{Filter: nil, + SkipToken: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + plugin.Logger(ctx).Error("azure_backup_job.listAzureBackupJobs", "api_error", err) return nil, nil } - } - for result.NotDone() { - err = result.NextWithContext(ctx) - if err != nil { - if strings.Contains(err.Error(), "ResourceNotFound") { - return nil, nil - } - return nil, err - } + for _, v := range page.Value { + d.StreamListItem(ctx, v) - for _, job := range result.Values() { - d.StreamListItem(ctx, job) // Check if context has been cancelled or if the limit has been hit (if specified) // if there is a limit, it will return the number of rows required to reach this limit if d.RowsRemaining(ctx) == 0 { @@ -171,3 +166,41 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd return nil, nil } + +//// TRANSFORM FUNCTION + +func backupJobProperties(ctx context.Context, d *transform.TransformData) (interface{}, error) { + data := d.HydrateItem.(*armrecoveryservicesbackup.JobResource) + + output := make(map[string]interface{}) + + if data.Properties != nil { + if data.Properties.GetJob() != nil { + if data.Properties.GetJob().ActivityID != nil { + output["ActivityID"] = data.Properties.GetJob().ActivityID + } + if data.Properties.GetJob().BackupManagementType != nil { + output["BackupManagementType"] = data.Properties.GetJob().BackupManagementType + } + if data.Properties.GetJob().JobType != nil { + output["JobType"] = data.Properties.GetJob().JobType + } + if data.Properties.GetJob().EndTime != nil { + output["EndTime"] = data.Properties.GetJob().EndTime + } + if data.Properties.GetJob().EntityFriendlyName != nil { + output["EntityFriendlyName"] = data.Properties.GetJob().EntityFriendlyName + } + if data.Properties.GetJob().Operation != nil { + output["Operation"] = data.Properties.GetJob().Operation + } + if data.Properties.GetJob().StartTime != nil { + output["StartTime"] = data.Properties.GetJob().StartTime + } + if data.Properties.GetJob().Status != nil { + output["Status"] = data.Properties.GetJob().Status + } + } + } + return output, nil +} diff --git a/docs/tables/azure_backup_job.md b/docs/tables/azure_backup_job.md new file mode 100644 index 00000000..d1c48348 --- /dev/null +++ b/docs/tables/azure_backup_job.md @@ -0,0 +1,42 @@ +# Table: azure_backup_job + +An Azure Backup job is a task that you can define and run to perform data protection operations on your Azure resources. These jobs are typically used to back up and restore data from various Azure services, such as virtual machines, databases, and files. + +**Note**: `vault_name` is required in query parameter to get the job details of the job. + +## Examples + +### Basic info + +```sql +select + name, + id, + type, + vault_name, + region +from + azure_backup_job +where + vault_name = 'my-vault'; +``` + +### Get job properties of jobs + +```sql +select + name, + id, + properties ->> 'JobType' as job_type, + properties ->> 'ActivityID' as activity_id, + properties ->> 'BackupManagementType' as backup_management_type, + properties ->> 'EndTime' as end_time, + properties ->> 'EntityFriendlyName' as entity_friendly_name, + properties ->> 'Operation' as Operation, + properties ->> 'StartTime' as start_time, + properties ->> 'Status' as Status +from + azure_backup_job +where + vault_name = 'my-vault'; +``` diff --git a/go.mod b/go.mod index 6176fb8d..17fde63a 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.21 require ( github.com/Azure/azure-sdk-for-go v58.0.0+incompatible github.com/Azure/azure-sdk-for-go/sdk/data/aztables v1.0.1 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicesbackup/v3 v3.0.0 github.com/Azure/azure-storage-blob-go v0.12.0 github.com/Azure/go-autorest/autorest v0.11.17 github.com/Azure/go-autorest/autorest/azure/auth v0.5.6 @@ -22,14 +23,16 @@ require ( cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect github.com/Azure/azure-pipeline-go v0.2.3 // indirect - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect github.com/Azure/go-autorest v14.2.0+incompatible // indirect github.com/Azure/go-autorest/autorest/adal v0.9.10 // indirect github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect github.com/Azure/go-autorest/autorest/validation v0.3.0 // indirect github.com/Azure/go-autorest/logger v0.2.0 // indirect github.com/Azure/go-autorest/tracing v0.6.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/XiaoMi/pegasus-go-client v0.0.0-20210427083443-f3b6b08bc4c2 // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect github.com/agext/levenshtein v1.2.2 // indirect @@ -58,6 +61,7 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-redis/redis/v8 v8.11.5 // indirect github.com/gofrs/uuid v4.0.0+incompatible // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect github.com/golang/glog v1.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect @@ -78,6 +82,7 @@ require ( github.com/iancoleman/strcase v0.3.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.15.11 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-ieproxy v0.0.1 // indirect github.com/mattn/go-isatty v0.0.19 // indirect @@ -90,6 +95,7 @@ require ( github.com/oklog/run v1.0.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pegasus-kv/thrift v0.13.0 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.14.0 // indirect @@ -117,13 +123,13 @@ require ( go.opentelemetry.io/otel/sdk/metric v0.40.0 // indirect go.opentelemetry.io/otel/trace v1.17.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect - golang.org/x/crypto v0.11.0 // indirect + golang.org/x/crypto v0.12.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect - golang.org/x/net v0.12.0 // indirect + golang.org/x/net v0.14.0 // indirect golang.org/x/oauth2 v0.10.0 // indirect golang.org/x/sync v0.3.0 // indirect golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect diff --git a/go.sum b/go.sum index 5db41b4c..68b45d0b 100644 --- a/go.sum +++ b/go.sum @@ -191,14 +191,16 @@ github.com/Azure/azure-sdk-for-go v45.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9mo github.com/Azure/azure-sdk-for-go v47.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v58.0.0+incompatible h1:Cw16jiP4dI+CK761aq44ol4RV5dUiIIXky1+EKpoiVM= github.com/Azure/azure-sdk-for-go v58.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 h1:/iHxaJhsFr0+xVFfbMr5vxz848jyiWuIEDhYq3y5odY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 h1:LNHhpdK7hzUcx/k1LIcuh5k7k1LGIWLQfCjaneSj7Fc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1/go.mod h1:uE9zaUfEQT/nbQjVi2IblCG9iaLtZsuYZ8ne+PuQ02M= github.com/Azure/azure-sdk-for-go/sdk/data/aztables v1.0.1 h1:bFa9IcjvrCber6gGgDAUZ+I2bO8J7s8JxXmu9fhi2ss= github.com/Azure/azure-sdk-for-go/sdk/data/aztables v1.0.1/go.mod h1:l3wvZkG9oW07GLBW5Cd0WwG5asOfJ8aqE8raUvNzLpk= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicesbackup/v3 v3.0.0 h1:BIvscO5ZFKaEHoix9jAV6vbatKLiDNb5pj8XjzQR2g4= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicesbackup/v3 v3.0.0/go.mod h1:4uHLkZ3JvDvacFcEyB0T/cCeVqlvtHHA7DjvpgvlpdA= github.com/Azure/azure-storage-blob-go v0.12.0 h1:7bFXA1QB+lOK2/ASWHhp6/vnxjaeeZq6t8w1Jyp0Iaw= github.com/Azure/azure-storage-blob-go v0.12.0/go.mod h1:A0u4VjtpgZJ7Y7um/+ix2DHBuEKFC6sEIlj0xc13a4Q= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= @@ -230,8 +232,8 @@ github.com/Azure/go-autorest/logger v0.2.0 h1:e4RVHVZKC5p6UANLJHkM4OfR1UKZPj8Wt8 github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -381,7 +383,8 @@ github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= @@ -616,8 +619,8 @@ github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaR github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pegasus-kv/thrift v0.13.0 h1:4ESwaNoHImfbHa9RUGJiJZ4hrxorihZHk5aarYwY8d4= github.com/pegasus-kv/thrift v0.13.0/go.mod h1:Gl9NT/WHG6ABm6NsrbfE8LiJN0sAyneCrvB4qN4NPqQ= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -759,8 +762,8 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -855,8 +858,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -957,6 +960,7 @@ golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1004,8 +1008,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From 51d26304d26c97cca9f2be7059fb0844245fb3d3 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Fri, 6 Oct 2023 12:59:58 +0530 Subject: [PATCH 04/12] uncommented the commented code --- azure/plugin.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/azure/plugin.go b/azure/plugin.go index 8f9b1f3c..e1c010ed 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -51,30 +51,30 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_disk": tableAzureComputeDisk(ctx), "azure_compute_disk_access": tableAzureComputeDiskAccess(ctx), "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), - // "azure_compute_disk_metric_read_ops": tableAzureComputeDiskMetricReadOps(ctx), - // "azure_compute_disk_metric_read_ops_daily": tableAzureComputeDiskMetricReadOpsDaily(ctx), - // "azure_compute_disk_metric_read_ops_hourly": tableAzureComputeDiskMetricReadOpsHourly(ctx), - // "azure_compute_disk_metric_write_ops": tableAzureComputeDiskMetricWriteOps(ctx), - // "azure_compute_disk_metric_write_ops_daily": tableAzureComputeDiskMetricWriteOpsDaily(ctx), - // "azure_compute_disk_metric_write_ops_hourly": tableAzureComputeDiskMetricWriteOpsHourly(ctx), + "azure_compute_disk_metric_read_ops": tableAzureComputeDiskMetricReadOps(ctx), + "azure_compute_disk_metric_read_ops_daily": tableAzureComputeDiskMetricReadOpsDaily(ctx), + "azure_compute_disk_metric_read_ops_hourly": tableAzureComputeDiskMetricReadOpsHourly(ctx), + "azure_compute_disk_metric_write_ops": tableAzureComputeDiskMetricWriteOps(ctx), + "azure_compute_disk_metric_write_ops_daily": tableAzureComputeDiskMetricWriteOpsDaily(ctx), + "azure_compute_disk_metric_write_ops_hourly": tableAzureComputeDiskMetricWriteOpsHourly(ctx), "azure_compute_image": tableAzureComputeImage(ctx), "azure_compute_resource_sku": tableAzureResourceSku(ctx), "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), "azure_compute_ssh_key": tableAzureComputeSshKey(ctx), "azure_compute_virtual_machine": tableAzureComputeVirtualMachine(ctx), - // "azure_compute_virtual_machine_metric_cpu_utilization": tableAzureComputeVirtualMachineMetricCpuUtilization(ctx), - // "azure_compute_virtual_machine_metric_cpu_utilization_daily": tableAzureComputeVirtualMachineMetricCpuUtilizationDaily(ctx), - // "azure_compute_virtual_machine_metric_cpu_utilization_hourly": tableAzureComputeVirtualMachineMetricCpuUtilizationHourly(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization": tableAzureComputeVirtualMachineMetricCpuUtilization(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization_daily": tableAzureComputeVirtualMachineMetricCpuUtilizationDaily(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization_hourly": tableAzureComputeVirtualMachineMetricCpuUtilizationHourly(ctx), "azure_compute_virtual_machine_scale_set": tableAzureComputeVirtualMachineScaleSet(ctx), "azure_compute_virtual_machine_scale_set_network_interface": tableAzureComputeVirtualMachineScaleSetNetworkInterface(ctx), "azure_compute_virtual_machine_scale_set_vm": tableAzureComputeVirtualMachineScaleSetVm(ctx), "azure_container_group": tableAzureContainerGroup(ctx), - // "azure_container_registry": tableAzureContainerRegistry(ctx), + "azure_container_registry": tableAzureContainerRegistry(ctx), "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), "azure_cosmosdb_mongo_collection": tableAzureCosmosDBMongoCollection(ctx), "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), "azure_cosmosdb_restorable_database_account": tableAzureCosmosDBRestorableDatabaseAccount(ctx), - // "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), + "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), "azure_data_factory": tableAzureDataFactory(ctx), "azure_data_factory_dataset": tableAzureDataFactoryDataset(ctx), "azure_data_factory_pipeline": tableAzureDataFactoryPipeline(ctx), @@ -120,9 +120,9 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_management_group": tableAzureManagementGroup(ctx), "azure_management_lock": tableAzureManagementLock(ctx), "azure_mariadb_server": tableAzureMariaDBServer(ctx), - // "azure_mssql_elasticpool": tableAzureMSSQLElasticPool(ctx), + "azure_mssql_elasticpool": tableAzureMSSQLElasticPool(ctx), "azure_mssql_managed_instance": tableAzureMSSQLManagedInstance(ctx), - // "azure_mssql_virtual_machine": tableAzureMSSQLVirtualMachine(ctx), + "azure_mssql_virtual_machine": tableAzureMSSQLVirtualMachine(ctx), "azure_mysql_flexible_server": tableAzureMySQLFlexibleServer(ctx), "azure_mysql_server": tableAzureMySQLServer(ctx), "azure_nat_gateway": tableAzureNatGateway(ctx), @@ -145,13 +145,13 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_role_definition": tableAzureIamRoleDefinition(ctx), "azure_route_table": tableAzureRouteTable(ctx), "azure_search_service": tableAzureSearchService(ctx), - // "azure_security_center_automation": tableAzureSecurityCenterAutomation(ctx), + "azure_security_center_automation": tableAzureSecurityCenterAutomation(ctx), "azure_security_center_auto_provisioning": tableAzureSecurityCenterAutoProvisioning(ctx), "azure_security_center_contact": tableAzureSecurityCenterContact(ctx), "azure_security_center_jit_network_access_policy": tableAzureSecurityCenterJITNetworkAccessPolicy(ctx), - // "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), + "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), "azure_security_center_sub_assessment": tableAzureSecurityCenterSubAssessment(ctx), - // "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), + "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), "azure_service_fabric_cluster": tableAzureServiceFabricCluster(ctx), "azure_servicebus_namespace": tableAzureServiceBusNamespace(ctx), "azure_signalr_service": tableAzureSignalRService(ctx), From c1f7ad94f3af340452853bbe22c8f4319e0f3af8 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Mon, 9 Oct 2023 11:09:29 +0530 Subject: [PATCH 05/12] Updated the table name --- azure/plugin.go | 2 +- ...ble_azure_recovery_services_backup_job.go} | 56 +++++++++++++------ ... => azure_recovery_services_backup_job.md} | 10 +--- 3 files changed, 44 insertions(+), 24 deletions(-) rename azure/{table_azure_backup_job.go => table_azure_recovery_services_backup_job.go} (77%) rename docs/tables/{azure_backup_job.md => azure_recovery_services_backup_job.md} (81%) diff --git a/azure/plugin.go b/azure/plugin.go index e1c010ed..c35a6804 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -43,7 +43,6 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_application_security_group": tableAzureApplicationSecurityGroup(ctx), "azure_automation_account": tableAzureApAutomationAccount(ctx), "azure_automation_variable": tableAzureApAutomationVariable(ctx), - "azure_backup_job": tableAzureBackupJob(ctx), "azure_bastion_host": tableAzureBastionHost(ctx), "azure_batch_account": tableAzureBatchAccount(ctx), "azure_cognitive_account": tableAzureCognitiveAccount(ctx), @@ -137,6 +136,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_private_dns_zone": tableAzurePrivateDNSZone(ctx), "azure_provider": tableAzureProvider(ctx), "azure_public_ip": tableAzurePublicIP(ctx), + "azure_recovery_services_backup_job": tableAzureRecoveryServicesBackupJob(ctx), "azure_recovery_services_vault": tableAzureRecoveryServicesVault(ctx), "azure_redis_cache": tableAzureRedisCache(ctx), "azure_resource_group": tableAzureResourceGroup(ctx), diff --git a/azure/table_azure_backup_job.go b/azure/table_azure_recovery_services_backup_job.go similarity index 77% rename from azure/table_azure_backup_job.go rename to azure/table_azure_recovery_services_backup_job.go index 2d29af0f..6142286d 100644 --- a/azure/table_azure_backup_job.go +++ b/azure/table_azure_recovery_services_backup_job.go @@ -2,8 +2,9 @@ package azure import ( "context" + "strings" - "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources" + "github.com/Azure/azure-sdk-for-go/profiles/latest/recoveryservices/mgmt/recoveryservices" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicesbackup/v3" "github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto" @@ -13,20 +14,20 @@ import ( //// TABLE DEFINITION //// -func tableAzureBackupJob(_ context.Context) *plugin.Table { +func tableAzureRecoveryServicesBackupJob(_ context.Context) *plugin.Table { return &plugin.Table{ - Name: "azure_backup_job", - Description: "Azure Backup Job", + Name: "azure_recovery_services_backup_job", + Description: "Azure Recovery Services Backup Job", List: &plugin.ListConfig{ - ParentHydrate: listResourceGroups, - Hydrate: listAzureBackupJobs, + ParentHydrate: listRecoveryServicesVaults, + Hydrate: listRecoveryServicesAzureBackupJobs, IgnoreConfig: &plugin.IgnoreConfig{ ShouldIgnoreErrorFunc: isNotFoundError([]string{"ResourceNotFound", "404"}), }, KeyColumns: plugin.KeyColumnSlice{ { Name: "vault_name", - Require: plugin.Required, + Require: plugin.Optional, }, { Name: "resource_group", @@ -44,7 +45,6 @@ func tableAzureBackupJob(_ context.Context) *plugin.Table { Name: "vault_name", Description: "The recovery vault name.", Type: proto.ColumnType_STRING, - Transform: transform.FromQual("vault_name"), }, { Name: "id", @@ -108,9 +108,20 @@ func tableAzureBackupJob(_ context.Context) *plugin.Table { } } +type JobInfo struct { + VaultName *string + ETag *string + Location *string + Properties armrecoveryservicesbackup.JobClassification + Tags map[string]*string + ID *string + Name *string + Type *string +} + //// LIST FUNCTION //// -func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { +func listRecoveryServicesAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { session, err := GetNewSession(ctx, d, "MANAGEMENT") if err != nil { return nil, err @@ -122,17 +133,21 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd return nil, err } - resourceGroup := h.Item.(resources.Group) + vault := h.Item.(recoveryservices.Vault) + + plugin.Logger(ctx).Error("Parameter ====>>", vault.Name, strings.Split(*vault.ID, "/")[4]) vaultName := d.EqualsQualString("vault_name") rgName := d.EqualsQualString("resource_group") - if vaultName == "" { - return nil, nil + if vaultName != "" { + if vaultName != *vault.Name { + return nil, nil + } } if rgName != "" { - if rgName != *resourceGroup.Name { + if rgName != strings.Split(*vault.ID, "/")[4] { return nil, nil } } @@ -143,7 +158,7 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd plugin.Logger(ctx).Error("azure_backup_job.listAzureBackupJobs", "NewBackupJobsClient", err) return nil, nil } - pager := clientFactory.NewListPager(vaultName, *resourceGroup.Name, &armrecoveryservicesbackup.BackupJobsClientListOptions{Filter: nil, + pager := clientFactory.NewListPager(*vault.Name, strings.Split(*vault.ID, "/")[4], &armrecoveryservicesbackup.BackupJobsClientListOptions{Filter: nil, SkipToken: nil, }) for pager.More() { @@ -154,7 +169,16 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd } for _, v := range page.Value { - d.StreamListItem(ctx, v) + d.StreamListItem(ctx, JobInfo{ + ETag: v.ETag, + Location: v.Location, + Properties: v.Properties, + Tags: v.Tags, + ID: v.ID, + Name: v.Name, + Type: v.Type, + VaultName: vault.Name, + }) // Check if context has been cancelled or if the limit has been hit (if specified) // if there is a limit, it will return the number of rows required to reach this limit @@ -170,7 +194,7 @@ func listAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd //// TRANSFORM FUNCTION func backupJobProperties(ctx context.Context, d *transform.TransformData) (interface{}, error) { - data := d.HydrateItem.(*armrecoveryservicesbackup.JobResource) + data := d.HydrateItem.(JobInfo) output := make(map[string]interface{}) diff --git a/docs/tables/azure_backup_job.md b/docs/tables/azure_recovery_services_backup_job.md similarity index 81% rename from docs/tables/azure_backup_job.md rename to docs/tables/azure_recovery_services_backup_job.md index d1c48348..f2fc5a45 100644 --- a/docs/tables/azure_backup_job.md +++ b/docs/tables/azure_recovery_services_backup_job.md @@ -1,9 +1,7 @@ -# Table: azure_backup_job +# Table: azure_recovery_services_backup_job An Azure Backup job is a task that you can define and run to perform data protection operations on your Azure resources. These jobs are typically used to back up and restore data from various Azure services, such as virtual machines, databases, and files. -**Note**: `vault_name` is required in query parameter to get the job details of the job. - ## Examples ### Basic info @@ -16,7 +14,7 @@ select vault_name, region from - azure_backup_job + azure_recovery_services_backup_job where vault_name = 'my-vault'; ``` @@ -36,7 +34,5 @@ select properties ->> 'StartTime' as start_time, properties ->> 'Status' as Status from - azure_backup_job -where - vault_name = 'my-vault'; + azure_recovery_services_backup_job; ``` From 4fbccb8917aef552fea15761d8f2ad7fffd1ccef Mon Sep 17 00:00:00 2001 From: ParthaI <47887552+ParthaI@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:25:49 +0530 Subject: [PATCH 06/12] Update table_azure_recovery_services_backup_job.go Co-authored-by: Madhushree Ray --- azure/table_azure_recovery_services_backup_job.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_recovery_services_backup_job.go b/azure/table_azure_recovery_services_backup_job.go index 6142286d..54987a85 100644 --- a/azure/table_azure_recovery_services_backup_job.go +++ b/azure/table_azure_recovery_services_backup_job.go @@ -155,7 +155,7 @@ func listRecoveryServicesAzureBackupJobs(ctx context.Context, d *plugin.QueryDat subscriptionID := session.SubscriptionID clientFactory, err := armrecoveryservicesbackup.NewBackupJobsClient(subscriptionID, cred, nil) if err != nil { - plugin.Logger(ctx).Error("azure_backup_job.listAzureBackupJobs", "NewBackupJobsClient", err) + plugin.Logger(ctx).Error("azure_recovery_services_backup_job.listAzureBackupJobs", "client_error", err) return nil, nil } pager := clientFactory.NewListPager(*vault.Name, strings.Split(*vault.ID, "/")[4], &armrecoveryservicesbackup.BackupJobsClientListOptions{Filter: nil, From a55e3eddaa06c03616a6727c11b5eb48d91f54be Mon Sep 17 00:00:00 2001 From: ParthaI <47887552+ParthaI@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:25:56 +0530 Subject: [PATCH 07/12] Update table_azure_recovery_services_backup_job.go Co-authored-by: Madhushree Ray --- azure/table_azure_recovery_services_backup_job.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_recovery_services_backup_job.go b/azure/table_azure_recovery_services_backup_job.go index 54987a85..cd0e7853 100644 --- a/azure/table_azure_recovery_services_backup_job.go +++ b/azure/table_azure_recovery_services_backup_job.go @@ -164,7 +164,7 @@ func listRecoveryServicesAzureBackupJobs(ctx context.Context, d *plugin.QueryDat for pager.More() { page, err := pager.NextPage(ctx) if err != nil { - plugin.Logger(ctx).Error("azure_backup_job.listAzureBackupJobs", "api_error", err) + plugin.Logger(ctx).Error("azure_recovery_services_backup_job.listAzureBackupJobs", "api_error", err) return nil, nil } From f5e9357b6bd321166540c1d1ce699706969efe17 Mon Sep 17 00:00:00 2001 From: Madhushree Ray Date: Mon, 30 Oct 2023 10:26:11 +0530 Subject: [PATCH 08/12] Update table_azure_recovery_services_backup_job.go --- azure/table_azure_recovery_services_backup_job.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_recovery_services_backup_job.go b/azure/table_azure_recovery_services_backup_job.go index cd0e7853..f5e54c45 100644 --- a/azure/table_azure_recovery_services_backup_job.go +++ b/azure/table_azure_recovery_services_backup_job.go @@ -48,7 +48,7 @@ func tableAzureRecoveryServicesBackupJob(_ context.Context) *plugin.Table { }, { Name: "id", - Description: "Resource Id represents the complete path to the resource.", + Description: "Resource ID represents the complete path to the resource.", Type: proto.ColumnType_STRING, Transform: transform.FromGo(), }, From dcce39473aef81a0ab902dce2f2c977bb71e973f Mon Sep 17 00:00:00 2001 From: ParthaI <47887552+ParthaI@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:53:54 +0530 Subject: [PATCH 09/12] Update azure/table_azure_recovery_services_backup_job.go Co-authored-by: Madhushree Ray --- azure/table_azure_recovery_services_backup_job.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_recovery_services_backup_job.go b/azure/table_azure_recovery_services_backup_job.go index f5e54c45..b9db4c22 100644 --- a/azure/table_azure_recovery_services_backup_job.go +++ b/azure/table_azure_recovery_services_backup_job.go @@ -121,7 +121,7 @@ type JobInfo struct { //// LIST FUNCTION //// -func listRecoveryServicesAzureBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { +func listRecoveryServicesBackupJobs(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { session, err := GetNewSession(ctx, d, "MANAGEMENT") if err != nil { return nil, err From 93b27cb9f458480daad66ed7a7fa3c86daf88e80 Mon Sep 17 00:00:00 2001 From: ParthaI <47887552+ParthaI@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:54:01 +0530 Subject: [PATCH 10/12] Update azure/table_azure_recovery_services_backup_job.go Co-authored-by: Madhushree Ray --- azure/table_azure_recovery_services_backup_job.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_recovery_services_backup_job.go b/azure/table_azure_recovery_services_backup_job.go index b9db4c22..d26f2c1c 100644 --- a/azure/table_azure_recovery_services_backup_job.go +++ b/azure/table_azure_recovery_services_backup_job.go @@ -20,7 +20,7 @@ func tableAzureRecoveryServicesBackupJob(_ context.Context) *plugin.Table { Description: "Azure Recovery Services Backup Job", List: &plugin.ListConfig{ ParentHydrate: listRecoveryServicesVaults, - Hydrate: listRecoveryServicesAzureBackupJobs, + Hydrate: listRecoveryServicesBackupJobs, IgnoreConfig: &plugin.IgnoreConfig{ ShouldIgnoreErrorFunc: isNotFoundError([]string{"ResourceNotFound", "404"}), }, From 9c4c75d8645cb43225574387f9d9204787db7aee Mon Sep 17 00:00:00 2001 From: ParthaI <47887552+ParthaI@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:54:08 +0530 Subject: [PATCH 11/12] Update azure/table_azure_recovery_services_backup_job.go Co-authored-by: Madhushree Ray --- azure/table_azure_recovery_services_backup_job.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_recovery_services_backup_job.go b/azure/table_azure_recovery_services_backup_job.go index d26f2c1c..2f8feee4 100644 --- a/azure/table_azure_recovery_services_backup_job.go +++ b/azure/table_azure_recovery_services_backup_job.go @@ -164,7 +164,7 @@ func listRecoveryServicesBackupJobs(ctx context.Context, d *plugin.QueryData, h for pager.More() { page, err := pager.NextPage(ctx) if err != nil { - plugin.Logger(ctx).Error("azure_recovery_services_backup_job.listAzureBackupJobs", "api_error", err) + plugin.Logger(ctx).Error("azure_recovery_services_backup_job.listRecoveryServicesBackupJobs", "api_error", err) return nil, nil } From ebe876452597c7c17d7c99b7449cf469f2826d04 Mon Sep 17 00:00:00 2001 From: ParthaI <47887552+ParthaI@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:54:14 +0530 Subject: [PATCH 12/12] Update azure/table_azure_recovery_services_backup_job.go Co-authored-by: Madhushree Ray --- azure/table_azure_recovery_services_backup_job.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_recovery_services_backup_job.go b/azure/table_azure_recovery_services_backup_job.go index 2f8feee4..50daa48d 100644 --- a/azure/table_azure_recovery_services_backup_job.go +++ b/azure/table_azure_recovery_services_backup_job.go @@ -155,7 +155,7 @@ func listRecoveryServicesBackupJobs(ctx context.Context, d *plugin.QueryData, h subscriptionID := session.SubscriptionID clientFactory, err := armrecoveryservicesbackup.NewBackupJobsClient(subscriptionID, cred, nil) if err != nil { - plugin.Logger(ctx).Error("azure_recovery_services_backup_job.listAzureBackupJobs", "client_error", err) + plugin.Logger(ctx).Error("azure_recovery_services_backup_job.listRecoveryServicesBackupJobs", "client_error", err) return nil, nil } pager := clientFactory.NewListPager(*vault.Name, strings.Split(*vault.ID, "/")[4], &armrecoveryservicesbackup.BackupJobsClientListOptions{Filter: nil,