From cb03971e2d76bbb4241896d714332fb6de7ca7c8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sun, 28 Apr 2024 08:04:26 +0000 Subject: [PATCH] CodeGen from PR 28832 in Azure/azure-rest-api-specs Merge 34d8b6d264d9b8980a3c8fe2dde026319b2ba32f into b8691fbfca8fcdc5a241a0b501c32fd4a76bb0cd --- .../armguestconfiguration/CHANGELOG.md | 16 + .../armguestconfiguration/README.md | 2 +- .../assignmentreports_client_example_test.go | 179 ---------- ...signmentreportsvmss_client_example_test.go | 184 ---------- .../assignments_client_example_test.go | 215 ------------ .../assignmentsvmss_client.go | 74 ++++ .../assignmentsvmss_client_example_test.go | 125 ------- .../armguestconfiguration/autorest.md | 6 +- .../armguestconfiguration/client_factory.go | 66 ++-- ...onnectedvmwarevsphereassignments_client.go | 315 ++++++++++++++++++ ...dvmwarevsphereassignmentsreports_client.go | 190 +++++++++++ .../armguestconfiguration/constants.go | 2 +- .../fake/assignmentsvmss_server.go | 47 +++ ...onnectedvmwarevsphereassignments_server.go | 242 ++++++++++++++ ...dvmwarevsphereassignmentsreports_server.go | 151 +++++++++ .../fake/server_factory.go | 46 ++- .../fake/time_rfc3339.go | 42 ++- .../armguestconfiguration/go.mod | 12 +- .../armguestconfiguration/go.sum | 19 -- ...rpassignmentreports_client_example_test.go | 179 ---------- .../hcrpassignments_client_example_test.go | 162 --------- .../armguestconfiguration/models_serde.go | 2 +- .../operations_client_example_test.go | 82 ----- .../armguestconfiguration/options.go | 42 +++ .../{response_types.go => responses.go} | 41 +++ .../armguestconfiguration/time_rfc3339.go | 42 ++- 26 files changed, 1268 insertions(+), 1215 deletions(-) delete mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client_example_test.go delete mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client_example_test.go delete mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client_example_test.go delete mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client_example_test.go create mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/connectedvmwarevsphereassignments_client.go create mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/connectedvmwarevsphereassignmentsreports_client.go create mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/connectedvmwarevsphereassignments_server.go create mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/connectedvmwarevsphereassignmentsreports_server.go delete mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client_example_test.go delete mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client_example_test.go delete mode 100644 sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client_example_test.go rename sdk/resourcemanager/guestconfiguration/armguestconfiguration/{response_types.go => responses.go} (71%) diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md index 53d2f6284803..49f4220d0fe4 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md @@ -1,5 +1,21 @@ # Release History +## 1.3.0 (2024-04-28) +### Features Added + +- New function `*AssignmentsVMSSClient.CreateOrUpdate(context.Context, string, string, string, Assignment, *AssignmentsVMSSClientCreateOrUpdateOptions) (AssignmentsVMSSClientCreateOrUpdateResponse, error)` +- New function `*ClientFactory.NewConnectedVMwarevSphereAssignmentsClient() *ConnectedVMwarevSphereAssignmentsClient` +- New function `*ClientFactory.NewConnectedVMwarevSphereAssignmentsReportsClient() *ConnectedVMwarevSphereAssignmentsReportsClient` +- New function `NewConnectedVMwarevSphereAssignmentsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ConnectedVMwarevSphereAssignmentsClient, error)` +- New function `*ConnectedVMwarevSphereAssignmentsClient.CreateOrUpdate(context.Context, string, string, string, Assignment, *ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateOptions) (ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse, error)` +- New function `*ConnectedVMwarevSphereAssignmentsClient.Delete(context.Context, string, string, string, *ConnectedVMwarevSphereAssignmentsClientDeleteOptions) (ConnectedVMwarevSphereAssignmentsClientDeleteResponse, error)` +- New function `*ConnectedVMwarevSphereAssignmentsClient.Get(context.Context, string, string, string, *ConnectedVMwarevSphereAssignmentsClientGetOptions) (ConnectedVMwarevSphereAssignmentsClientGetResponse, error)` +- New function `*ConnectedVMwarevSphereAssignmentsClient.NewListPager(string, string, *ConnectedVMwarevSphereAssignmentsClientListOptions) *runtime.Pager[ConnectedVMwarevSphereAssignmentsClientListResponse]` +- New function `NewConnectedVMwarevSphereAssignmentsReportsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ConnectedVMwarevSphereAssignmentsReportsClient, error)` +- New function `*ConnectedVMwarevSphereAssignmentsReportsClient.Get(context.Context, string, string, string, string, *ConnectedVMwarevSphereAssignmentsReportsClientGetOptions) (ConnectedVMwarevSphereAssignmentsReportsClientGetResponse, error)` +- New function `*ConnectedVMwarevSphereAssignmentsReportsClient.List(context.Context, string, string, string, *ConnectedVMwarevSphereAssignmentsReportsClientListOptions) (ConnectedVMwarevSphereAssignmentsReportsClientListResponse, error)` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md index 044535d55a04..4e26346c704c 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md @@ -57,7 +57,7 @@ clientFactory, err := armguestconfiguration.NewClientFactory(, A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewAssignmentsClient() +client := clientFactory.NewAssignmentReportsClient() ``` ## Fakes diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client_example_test.go deleted file mode 100644 index a62a0b68ef2e..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client_example_test.go +++ /dev/null @@ -1,179 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllGuestConfigurationAssignmentReports.json -func ExampleAssignmentReportsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentReportsClient().List(ctx, "myResourceGroupName", "AuditSecureProtocol", "myVMName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AssignmentReportList = armguestconfiguration.AssignmentReportList{ - // Value: []*armguestconfiguration.AssignmentReport{ - // { - // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm"), - // UUID: to.Ptr("vmuuid"), - // }, - // }, - // }, - // { - // Name: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:14:13.000Z"); return t}()), - // ReportID: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm"), - // UUID: to.Ptr("vmuuid"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationAssignmentReportById.json -func ExampleAssignmentReportsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentReportsClient().Get(ctx, "myResourceGroupName", "AuditSecureProtocol", "7367cbb8-ae99-47d0-a33b-a283564d2cb1", "myvm", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AssignmentReport = armguestconfiguration.AssignmentReport{ - // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Version: to.Ptr("1.0.0.0"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm"), - // UUID: to.Ptr("vmuuid"), - // }, - // Details: &armguestconfiguration.AssignmentReportDetails{ - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // JobID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // OperationType: to.Ptr(armguestconfiguration.TypeConsistency), - // Resources: []*armguestconfiguration.AssignmentReportResource{ - // { - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // Properties: map[string]any{ - // "ConfigurationName": "IsWebServerSecure", - // "DependsOn": nil, - // "IsSingleInstance": "Yes", - // "ModuleName": "SecureProtocolWebServer", - // "ModuleVersion": "1.0.0.3", - // "Protocols":[]any{ - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "SSL 2.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "SSL 3.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "PCT 1.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "Multi-Protocol Unified Hello", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.1", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.2", - // }, - // }, - // "PsDscRunAsCredential": nil, - // "Reasons": nil, - // "ResourceId": "[SecureWebServer]s1", - // "SourceInfo": nil, - // }, - // Reasons: []*armguestconfiguration.AssignmentReportResourceComplianceReason{ - // { - // Code: to.Ptr("DSC::RESOURCE::SUCCESS"), - // Phrase: to.Ptr("Operation successful."), - // }}, - // }}, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client_example_test.go deleted file mode 100644 index 8b700ce62d55..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client_example_test.go +++ /dev/null @@ -1,184 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllVMSSGuestConfigurationAssignmentReports.json -func ExampleAssignmentReportsVMSSClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentReportsVMSSClient().NewListPager("myResourceGroupName", "myVMSSName", "AuditSecureProtocol", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssignmentReportList = armguestconfiguration.AssignmentReportList{ - // Value: []*armguestconfiguration.AssignmentReport{ - // { - // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/virtualMachines/1"), - // UUID: to.Ptr("vmuuid"), - // }, - // }, - // }, - // { - // Name: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:14:13.000Z"); return t}()), - // ReportID: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/virtualMachines/1"), - // UUID: to.Ptr("vmuuid"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getVMSSGuestConfigurationAssignmentReportById.json -func ExampleAssignmentReportsVMSSClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentReportsVMSSClient().Get(ctx, "myResourceGroupName", "myvmss", "AuditSecureProtocol", "7367cbb8-ae99-47d0-a33b-a283564d2cb1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AssignmentReport = armguestconfiguration.AssignmentReport{ - // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myvmss/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Version: to.Ptr("1.0.0.0"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mySubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myvmss/virtualMachines/1"), - // UUID: to.Ptr("vmuuid"), - // }, - // Details: &armguestconfiguration.AssignmentReportDetails{ - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // JobID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // OperationType: to.Ptr(armguestconfiguration.TypeConsistency), - // Resources: []*armguestconfiguration.AssignmentReportResource{ - // { - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // Properties: map[string]any{ - // "ConfigurationName": "IsWebServerSecure", - // "DependsOn": nil, - // "IsSingleInstance": "Yes", - // "ModuleName": "SecureProtocolWebServer", - // "ModuleVersion": "1.0.0.3", - // "Protocols":[]any{ - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "SSL 2.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "SSL 3.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "PCT 1.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "Multi-Protocol Unified Hello", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.1", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.2", - // }, - // }, - // "PsDscRunAsCredential": nil, - // "Reasons": nil, - // "ResourceId": "[SecureWebServer]s1", - // "SourceInfo": nil, - // }, - // Reasons: []*armguestconfiguration.AssignmentReportResourceComplianceReason{ - // { - // Code: to.Ptr("DSC::RESOURCE::SUCCESS"), - // Phrase: to.Ptr("Operation successful."), - // }}, - // }}, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client_example_test.go deleted file mode 100644 index c4b9a262ef48..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client_example_test.go +++ /dev/null @@ -1,215 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/createOrUpdateGuestConfigurationAssignment.json -func ExampleAssignmentsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().CreateOrUpdate(ctx, "NotInstalledApplicationForWindows", "myResourceGroupName", "myVMName", armguestconfiguration.Assignment{ - Name: to.Ptr("NotInstalledApplicationForWindows"), - Location: to.Ptr("westcentralus"), - Properties: &armguestconfiguration.AssignmentProperties{ - Context: to.Ptr("Azure policy"), - GuestConfiguration: &armguestconfiguration.Navigation{ - Name: to.Ptr("NotInstalledApplicationForWindows"), - AssignmentType: to.Ptr(armguestconfiguration.AssignmentTypeApplyAndAutoCorrect), - ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - { - Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), - Value: to.Ptr("NotePad,sql"), - }}, - ContentHash: to.Ptr("123contenthash"), - ContentURI: to.Ptr("https://thisisfake/pacakge"), - Version: to.Ptr("1.*"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Assignment = armguestconfiguration.Assignment{ - // Name: to.Ptr("NotInstalledApplicationForWindows"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/NotInstalledApplicationForWindows"), - // Location: to.Ptr("westcentralus"), - // Properties: &armguestconfiguration.AssignmentProperties{ - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusPending), - // Context: to.Ptr("Azure policy"), - // GuestConfiguration: &armguestconfiguration.Navigation{ - // Name: to.Ptr("NotInstalledApplicationForWindows"), - // AssignmentSource: to.Ptr("AzurePolicy"), - // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - // { - // Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), - // Value: to.Ptr("NotePad,sql"), - // }}, - // Version: to.Ptr("1.0.0.3"), - // }, - // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationAssignment.json -func ExampleAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "myResourceGroupName", "SecureProtocol", "myVMName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Assignment = armguestconfiguration.Assignment{ - // Name: to.Ptr("AuditSecureProtocol"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol"), - // Location: to.Ptr("centraluseuap"), - // Properties: &armguestconfiguration.AssignmentProperties{ - // AssignmentHash: to.Ptr("E0D8941DD713F284284561648C00C18FA76C8602943C7CD38AFD73B56AE4C35F.E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"), - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // GuestConfiguration: &armguestconfiguration.Navigation{ - // Name: to.Ptr("AuditSecureProtocol"), - // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - // }, - // ContentHash: to.Ptr("content hash"), - // ContentURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/builtinconfig/AuditSecureProtocol/AuditSecureProtocol_1.0.0.3.zip"), - // Version: to.Ptr("1.0.0.3"), - // }, - // LastComplianceStatusChecked: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // LatestReportID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationAssignment.json -func ExampleAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Delete(ctx, "myResourceGroupName", "SecureProtocol", "myVMName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listSubGuestConfigurationAssignments.json -func ExampleAssignmentsClient_NewSubscriptionListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewSubscriptionListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssignmentList = armguestconfiguration.AssignmentList{ - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listRGGuestConfigurationAssignments.json -func ExampleAssignmentsClient_NewRGListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewRGListPager("myResourceGroupName", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssignmentList = armguestconfiguration.AssignmentList{ - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listGuestConfigurationAssignments.json -func ExampleAssignmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListPager("myResourceGroupName", "myVMName", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssignmentList = armguestconfiguration.AssignmentList{ - // } - } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client.go index 8c3c6de39689..2e28a15a5978 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client.go @@ -44,6 +44,80 @@ func NewAssignmentsVMSSClient(subscriptionID string, credential azcore.TokenCred return client, nil } +// CreateOrUpdate - Creates an association between a VMSS and guest configuration +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-25 +// - resourceGroupName - The resource group name. +// - vmssName - The name of the virtual machine scale set. +// - name - Name of the guest configuration assignment. +// - parameters - Parameters supplied to the create or update guest configuration assignment. +// - options - AssignmentsVMSSClientCreateOrUpdateOptions contains the optional parameters for the AssignmentsVMSSClient.CreateOrUpdate +// method. +func (client *AssignmentsVMSSClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, vmssName string, name string, parameters Assignment, options *AssignmentsVMSSClientCreateOrUpdateOptions) (AssignmentsVMSSClientCreateOrUpdateResponse, error) { + var err error + const operationName = "AssignmentsVMSSClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vmssName, name, parameters, options) + if err != nil { + return AssignmentsVMSSClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AssignmentsVMSSClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return AssignmentsVMSSClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AssignmentsVMSSClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vmssName string, name string, parameters Assignment, options *AssignmentsVMSSClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if vmssName == "" { + return nil, errors.New("parameter vmssName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmssName}", url.PathEscape(vmssName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-01-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AssignmentsVMSSClient) createOrUpdateHandleResponse(resp *http.Response) (AssignmentsVMSSClientCreateOrUpdateResponse, error) { + result := AssignmentsVMSSClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { + return AssignmentsVMSSClientCreateOrUpdateResponse{}, err + } + return result, nil +} + // Delete - Delete a guest configuration assignment for VMSS // If the operation fails it returns an *azcore.ResponseError type. // diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client_example_test.go deleted file mode 100644 index 95966c51a276..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client_example_test.go +++ /dev/null @@ -1,125 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getVMSSGuestConfigurationAssignment.json -func ExampleAssignmentsVMSSClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsVMSSClient().Get(ctx, "myResourceGroupName", "myVMSSName", "SecureProtocol", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Assignment = armguestconfiguration.Assignment{ - // Name: to.Ptr("AuditSecureProtocol"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol"), - // Location: to.Ptr("centraluseuap"), - // Properties: &armguestconfiguration.AssignmentProperties{ - // AssignmentHash: to.Ptr("E0D8941DD713F284284561648C00C18FA76C8602943C7CD38AFD73B56AE4C35F.E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"), - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // GuestConfiguration: &armguestconfiguration.Navigation{ - // Name: to.Ptr("AuditSecureProtocol"), - // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - // }, - // ContentHash: to.Ptr("content hash"), - // ContentURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/builtinconfig/AuditSecureProtocol/AuditSecureProtocol_1.0.0.3.zip"), - // Version: to.Ptr("1.0.0.3"), - // }, - // LastComplianceStatusChecked: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), - // ResourceType: to.Ptr("VMSS"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationVMSSAssignment.json -func ExampleAssignmentsVMSSClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsVMSSClient().Delete(ctx, "myResourceGroupName", "myVMSSName", "SecureProtocol", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Assignment = armguestconfiguration.Assignment{ - // Name: to.Ptr("AuditSecureProtocol"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol"), - // Location: to.Ptr("centraluseuap"), - // Properties: &armguestconfiguration.AssignmentProperties{ - // AssignmentHash: to.Ptr("E0D8941DD713F284284561648C00C18FA76C8602943C7CD38AFD73B56AE4C35F.E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"), - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // GuestConfiguration: &armguestconfiguration.Navigation{ - // Name: to.Ptr("AuditSecureProtocol"), - // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - // }, - // ContentHash: to.Ptr("content hash"), - // ContentURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/builtinconfig/AuditSecureProtocol/AuditSecureProtocol_1.0.0.3.zip"), - // Version: to.Ptr("1.0.0.3"), - // }, - // LastComplianceStatusChecked: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), - // ResourceType: to.Ptr("VMSS"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listVMSSGuestConfigurationAssignments.json -func ExampleAssignmentsVMSSClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsVMSSClient().NewListPager("myResourceGroupName", "myVMSSName", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssignmentList = armguestconfiguration.AssignmentList{ - // } - } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md index c57def9fdf1f..806a9618c594 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/guestconfiguration/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/guestconfiguration/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 1.3.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/client_factory.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/client_factory.go index 5b4cb1e582a5..015e583e9d04 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/client_factory.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/client_factory.go @@ -17,8 +17,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -28,54 +27,83 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewAssignmentReportsClient creates a new instance of AssignmentReportsClient. func (c *ClientFactory) NewAssignmentReportsClient() *AssignmentReportsClient { - subClient, _ := NewAssignmentReportsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AssignmentReportsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAssignmentReportsVMSSClient creates a new instance of AssignmentReportsVMSSClient. func (c *ClientFactory) NewAssignmentReportsVMSSClient() *AssignmentReportsVMSSClient { - subClient, _ := NewAssignmentReportsVMSSClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AssignmentReportsVMSSClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAssignmentsClient creates a new instance of AssignmentsClient. func (c *ClientFactory) NewAssignmentsClient() *AssignmentsClient { - subClient, _ := NewAssignmentsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AssignmentsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAssignmentsVMSSClient creates a new instance of AssignmentsVMSSClient. func (c *ClientFactory) NewAssignmentsVMSSClient() *AssignmentsVMSSClient { - subClient, _ := NewAssignmentsVMSSClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AssignmentsVMSSClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewConnectedVMwarevSphereAssignmentsClient creates a new instance of ConnectedVMwarevSphereAssignmentsClient. +func (c *ClientFactory) NewConnectedVMwarevSphereAssignmentsClient() *ConnectedVMwarevSphereAssignmentsClient { + return &ConnectedVMwarevSphereAssignmentsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewConnectedVMwarevSphereAssignmentsReportsClient creates a new instance of ConnectedVMwarevSphereAssignmentsReportsClient. +func (c *ClientFactory) NewConnectedVMwarevSphereAssignmentsReportsClient() *ConnectedVMwarevSphereAssignmentsReportsClient { + return &ConnectedVMwarevSphereAssignmentsReportsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewHCRPAssignmentReportsClient creates a new instance of HCRPAssignmentReportsClient. func (c *ClientFactory) NewHCRPAssignmentReportsClient() *HCRPAssignmentReportsClient { - subClient, _ := NewHCRPAssignmentReportsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &HCRPAssignmentReportsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewHCRPAssignmentsClient creates a new instance of HCRPAssignmentsClient. func (c *ClientFactory) NewHCRPAssignmentsClient() *HCRPAssignmentsClient { - subClient, _ := NewHCRPAssignmentsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &HCRPAssignmentsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/connectedvmwarevsphereassignments_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/connectedvmwarevsphereassignments_client.go new file mode 100644 index 000000000000..3ae9fde05798 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/connectedvmwarevsphereassignments_client.go @@ -0,0 +1,315 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armguestconfiguration + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ConnectedVMwarevSphereAssignmentsClient contains the methods for the GuestConfigurationConnectedVMwarevSphereAssignments group. +// Don't use this type directly, use NewConnectedVMwarevSphereAssignmentsClient() instead. +type ConnectedVMwarevSphereAssignmentsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewConnectedVMwarevSphereAssignmentsClient creates a new instance of ConnectedVMwarevSphereAssignmentsClient with the specified values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewConnectedVMwarevSphereAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectedVMwarevSphereAssignmentsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ConnectedVMwarevSphereAssignmentsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates an association between a Connected VM Sphere machine and guest configuration +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-25 +// - resourceGroupName - The resource group name. +// - vmName - The name of the virtual machine. +// - guestConfigurationAssignmentName - Name of the guest configuration assignment. +// - parameters - Parameters supplied to the create or update guest configuration assignment. +// - options - ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsClient.CreateOrUpdate +// method. +func (client *ConnectedVMwarevSphereAssignmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, parameters Assignment, options *ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateOptions) (ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ConnectedVMwarevSphereAssignmentsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vmName, guestConfigurationAssignmentName, parameters, options) + if err != nil { + return ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ConnectedVMwarevSphereAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, parameters Assignment, options *ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-01-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ConnectedVMwarevSphereAssignmentsClient) createOrUpdateHandleResponse(resp *http.Response) (ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse, error) { + result := ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { + return ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a guest configuration assignment +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-25 +// - resourceGroupName - The resource group name. +// - vmName - The name of the virtual machine. +// - guestConfigurationAssignmentName - Name of the guest configuration assignment +// - options - ConnectedVMwarevSphereAssignmentsClientDeleteOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsClient.Delete +// method. +func (client *ConnectedVMwarevSphereAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *ConnectedVMwarevSphereAssignmentsClientDeleteOptions) (ConnectedVMwarevSphereAssignmentsClientDeleteResponse, error) { + var err error + const operationName = "ConnectedVMwarevSphereAssignmentsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, vmName, guestConfigurationAssignmentName, options) + if err != nil { + return ConnectedVMwarevSphereAssignmentsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectedVMwarevSphereAssignmentsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ConnectedVMwarevSphereAssignmentsClientDeleteResponse{}, err + } + return ConnectedVMwarevSphereAssignmentsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ConnectedVMwarevSphereAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *ConnectedVMwarevSphereAssignmentsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-01-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get information about a guest configuration assignment +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-25 +// - resourceGroupName - The resource group name. +// - vmName - The name of the virtual machine. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - options - ConnectedVMwarevSphereAssignmentsClientGetOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsClient.Get +// method. +func (client *ConnectedVMwarevSphereAssignmentsClient) Get(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *ConnectedVMwarevSphereAssignmentsClientGetOptions) (ConnectedVMwarevSphereAssignmentsClientGetResponse, error) { + var err error + const operationName = "ConnectedVMwarevSphereAssignmentsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, vmName, guestConfigurationAssignmentName, options) + if err != nil { + return ConnectedVMwarevSphereAssignmentsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectedVMwarevSphereAssignmentsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ConnectedVMwarevSphereAssignmentsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ConnectedVMwarevSphereAssignmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *ConnectedVMwarevSphereAssignmentsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-01-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ConnectedVMwarevSphereAssignmentsClient) getHandleResponse(resp *http.Response) (ConnectedVMwarevSphereAssignmentsClientGetResponse, error) { + result := ConnectedVMwarevSphereAssignmentsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { + return ConnectedVMwarevSphereAssignmentsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all guest configuration assignments for an ARC machine. +// +// Generated from API version 2022-01-25 +// - resourceGroupName - The resource group name. +// - vmName - The name of the virtual machine. +// - options - ConnectedVMwarevSphereAssignmentsClientListOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsClient.NewListPager +// method. +func (client *ConnectedVMwarevSphereAssignmentsClient) NewListPager(resourceGroupName string, vmName string, options *ConnectedVMwarevSphereAssignmentsClientListOptions) *runtime.Pager[ConnectedVMwarevSphereAssignmentsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ConnectedVMwarevSphereAssignmentsClientListResponse]{ + More: func(page ConnectedVMwarevSphereAssignmentsClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *ConnectedVMwarevSphereAssignmentsClientListResponse) (ConnectedVMwarevSphereAssignmentsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConnectedVMwarevSphereAssignmentsClient.NewListPager") + req, err := client.listCreateRequest(ctx, resourceGroupName, vmName, options) + if err != nil { + return ConnectedVMwarevSphereAssignmentsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectedVMwarevSphereAssignmentsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ConnectedVMwarevSphereAssignmentsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ConnectedVMwarevSphereAssignmentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, vmName string, options *ConnectedVMwarevSphereAssignmentsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-01-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ConnectedVMwarevSphereAssignmentsClient) listHandleResponse(resp *http.Response) (ConnectedVMwarevSphereAssignmentsClientListResponse, error) { + result := ConnectedVMwarevSphereAssignmentsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AssignmentList); err != nil { + return ConnectedVMwarevSphereAssignmentsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/connectedvmwarevsphereassignmentsreports_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/connectedvmwarevsphereassignmentsreports_client.go new file mode 100644 index 000000000000..81f29b34010e --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/connectedvmwarevsphereassignmentsreports_client.go @@ -0,0 +1,190 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armguestconfiguration + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ConnectedVMwarevSphereAssignmentsReportsClient contains the methods for the GuestConfigurationConnectedVMwarevSphereAssignmentsReports group. +// Don't use this type directly, use NewConnectedVMwarevSphereAssignmentsReportsClient() instead. +type ConnectedVMwarevSphereAssignmentsReportsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewConnectedVMwarevSphereAssignmentsReportsClient creates a new instance of ConnectedVMwarevSphereAssignmentsReportsClient with the specified values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewConnectedVMwarevSphereAssignmentsReportsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectedVMwarevSphereAssignmentsReportsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ConnectedVMwarevSphereAssignmentsReportsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get a report for the guest configuration assignment, by reportId. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-25 +// - resourceGroupName - The resource group name. +// - vmName - The name of the virtual machine. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - reportID - The GUID for the guest configuration assignment report. +// - options - ConnectedVMwarevSphereAssignmentsReportsClientGetOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsReportsClient.Get +// method. +func (client *ConnectedVMwarevSphereAssignmentsReportsClient) Get(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, reportID string, options *ConnectedVMwarevSphereAssignmentsReportsClientGetOptions) (ConnectedVMwarevSphereAssignmentsReportsClientGetResponse, error) { + var err error + const operationName = "ConnectedVMwarevSphereAssignmentsReportsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, vmName, guestConfigurationAssignmentName, reportID, options) + if err != nil { + return ConnectedVMwarevSphereAssignmentsReportsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectedVMwarevSphereAssignmentsReportsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ConnectedVMwarevSphereAssignmentsReportsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ConnectedVMwarevSphereAssignmentsReportsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, reportID string, options *ConnectedVMwarevSphereAssignmentsReportsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if reportID == "" { + return nil, errors.New("parameter reportID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportId}", url.PathEscape(reportID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-01-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ConnectedVMwarevSphereAssignmentsReportsClient) getHandleResponse(resp *http.Response) (ConnectedVMwarevSphereAssignmentsReportsClientGetResponse, error) { + result := ConnectedVMwarevSphereAssignmentsReportsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AssignmentReport); err != nil { + return ConnectedVMwarevSphereAssignmentsReportsClientGetResponse{}, err + } + return result, nil +} + +// List - List all reports for the guest configuration assignment, latest report first. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-25 +// - resourceGroupName - The resource group name. +// - vmName - The name of the virtual machine. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - options - ConnectedVMwarevSphereAssignmentsReportsClientListOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsReportsClient.List +// method. +func (client *ConnectedVMwarevSphereAssignmentsReportsClient) List(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *ConnectedVMwarevSphereAssignmentsReportsClientListOptions) (ConnectedVMwarevSphereAssignmentsReportsClientListResponse, error) { + var err error + const operationName = "ConnectedVMwarevSphereAssignmentsReportsClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listCreateRequest(ctx, resourceGroupName, vmName, guestConfigurationAssignmentName, options) + if err != nil { + return ConnectedVMwarevSphereAssignmentsReportsClientListResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectedVMwarevSphereAssignmentsReportsClientListResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ConnectedVMwarevSphereAssignmentsReportsClientListResponse{}, err + } + resp, err := client.listHandleResponse(httpResp) + return resp, err +} + +// listCreateRequest creates the List request. +func (client *ConnectedVMwarevSphereAssignmentsReportsClient) listCreateRequest(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *ConnectedVMwarevSphereAssignmentsReportsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-01-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ConnectedVMwarevSphereAssignmentsReportsClient) listHandleResponse(resp *http.Response) (ConnectedVMwarevSphereAssignmentsReportsClientListResponse, error) { + result := ConnectedVMwarevSphereAssignmentsReportsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AssignmentReportList); err != nil { + return ConnectedVMwarevSphereAssignmentsReportsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/constants.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/constants.go index 32b6d03c2c82..cb57f9dc29a8 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/constants.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/constants.go @@ -10,7 +10,7 @@ package armguestconfiguration const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" - moduleVersion = "v1.2.0" + moduleVersion = "v1.3.0" ) // ActionAfterReboot - Specifies what happens after a reboot during the application of a configuration. The possible values diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/assignmentsvmss_server.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/assignmentsvmss_server.go index 0b9a88e91a6e..941a3460736f 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/assignmentsvmss_server.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/assignmentsvmss_server.go @@ -23,6 +23,10 @@ import ( // AssignmentsVMSSServer is a fake server for instances of the armguestconfiguration.AssignmentsVMSSClient type. type AssignmentsVMSSServer struct { + // CreateOrUpdate is the fake for method AssignmentsVMSSClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, vmssName string, name string, parameters armguestconfiguration.Assignment, options *armguestconfiguration.AssignmentsVMSSClientCreateOrUpdateOptions) (resp azfake.Responder[armguestconfiguration.AssignmentsVMSSClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + // Delete is the fake for method AssignmentsVMSSClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent Delete func(ctx context.Context, resourceGroupName string, vmssName string, name string, options *armguestconfiguration.AssignmentsVMSSClientDeleteOptions) (resp azfake.Responder[armguestconfiguration.AssignmentsVMSSClientDeleteResponse], errResp azfake.ErrorResponder) @@ -65,6 +69,8 @@ func (a *AssignmentsVMSSServerTransport) Do(req *http.Request) (*http.Response, var err error switch method { + case "AssignmentsVMSSClient.CreateOrUpdate": + resp, err = a.dispatchCreateOrUpdate(req) case "AssignmentsVMSSClient.Delete": resp, err = a.dispatchDelete(req) case "AssignmentsVMSSClient.Get": @@ -82,6 +88,47 @@ func (a *AssignmentsVMSSServerTransport) Do(req *http.Request) (*http.Response, return resp, nil } +func (a *AssignmentsVMSSServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if a.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Compute/virtualMachineScaleSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.GuestConfiguration/guestConfigurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armguestconfiguration.Assignment](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vmssNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmssName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, vmssNameParam, nameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Assignment, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (a *AssignmentsVMSSServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if a.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/connectedvmwarevsphereassignments_server.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/connectedvmwarevsphereassignments_server.go new file mode 100644 index 000000000000..c847e3e67db6 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/connectedvmwarevsphereassignments_server.go @@ -0,0 +1,242 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" + "net/http" + "net/url" + "regexp" +) + +// ConnectedVMwarevSphereAssignmentsServer is a fake server for instances of the armguestconfiguration.ConnectedVMwarevSphereAssignmentsClient type. +type ConnectedVMwarevSphereAssignmentsServer struct { + // CreateOrUpdate is the fake for method ConnectedVMwarevSphereAssignmentsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, parameters armguestconfiguration.Assignment, options *armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateOptions) (resp azfake.Responder[armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ConnectedVMwarevSphereAssignmentsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientDeleteOptions) (resp azfake.Responder[armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ConnectedVMwarevSphereAssignmentsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientGetOptions) (resp azfake.Responder[armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ConnectedVMwarevSphereAssignmentsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vmName string, options *armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientListOptions) (resp azfake.PagerResponder[armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientListResponse]) +} + +// NewConnectedVMwarevSphereAssignmentsServerTransport creates a new instance of ConnectedVMwarevSphereAssignmentsServerTransport with the provided implementation. +// The returned ConnectedVMwarevSphereAssignmentsServerTransport instance is connected to an instance of armguestconfiguration.ConnectedVMwarevSphereAssignmentsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewConnectedVMwarevSphereAssignmentsServerTransport(srv *ConnectedVMwarevSphereAssignmentsServer) *ConnectedVMwarevSphereAssignmentsServerTransport { + return &ConnectedVMwarevSphereAssignmentsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientListResponse]](), + } +} + +// ConnectedVMwarevSphereAssignmentsServerTransport connects instances of armguestconfiguration.ConnectedVMwarevSphereAssignmentsClient to instances of ConnectedVMwarevSphereAssignmentsServer. +// Don't use this type directly, use NewConnectedVMwarevSphereAssignmentsServerTransport instead. +type ConnectedVMwarevSphereAssignmentsServerTransport struct { + srv *ConnectedVMwarevSphereAssignmentsServer + newListPager *tracker[azfake.PagerResponder[armguestconfiguration.ConnectedVMwarevSphereAssignmentsClientListResponse]] +} + +// Do implements the policy.Transporter interface for ConnectedVMwarevSphereAssignmentsServerTransport. +func (c *ConnectedVMwarevSphereAssignmentsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ConnectedVMwarevSphereAssignmentsClient.CreateOrUpdate": + resp, err = c.dispatchCreateOrUpdate(req) + case "ConnectedVMwarevSphereAssignmentsClient.Delete": + resp, err = c.dispatchDelete(req) + case "ConnectedVMwarevSphereAssignmentsClient.Get": + resp, err = c.dispatchGet(req) + case "ConnectedVMwarevSphereAssignmentsClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *ConnectedVMwarevSphereAssignmentsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ConnectedVMwarevSphere/virtualmachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.GuestConfiguration/guestConfigurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armguestconfiguration.Assignment](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vmNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmName")]) + if err != nil { + return nil, err + } + guestConfigurationAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("guestConfigurationAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, vmNameParam, guestConfigurationAssignmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Assignment, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ConnectedVMwarevSphereAssignmentsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if c.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ConnectedVMwarevSphere/virtualmachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.GuestConfiguration/guestConfigurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vmNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmName")]) + if err != nil { + return nil, err + } + guestConfigurationAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("guestConfigurationAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Delete(req.Context(), resourceGroupNameParam, vmNameParam, guestConfigurationAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ConnectedVMwarevSphereAssignmentsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ConnectedVMwarevSphere/virtualmachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.GuestConfiguration/guestConfigurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vmNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmName")]) + if err != nil { + return nil, err + } + guestConfigurationAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("guestConfigurationAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, vmNameParam, guestConfigurationAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Assignment, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ConnectedVMwarevSphereAssignmentsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := c.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ConnectedVMwarevSphere/virtualmachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.GuestConfiguration/guestConfigurationAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vmNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListPager(resourceGroupNameParam, vmNameParam, nil) + newListPager = &resp + c.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + c.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/connectedvmwarevsphereassignmentsreports_server.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/connectedvmwarevsphereassignmentsreports_server.go new file mode 100644 index 000000000000..d22ddc61076b --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/connectedvmwarevsphereassignmentsreports_server.go @@ -0,0 +1,151 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" + "net/http" + "net/url" + "regexp" +) + +// ConnectedVMwarevSphereAssignmentsReportsServer is a fake server for instances of the armguestconfiguration.ConnectedVMwarevSphereAssignmentsReportsClient type. +type ConnectedVMwarevSphereAssignmentsReportsServer struct { + // Get is the fake for method ConnectedVMwarevSphereAssignmentsReportsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, reportID string, options *armguestconfiguration.ConnectedVMwarevSphereAssignmentsReportsClientGetOptions) (resp azfake.Responder[armguestconfiguration.ConnectedVMwarevSphereAssignmentsReportsClientGetResponse], errResp azfake.ErrorResponder) + + // List is the fake for method ConnectedVMwarevSphereAssignmentsReportsClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, vmName string, guestConfigurationAssignmentName string, options *armguestconfiguration.ConnectedVMwarevSphereAssignmentsReportsClientListOptions) (resp azfake.Responder[armguestconfiguration.ConnectedVMwarevSphereAssignmentsReportsClientListResponse], errResp azfake.ErrorResponder) +} + +// NewConnectedVMwarevSphereAssignmentsReportsServerTransport creates a new instance of ConnectedVMwarevSphereAssignmentsReportsServerTransport with the provided implementation. +// The returned ConnectedVMwarevSphereAssignmentsReportsServerTransport instance is connected to an instance of armguestconfiguration.ConnectedVMwarevSphereAssignmentsReportsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewConnectedVMwarevSphereAssignmentsReportsServerTransport(srv *ConnectedVMwarevSphereAssignmentsReportsServer) *ConnectedVMwarevSphereAssignmentsReportsServerTransport { + return &ConnectedVMwarevSphereAssignmentsReportsServerTransport{srv: srv} +} + +// ConnectedVMwarevSphereAssignmentsReportsServerTransport connects instances of armguestconfiguration.ConnectedVMwarevSphereAssignmentsReportsClient to instances of ConnectedVMwarevSphereAssignmentsReportsServer. +// Don't use this type directly, use NewConnectedVMwarevSphereAssignmentsReportsServerTransport instead. +type ConnectedVMwarevSphereAssignmentsReportsServerTransport struct { + srv *ConnectedVMwarevSphereAssignmentsReportsServer +} + +// Do implements the policy.Transporter interface for ConnectedVMwarevSphereAssignmentsReportsServerTransport. +func (c *ConnectedVMwarevSphereAssignmentsReportsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ConnectedVMwarevSphereAssignmentsReportsClient.Get": + resp, err = c.dispatchGet(req) + case "ConnectedVMwarevSphereAssignmentsReportsClient.List": + resp, err = c.dispatchList(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *ConnectedVMwarevSphereAssignmentsReportsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ConnectedVMwarevSphere/virtualmachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.GuestConfiguration/guestConfigurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vmNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmName")]) + if err != nil { + return nil, err + } + guestConfigurationAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("guestConfigurationAssignmentName")]) + if err != nil { + return nil, err + } + reportIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportId")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, vmNameParam, guestConfigurationAssignmentNameParam, reportIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AssignmentReport, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ConnectedVMwarevSphereAssignmentsReportsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if c.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ConnectedVMwarevSphere/virtualmachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.GuestConfiguration/guestConfigurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reports` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vmNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmName")]) + if err != nil { + return nil, err + } + guestConfigurationAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("guestConfigurationAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.List(req.Context(), resourceGroupNameParam, vmNameParam, guestConfigurationAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AssignmentReportList, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/server_factory.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/server_factory.go index 0570c3a182d3..49bfe54d94c3 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/server_factory.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/server_factory.go @@ -19,13 +19,15 @@ import ( // ServerFactory is a fake server for instances of the armguestconfiguration.ClientFactory type. type ServerFactory struct { - AssignmentReportsServer AssignmentReportsServer - AssignmentReportsVMSSServer AssignmentReportsVMSSServer - AssignmentsServer AssignmentsServer - AssignmentsVMSSServer AssignmentsVMSSServer - HCRPAssignmentReportsServer HCRPAssignmentReportsServer - HCRPAssignmentsServer HCRPAssignmentsServer - OperationsServer OperationsServer + AssignmentReportsServer AssignmentReportsServer + AssignmentReportsVMSSServer AssignmentReportsVMSSServer + AssignmentsServer AssignmentsServer + AssignmentsVMSSServer AssignmentsVMSSServer + ConnectedVMwarevSphereAssignmentsServer ConnectedVMwarevSphereAssignmentsServer + ConnectedVMwarevSphereAssignmentsReportsServer ConnectedVMwarevSphereAssignmentsReportsServer + HCRPAssignmentReportsServer HCRPAssignmentReportsServer + HCRPAssignmentsServer HCRPAssignmentsServer + OperationsServer OperationsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -40,15 +42,17 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armguestconfiguration.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trAssignmentReportsServer *AssignmentReportsServerTransport - trAssignmentReportsVMSSServer *AssignmentReportsVMSSServerTransport - trAssignmentsServer *AssignmentsServerTransport - trAssignmentsVMSSServer *AssignmentsVMSSServerTransport - trHCRPAssignmentReportsServer *HCRPAssignmentReportsServerTransport - trHCRPAssignmentsServer *HCRPAssignmentsServerTransport - trOperationsServer *OperationsServerTransport + srv *ServerFactory + trMu sync.Mutex + trAssignmentReportsServer *AssignmentReportsServerTransport + trAssignmentReportsVMSSServer *AssignmentReportsVMSSServerTransport + trAssignmentsServer *AssignmentsServerTransport + trAssignmentsVMSSServer *AssignmentsVMSSServerTransport + trConnectedVMwarevSphereAssignmentsServer *ConnectedVMwarevSphereAssignmentsServerTransport + trConnectedVMwarevSphereAssignmentsReportsServer *ConnectedVMwarevSphereAssignmentsReportsServerTransport + trHCRPAssignmentReportsServer *HCRPAssignmentReportsServerTransport + trHCRPAssignmentsServer *HCRPAssignmentsServerTransport + trOperationsServer *OperationsServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -82,6 +86,16 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewAssignmentsVMSSServerTransport(&s.srv.AssignmentsVMSSServer) }) resp, err = s.trAssignmentsVMSSServer.Do(req) + case "ConnectedVMwarevSphereAssignmentsClient": + initServer(s, &s.trConnectedVMwarevSphereAssignmentsServer, func() *ConnectedVMwarevSphereAssignmentsServerTransport { + return NewConnectedVMwarevSphereAssignmentsServerTransport(&s.srv.ConnectedVMwarevSphereAssignmentsServer) + }) + resp, err = s.trConnectedVMwarevSphereAssignmentsServer.Do(req) + case "ConnectedVMwarevSphereAssignmentsReportsClient": + initServer(s, &s.trConnectedVMwarevSphereAssignmentsReportsServer, func() *ConnectedVMwarevSphereAssignmentsReportsServerTransport { + return NewConnectedVMwarevSphereAssignmentsReportsServerTransport(&s.srv.ConnectedVMwarevSphereAssignmentsReportsServer) + }) + resp, err = s.trConnectedVMwarevSphereAssignmentsReportsServer.Do(req) case "HCRPAssignmentReportsClient": initServer(s, &s.trHCRPAssignmentReportsServer, func() *HCRPAssignmentReportsServerTransport { return NewHCRPAssignmentReportsServerTransport(&s.srv.HCRPAssignmentReportsServer) diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/time_rfc3339.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/time_rfc3339.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/fake/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod index 33a895c4ae3e..8f7c5e7f0c21 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/ go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect - github.com/golang-jwt/jwt/v5 v5.0.0 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum index 5228c81c4b02..520f1a7d9768 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum @@ -1,31 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 h1:sUFnFjzDUie80h24I7mrKtwCKgLY9L8h5Tp2x9+TWqk= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0/go.mod h1:52JbnQTp15qg5mRkMBHwp0j0ZFwHJ42Sx3zVV5RE9p0= -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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -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/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client_example_test.go deleted file mode 100644 index 047c0ecc8a40..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client_example_test.go +++ /dev/null @@ -1,179 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllGuestConfigurationHCRPAssignmentReports.json -func ExampleHCRPAssignmentReportsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHCRPAssignmentReportsClient().List(ctx, "myResourceGroupName", "AuditSecureProtocol", "myMachineName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AssignmentReportList = armguestconfiguration.AssignmentReportList{ - // Value: []*armguestconfiguration.AssignmentReport{ - // { - // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName"), - // UUID: to.Ptr("vmuuid"), - // }, - // }, - // }, - // { - // Name: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:14:13.000Z"); return t}()), - // ReportID: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName"), - // UUID: to.Ptr("vmuuid"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationHCRPAssignmentReportById.json -func ExampleHCRPAssignmentReportsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHCRPAssignmentReportsClient().Get(ctx, "myResourceGroupName", "AuditSecureProtocol", "7367cbb8-ae99-47d0-a33b-a283564d2cb1", "myMachineName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AssignmentReport = armguestconfiguration.AssignmentReport{ - // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // Properties: &armguestconfiguration.AssignmentReportProperties{ - // Assignment: &armguestconfiguration.AssignmentInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Configuration: &armguestconfiguration.ConfigurationInfo{ - // Name: to.Ptr("AuditSecureProtocol"), - // Version: to.Ptr("1.0.0.0"), - // }, - // }, - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // VM: &armguestconfiguration.VMInfo{ - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName"), - // UUID: to.Ptr("vmuuid"), - // }, - // Details: &armguestconfiguration.AssignmentReportDetails{ - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // JobID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // OperationType: to.Ptr(armguestconfiguration.TypeConsistency), - // Resources: []*armguestconfiguration.AssignmentReportResource{ - // { - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // Properties: map[string]any{ - // "ConfigurationName": "IsWebServerSecure", - // "DependsOn": nil, - // "IsSingleInstance": "Yes", - // "ModuleName": "SecureProtocolWebServer", - // "ModuleVersion": "1.0.0.3", - // "Protocols":[]any{ - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "SSL 2.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "SSL 3.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "PCT 1.0", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "Multi-Protocol Unified Hello", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.1", - // }, - // map[string]any{ - // "Ensure": "Absent", - // "Protocol": "TLS 1.2", - // }, - // }, - // "PsDscRunAsCredential": nil, - // "Reasons": nil, - // "ResourceId": "[SecureWebServer]s1", - // "SourceInfo": nil, - // }, - // Reasons: []*armguestconfiguration.AssignmentReportResourceComplianceReason{ - // { - // Code: to.Ptr("DSC::RESOURCE::SUCCESS"), - // Phrase: to.Ptr("Operation successful."), - // }}, - // }}, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53.000Z"); return t}()), - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client_example_test.go deleted file mode 100644 index 04788631b73b..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client_example_test.go +++ /dev/null @@ -1,162 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/createOrUpdateGuestConfigurationHCRPAssignment.json -func ExampleHCRPAssignmentsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHCRPAssignmentsClient().CreateOrUpdate(ctx, "NotInstalledApplicationForWindows", "myResourceGroupName", "myMachineName", armguestconfiguration.Assignment{ - Name: to.Ptr("NotInstalledApplicationForWindows"), - Location: to.Ptr("westcentralus"), - Properties: &armguestconfiguration.AssignmentProperties{ - Context: to.Ptr("Azure policy"), - GuestConfiguration: &armguestconfiguration.Navigation{ - Name: to.Ptr("NotInstalledApplicationForWindows"), - AssignmentType: to.Ptr(armguestconfiguration.AssignmentTypeApplyAndAutoCorrect), - ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - { - Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), - Value: to.Ptr("NotePad,sql"), - }}, - ContentHash: to.Ptr("123contenthash"), - ContentURI: to.Ptr("https://thisisfake/pacakge"), - Version: to.Ptr("1.*"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Assignment = armguestconfiguration.Assignment{ - // Name: to.Ptr("NotInstalledApplicationForWindows"), - // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/HybridRP.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/NotInstalledApplicationForWindows"), - // Location: to.Ptr("westcentralus"), - // Properties: &armguestconfiguration.AssignmentProperties{ - // AssignmentHash: to.Ptr("abcdr453g"), - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusPending), - // Context: to.Ptr("Azure policy"), - // GuestConfiguration: &armguestconfiguration.Navigation{ - // Name: to.Ptr("NotInstalledApplicationForWindows"), - // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - // { - // Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), - // Value: to.Ptr("NotePad,sql"), - // }}, - // Version: to.Ptr("1.0.0.3"), - // }, - // LatestReportID: to.Ptr("a2a64e5d-a1a9-4344-a866-fb9e1541f723"), - // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationHCRPAssignment.json -func ExampleHCRPAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHCRPAssignmentsClient().Get(ctx, "myResourceGroupName", "SecureProtocol", "myMachineName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Assignment = armguestconfiguration.Assignment{ - // Name: to.Ptr("AuditSecureProtocol"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol"), - // Location: to.Ptr("centraluseuap"), - // Properties: &armguestconfiguration.AssignmentProperties{ - // AssignmentHash: to.Ptr("E0D8941DD713F284284561648C00C18FA76C8602943C7CD38AFD73B56AE4C35F.E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"), - // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), - // GuestConfiguration: &armguestconfiguration.Navigation{ - // Name: to.Ptr("AuditSecureProtocol"), - // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - // }, - // ContentHash: to.Ptr("content hash"), - // ContentURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/builtinconfig/AuditSecureProtocol/AuditSecureProtocol_1.0.0.3.zip"), - // Version: to.Ptr("1.0.0.3"), - // }, - // LastComplianceStatusChecked: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13.000Z"); return t}()), - // LatestReportID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), - // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationHCRPAssignment.json -func ExampleHCRPAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewHCRPAssignmentsClient().Delete(ctx, "myResourceGroupName", "SecureProtocol", "myMachineName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listGuestConfigurationHCRPAssignments.json -func ExampleHCRPAssignmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewHCRPAssignmentsClient().NewListPager("myResourceGroupName", "myMachineName", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssignmentList = armguestconfiguration.AssignmentList{ - // } - } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models_serde.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models_serde.go index 71e27be40ba2..30f161eae2f8 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models_serde.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models_serde.go @@ -1066,7 +1066,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client_example_test.go deleted file mode 100644 index 4170a250fe02..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client_example_test.go +++ /dev/null @@ -1,82 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listOperations.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationList = armguestconfiguration.OperationList{ - // Value: []*armguestconfiguration.Operation{ - // { - // Name: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/write"), - // Display: &armguestconfiguration.OperationDisplay{ - // Description: to.Ptr("Create new guest configuration assignment."), - // Operation: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/write"), - // Provider: to.Ptr("Microsoft Guest Configuration"), - // Resource: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.GuestConfiguration/register/action"), - // Display: &armguestconfiguration.OperationDisplay{ - // Description: to.Ptr("Registers the subscription for the Microsoft.GuestConfiguration resource provider."), - // Operation: to.Ptr("Registers the feature for Microsoft.GuestConfiguration."), - // Provider: to.Ptr("Microsoft Guest Configuration"), - // Resource: to.Ptr("Register"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/read"), - // Display: &armguestconfiguration.OperationDisplay{ - // Description: to.Ptr("Get guest configuration assignment."), - // Operation: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/read"), - // Provider: to.Ptr("Microsoft Guest Configuration"), - // Resource: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/reports/read"), - // Display: &armguestconfiguration.OperationDisplay{ - // Description: to.Ptr("Get guest configuration assignment report."), - // Operation: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/reports/read"), - // Provider: to.Ptr("Microsoft Guest Configuration"), - // Resource: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/options.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/options.go index 3e3c25d9bfd7..e93d881d389b 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/options.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/options.go @@ -60,6 +60,12 @@ type AssignmentsClientSubscriptionListOptions struct { // placeholder for future optional parameters } +// AssignmentsVMSSClientCreateOrUpdateOptions contains the optional parameters for the AssignmentsVMSSClient.CreateOrUpdate +// method. +type AssignmentsVMSSClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + // AssignmentsVMSSClientDeleteOptions contains the optional parameters for the AssignmentsVMSSClient.Delete method. type AssignmentsVMSSClientDeleteOptions struct { // placeholder for future optional parameters @@ -75,6 +81,42 @@ type AssignmentsVMSSClientListOptions struct { // placeholder for future optional parameters } +// ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsClient.CreateOrUpdate +// method. +type ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ConnectedVMwarevSphereAssignmentsClientDeleteOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsClient.Delete +// method. +type ConnectedVMwarevSphereAssignmentsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ConnectedVMwarevSphereAssignmentsClientGetOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsClient.Get +// method. +type ConnectedVMwarevSphereAssignmentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ConnectedVMwarevSphereAssignmentsClientListOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsClient.NewListPager +// method. +type ConnectedVMwarevSphereAssignmentsClientListOptions struct { + // placeholder for future optional parameters +} + +// ConnectedVMwarevSphereAssignmentsReportsClientGetOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsReportsClient.Get +// method. +type ConnectedVMwarevSphereAssignmentsReportsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ConnectedVMwarevSphereAssignmentsReportsClientListOptions contains the optional parameters for the ConnectedVMwarevSphereAssignmentsReportsClient.List +// method. +type ConnectedVMwarevSphereAssignmentsReportsClientListOptions struct { + // placeholder for future optional parameters +} + // HCRPAssignmentReportsClientGetOptions contains the optional parameters for the HCRPAssignmentReportsClient.Get method. type HCRPAssignmentReportsClientGetOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/response_types.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/responses.go similarity index 71% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/response_types.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/responses.go index 83a8971f76fe..8f130fcf11d0 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/response_types.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/responses.go @@ -67,6 +67,12 @@ type AssignmentsClientSubscriptionListResponse struct { AssignmentList } +// AssignmentsVMSSClientCreateOrUpdateResponse contains the response from method AssignmentsVMSSClient.CreateOrUpdate. +type AssignmentsVMSSClientCreateOrUpdateResponse struct { + // Guest configuration assignment is an association between a machine and guest configuration. + Assignment +} + // AssignmentsVMSSClientDeleteResponse contains the response from method AssignmentsVMSSClient.Delete. type AssignmentsVMSSClientDeleteResponse struct { // Guest configuration assignment is an association between a machine and guest configuration. @@ -85,6 +91,41 @@ type AssignmentsVMSSClientListResponse struct { AssignmentList } +// ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse contains the response from method ConnectedVMwarevSphereAssignmentsClient.CreateOrUpdate. +type ConnectedVMwarevSphereAssignmentsClientCreateOrUpdateResponse struct { + // Guest configuration assignment is an association between a machine and guest configuration. + Assignment +} + +// ConnectedVMwarevSphereAssignmentsClientDeleteResponse contains the response from method ConnectedVMwarevSphereAssignmentsClient.Delete. +type ConnectedVMwarevSphereAssignmentsClientDeleteResponse struct { + // placeholder for future response values +} + +// ConnectedVMwarevSphereAssignmentsClientGetResponse contains the response from method ConnectedVMwarevSphereAssignmentsClient.Get. +type ConnectedVMwarevSphereAssignmentsClientGetResponse struct { + // Guest configuration assignment is an association between a machine and guest configuration. + Assignment +} + +// ConnectedVMwarevSphereAssignmentsClientListResponse contains the response from method ConnectedVMwarevSphereAssignmentsClient.NewListPager. +type ConnectedVMwarevSphereAssignmentsClientListResponse struct { + // The response of the list guest configuration assignment operation. + AssignmentList +} + +// ConnectedVMwarevSphereAssignmentsReportsClientGetResponse contains the response from method ConnectedVMwarevSphereAssignmentsReportsClient.Get. +type ConnectedVMwarevSphereAssignmentsReportsClientGetResponse struct { + // Report for the guest configuration assignment. Report contains information such as compliance status, reason, and more. + AssignmentReport +} + +// ConnectedVMwarevSphereAssignmentsReportsClientListResponse contains the response from method ConnectedVMwarevSphereAssignmentsReportsClient.List. +type ConnectedVMwarevSphereAssignmentsReportsClientListResponse struct { + // List of guest configuration assignment reports. + AssignmentReportList +} + // HCRPAssignmentReportsClientGetResponse contains the response from method HCRPAssignmentReportsClient.Get. type HCRPAssignmentReportsClientGetResponse struct { // Report for the guest configuration assignment. Report contains information such as compliance status, reason, and more. diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/time_rfc3339.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/time_rfc3339.go index 0969df8de065..562756655e4b 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/time_rfc3339.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339