From cb6202dd02b1c61106d87669ab3df2f1d9507616 Mon Sep 17 00:00:00 2001 From: "judy.liu" Date: Fri, 21 Nov 2025 10:59:39 +0800 Subject: [PATCH] add code --- .../attestation/armattestation/CHANGELOG.md | 34 ++ .../attestation/armattestation/README.md | 4 +- .../armattestation/attestation_live_test.go | 140 +++---- .../attestation/armattestation/autorest.md | 12 - .../attestation/armattestation/build.go | 7 - .../armattestation/client_factory.go | 42 +- .../attestation/armattestation/constants.go | 110 +++-- .../armattestation/fake/internal.go | 11 +- .../armattestation/fake/operations_server.go | 97 +++-- .../fake/privateendpointconnections_server.go | 97 +++-- .../fake/privatelinkresources_server.go | 121 ++++++ .../armattestation/fake/providers_server.go | 217 ++++++---- .../armattestation/fake/server_factory.go | 24 +- .../armattestation/fake/time_rfc3339.go | 86 ---- .../attestation/armattestation/go.mod | 16 +- .../attestation/armattestation/go.sum | 28 +- .../attestation/armattestation/models.go | 203 ++++++--- .../armattestation/models_serde.go | 343 +++++++++++---- .../armattestation/operations_client.go | 61 ++- .../operations_client_example_test.go | 70 +++- .../attestation/armattestation/options.go | 18 +- .../privateendpointconnections_client.go | 97 ++--- ...endpointconnections_client_example_test.go | 212 +++++----- .../privatelinkresources_client.go | 105 +++++ ...rivatelinkresources_client_example_test.go | 52 +++ .../armattestation/providers_client.go | 179 ++++---- .../providers_client_example_test.go | 395 ++++++++++-------- .../{response_types.go => responses.go} | 20 +- .../armattestation/testdata/_metadata.json | 4 + .../armattestation/time_rfc3339.go | 51 ++- .../armattestation/tsp-location.yaml | 4 + .../attestation/armattestation/version.go | 10 + 32 files changed, 1797 insertions(+), 1073 deletions(-) delete mode 100644 sdk/resourcemanager/attestation/armattestation/autorest.md delete mode 100644 sdk/resourcemanager/attestation/armattestation/build.go create mode 100644 sdk/resourcemanager/attestation/armattestation/fake/privatelinkresources_server.go delete mode 100644 sdk/resourcemanager/attestation/armattestation/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/attestation/armattestation/privatelinkresources_client.go create mode 100644 sdk/resourcemanager/attestation/armattestation/privatelinkresources_client_example_test.go rename sdk/resourcemanager/attestation/armattestation/{response_types.go => responses.go} (84%) create mode 100644 sdk/resourcemanager/attestation/armattestation/testdata/_metadata.json create mode 100644 sdk/resourcemanager/attestation/armattestation/tsp-location.yaml create mode 100644 sdk/resourcemanager/attestation/armattestation/version.go diff --git a/sdk/resourcemanager/attestation/armattestation/CHANGELOG.md b/sdk/resourcemanager/attestation/armattestation/CHANGELOG.md index b9af10cca9e2..efb4d0827895 100644 --- a/sdk/resourcemanager/attestation/armattestation/CHANGELOG.md +++ b/sdk/resourcemanager/attestation/armattestation/CHANGELOG.md @@ -1,5 +1,39 @@ # Release History +## 2.0.0 (2025-11-21) +### Breaking Changes + +- Type of `StatusResult.Status` has been changed from `*AttestationServiceStatus` to `*ServiceStatus` +- Enum `AttestationServiceStatus` has been removed +- Operation `*OperationsClient.List` has supported pagination, use `*OperationsClient.NewListPager` instead. +- Operation `*ProvidersClient.List` has supported pagination, use `*ProvidersClient.NewListPager` instead. +- Operation `*ProvidersClient.ListByResourceGroup` has supported pagination, use `*ProvidersClient.NewListByResourceGroupPager` instead. +- Struct `Resource` has been removed +- Struct `TrackedResource` has been removed + +### Features Added + +- New enum type `PublicNetworkAccessType` with values `PublicNetworkAccessTypeDisabled`, `PublicNetworkAccessTypeEnabled` +- New enum type `ServiceStatus` with values `ServiceStatusError`, `ServiceStatusNotReady`, `ServiceStatusReady` +- New enum type `TpmAttestationAuthenticationType` with values `TpmAttestationAuthenticationTypeDisabled`, `TpmAttestationAuthenticationTypeEnabled` +- New function `*ClientFactory.NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient` +- New function `NewPrivateLinkResourcesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*PrivateLinkResourcesClient, error)` +- New function `*PrivateLinkResourcesClient.ListByProvider(context.Context, string, string, *PrivateLinkResourcesClientListByProviderOptions) (PrivateLinkResourcesClientListByProviderResponse, error)` +- New struct `LogSpecification` +- New struct `OperationProperties` +- New struct `PrivateLinkResource` +- New struct `PrivateLinkResourceListResult` +- New struct `PrivateLinkResourceProperties` +- New struct `ServicePatchSpecificParams` +- New struct `ServiceSpecification` +- New field `Properties` in struct `OperationsDefinition` +- New field `SystemData` in struct `PrivateEndpointConnection` +- New field `NextLink` in struct `PrivateEndpointConnectionListResult` +- New field `PublicNetworkAccess`, `TpmAttestationAuthentication` in struct `ServiceCreationSpecificParams` +- New field `Properties` in struct `ServicePatchParams` +- New field `PublicNetworkAccess`, `TpmAttestationAuthentication` in struct `StatusResult` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/attestation/armattestation/README.md b/sdk/resourcemanager/attestation/armattestation/README.md index 9495afc0309a..30930119c0b7 100644 --- a/sdk/resourcemanager/attestation/armattestation/README.md +++ b/sdk/resourcemanager/attestation/armattestation/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Attestation module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2 ``` ## Authorization @@ -55,7 +55,7 @@ clientFactory, err := armattestation.NewClientFactory(, cred, & 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.NewProvidersClient() +client := clientFactory.NewPrivateEndpointConnectionsClient() ``` ## Fakes diff --git a/sdk/resourcemanager/attestation/armattestation/attestation_live_test.go b/sdk/resourcemanager/attestation/armattestation/attestation_live_test.go index f3f8dacf44ea..d4e99ceede88 100644 --- a/sdk/resourcemanager/attestation/armattestation/attestation_live_test.go +++ b/sdk/resourcemanager/attestation/armattestation/attestation_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" @@ -24,15 +24,15 @@ import ( type AttestationTestSuite struct { suite.Suite - ctx context.Context - cred azcore.TokenCredential - options *arm.ClientOptions - armEndpoint string - attestationId string - providerName string - location string - resourceGroupName string - subscriptionId string + ctx context.Context + cred azcore.TokenCredential + options *arm.ClientOptions + armEndpoint string + attestationId string + providerName string + location string + resourceGroupName string + subscriptionId string } func (testsuite *AttestationTestSuite) SetupSuite() { @@ -109,9 +109,9 @@ func (testsuite *AttestationTestSuite) TestAttestationProviders() { fmt.Println("Call operation: AttestationProviders_Update") _, err = providersClient.Update(testsuite.ctx, testsuite.resourceGroupName, testsuite.providerName, armattestation.ServicePatchParams{ Tags: map[string]*string{ - "Property1": to.Ptr("Value1"), - "Property2": to.Ptr("Value2"), - "Property3": to.Ptr("Value3"), + "Property1": to.Ptr("Value1"), + "Property2": to.Ptr("Value2"), + "Property3": to.Ptr("Value3"), }, }, nil) testsuite.Require().NoError(err) @@ -124,78 +124,78 @@ func (testsuite *AttestationTestSuite) TestPrivateEndpointConnections() { var err error // From step Create_PrivateEndpoint template := map[string]any{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "parameters": map[string]any{ "attestationId": map[string]any{ - "type": "string", - "defaultValue": testsuite.attestationId, + "type": "string", + "defaultValue": testsuite.attestationId, }, "location": map[string]any{ - "type": "string", - "defaultValue": testsuite.location, + "type": "string", + "defaultValue": testsuite.location, }, "networkInterfaceName": map[string]any{ - "type": "string", - "defaultValue": "epattestation-nic", + "type": "string", + "defaultValue": "epattestation-nic", }, "privateEndpointName": map[string]any{ - "type": "string", - "defaultValue": "epattestation", + "type": "string", + "defaultValue": "epattestation", }, "virtualNetworksName": map[string]any{ - "type": "string", - "defaultValue": "epattestationvnet", + "type": "string", + "defaultValue": "epattestationvnet", }, }, "resources": []any{ map[string]any{ - "name": "[parameters('virtualNetworksName')]", - "type": "Microsoft.Network/virtualNetworks", - "apiVersion": "2020-11-01", - "location": "[parameters('location')]", + "name": "[parameters('virtualNetworksName')]", + "type": "Microsoft.Network/virtualNetworks", + "apiVersion": "2020-11-01", + "location": "[parameters('location')]", "properties": map[string]any{ "addressSpace": map[string]any{ "addressPrefixes": []any{ "10.0.0.0/16", }, }, - "enableDdosProtection": false, + "enableDdosProtection": false, "subnets": []any{ map[string]any{ - "name": "default", + "name": "default", "properties": map[string]any{ - "addressPrefix": "10.0.0.0/24", - "delegations": []any{}, - "privateEndpointNetworkPolicies": "Disabled", - "privateLinkServiceNetworkPolicies": "Enabled", + "addressPrefix": "10.0.0.0/24", + "delegations": []any{}, + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled", }, }, }, - "virtualNetworkPeerings": []any{}, + "virtualNetworkPeerings": []any{}, }, }, map[string]any{ - "name": "[parameters('networkInterfaceName')]", - "type": "Microsoft.Network/networkInterfaces", - "apiVersion": "2020-11-01", + "name": "[parameters('networkInterfaceName')]", + "type": "Microsoft.Network/networkInterfaces", + "apiVersion": "2020-11-01", "dependsOn": []any{ "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", }, - "location": "[parameters('location')]", + "location": "[parameters('location')]", "properties": map[string]any{ "dnsSettings": map[string]any{ "dnsServers": []any{}, }, - "enableIPForwarding": false, + "enableIPForwarding": false, "ipConfigurations": []any{ map[string]any{ - "name": "privateEndpointIpConfig", + "name": "privateEndpointIpConfig", "properties": map[string]any{ - "primary": true, - "privateIPAddress": "10.0.0.4", - "privateIPAddressVersion": "IPv4", - "privateIPAllocationMethod": "Dynamic", + "primary": true, + "privateIPAddress": "10.0.0.4", + "privateIPAddressVersion": "IPv4", + "privateIPAllocationMethod": "Dynamic", "subnet": map[string]any{ "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", }, @@ -205,29 +205,29 @@ func (testsuite *AttestationTestSuite) TestPrivateEndpointConnections() { }, }, map[string]any{ - "name": "[parameters('privateEndpointName')]", - "type": "Microsoft.Network/privateEndpoints", - "apiVersion": "2020-11-01", + "name": "[parameters('privateEndpointName')]", + "type": "Microsoft.Network/privateEndpoints", + "apiVersion": "2020-11-01", "dependsOn": []any{ "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", }, - "location": "[parameters('location')]", + "location": "[parameters('location')]", "properties": map[string]any{ - "customDnsConfigs": []any{}, - "manualPrivateLinkServiceConnections": []any{}, + "customDnsConfigs": []any{}, + "manualPrivateLinkServiceConnections": []any{}, "privateLinkServiceConnections": []any{ map[string]any{ - "name": "[parameters('privateEndpointName')]", + "name": "[parameters('privateEndpointName')]", "properties": map[string]any{ "groupIds": []any{ "standard", }, "privateLinkServiceConnectionState": map[string]any{ - "description": "Auto-Approved", - "actionsRequired": "None", - "status": "Approved", + "description": "Auto-Approved", + "actionsRequired": "None", + "status": "Approved", }, - "privateLinkServiceId": "[parameters('attestationId')]", + "privateLinkServiceId": "[parameters('attestationId')]", }, }, }, @@ -237,26 +237,26 @@ func (testsuite *AttestationTestSuite) TestPrivateEndpointConnections() { }, }, map[string]any{ - "name": "[concat(parameters('virtualNetworksName'), '/default')]", - "type": "Microsoft.Network/virtualNetworks/subnets", - "apiVersion": "2020-11-01", + "name": "[concat(parameters('virtualNetworksName'), '/default')]", + "type": "Microsoft.Network/virtualNetworks/subnets", + "apiVersion": "2020-11-01", "dependsOn": []any{ "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworksName'))]", }, "properties": map[string]any{ - "addressPrefix": "10.0.0.0/24", - "delegations": []any{}, - "privateEndpointNetworkPolicies": "Disabled", - "privateLinkServiceNetworkPolicies": "Enabled", + "addressPrefix": "10.0.0.0/24", + "delegations": []any{}, + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled", }, }, }, - "variables": map[string]any{}, + "variables": map[string]any{}, } deployment := armresources.Deployment{ Properties: &armresources.DeploymentProperties{ - Template: template, - Mode: to.Ptr(armresources.DeploymentModeIncremental), + Template: template, + Mode: to.Ptr(armresources.DeploymentModeIncremental), }, } _, err = testutil.CreateDeployment(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName, "Create_PrivateEndpoint", &deployment) @@ -280,11 +280,11 @@ func (testsuite *AttestationTestSuite) TestPrivateEndpointConnections() { // From step PrivateEndpointConnections_Create fmt.Println("Call operation: PrivateEndpointConnections_Create") _, err = privateEndpointConnectionsClient.Create(testsuite.ctx, testsuite.resourceGroupName, testsuite.providerName, privateEndpointConnectionName, armattestation.PrivateEndpointConnection{ - ID: to.Ptr(privateEndpointConnectionId), + ID: to.Ptr(privateEndpointConnectionId), Properties: &armattestation.PrivateEndpointConnectionProperties{ PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ - Description: to.Ptr("rejection connection"), - Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusRejected), + Description: to.Ptr("rejection connection"), + Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusRejected), }, }, }, nil) diff --git a/sdk/resourcemanager/attestation/armattestation/autorest.md b/sdk/resourcemanager/attestation/armattestation/autorest.md deleted file mode 100644 index 5d17c1cd0dc2..000000000000 --- a/sdk/resourcemanager/attestation/armattestation/autorest.md +++ /dev/null @@ -1,12 +0,0 @@ -### AutoRest Configuration - -> see https://aka.ms/autorest - -``` yaml -azure-arm: true -require: -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/readme.go.md -license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 -``` \ No newline at end of file diff --git a/sdk/resourcemanager/attestation/armattestation/build.go b/sdk/resourcemanager/attestation/armattestation/build.go deleted file mode 100644 index 50cd49603732..000000000000 --- a/sdk/resourcemanager/attestation/armattestation/build.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/attestation/armattestation - -package armattestation diff --git a/sdk/resourcemanager/attestation/armattestation/client_factory.go b/sdk/resourcemanager/attestation/armattestation/client_factory.go index d1275317c433..47c63304bede 100644 --- a/sdk/resourcemanager/attestation/armattestation/client_factory.go +++ b/sdk/resourcemanager/attestation/armattestation/client_factory.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation @@ -17,40 +13,52 @@ 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. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - 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 } // 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, + } } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { - subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateEndpointConnectionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. +func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { + return &PrivateLinkResourcesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProvidersClient creates a new instance of ProvidersClient. func (c *ClientFactory) NewProvidersClient() *ProvidersClient { - subClient, _ := NewProvidersClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProvidersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/attestation/armattestation/constants.go b/sdk/resourcemanager/attestation/armattestation/constants.go index a6e0fade1d09..557fadd9633e 100644 --- a/sdk/resourcemanager/attestation/armattestation/constants.go +++ b/sdk/resourcemanager/attestation/armattestation/constants.go @@ -1,44 +1,21 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation -const ( - moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation" - moduleVersion = "v1.2.0" -) - -// AttestationServiceStatus - Status of attestation service. -type AttestationServiceStatus string - -const ( - AttestationServiceStatusError AttestationServiceStatus = "Error" - AttestationServiceStatusNotReady AttestationServiceStatus = "NotReady" - AttestationServiceStatusReady AttestationServiceStatus = "Ready" -) - -// PossibleAttestationServiceStatusValues returns the possible values for the AttestationServiceStatus const type. -func PossibleAttestationServiceStatusValues() []AttestationServiceStatus { - return []AttestationServiceStatus{ - AttestationServiceStatusError, - AttestationServiceStatusNotReady, - AttestationServiceStatusReady, - } -} - -// CreatedByType - The type of identity that created the resource. +// CreatedByType - The kind of entity that created the resource. type CreatedByType string const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" ) // PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. @@ -55,9 +32,13 @@ func PossibleCreatedByTypeValues() []CreatedByType { type PrivateEndpointConnectionProvisioningState string const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + // PrivateEndpointConnectionProvisioningStateCreating - Connection is being created + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + // PrivateEndpointConnectionProvisioningStateDeleting - Connection is being deleted + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + // PrivateEndpointConnectionProvisioningStateFailed - Connection provisioning has failed + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + // PrivateEndpointConnectionProvisioningStateSucceeded - Connection has been provisioned PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" ) @@ -75,8 +56,11 @@ func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpoin type PrivateEndpointServiceConnectionStatus string const ( + // PrivateEndpointServiceConnectionStatusApproved - Connection approved PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + // PrivateEndpointServiceConnectionStatusPending - Connection waiting for approval or rejection + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + // PrivateEndpointServiceConnectionStatusRejected - Connection Rejected PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" ) @@ -88,3 +72,57 @@ func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointSer PrivateEndpointServiceConnectionStatusRejected, } } + +// PublicNetworkAccessType - The public network access type for API calls to the Attestation Provider. +type PublicNetworkAccessType string + +const ( + // PublicNetworkAccessTypeDisabled - Disables public network connectivity to the Attestation Provider REST APIs. + PublicNetworkAccessTypeDisabled PublicNetworkAccessType = "Disabled" + // PublicNetworkAccessTypeEnabled - Enables public network connectivity to the Attestation Provider REST APIs. + PublicNetworkAccessTypeEnabled PublicNetworkAccessType = "Enabled" +) + +// PossiblePublicNetworkAccessTypeValues returns the possible values for the PublicNetworkAccessType const type. +func PossiblePublicNetworkAccessTypeValues() []PublicNetworkAccessType { + return []PublicNetworkAccessType{ + PublicNetworkAccessTypeDisabled, + PublicNetworkAccessTypeEnabled, + } +} + +// ServiceStatus - Status of attestation service. +type ServiceStatus string + +const ( + ServiceStatusError ServiceStatus = "Error" + ServiceStatusNotReady ServiceStatus = "NotReady" + ServiceStatusReady ServiceStatus = "Ready" +) + +// PossibleServiceStatusValues returns the possible values for the ServiceStatus const type. +func PossibleServiceStatusValues() []ServiceStatus { + return []ServiceStatus{ + ServiceStatusError, + ServiceStatusNotReady, + ServiceStatusReady, + } +} + +// TpmAttestationAuthenticationType - The type for specifying the requirement of authentication for TPM Attestation REST APIs. +type TpmAttestationAuthenticationType string + +const ( + // TpmAttestationAuthenticationTypeDisabled - Disables the requirement of authentication for TPM Attestation REST APIs. + TpmAttestationAuthenticationTypeDisabled TpmAttestationAuthenticationType = "Disabled" + // TpmAttestationAuthenticationTypeEnabled - Enables the requirement of authentication for TPM Attestation REST APIs. + TpmAttestationAuthenticationTypeEnabled TpmAttestationAuthenticationType = "Enabled" +) + +// PossibleTpmAttestationAuthenticationTypeValues returns the possible values for the TpmAttestationAuthenticationType const type. +func PossibleTpmAttestationAuthenticationTypeValues() []TpmAttestationAuthenticationType { + return []TpmAttestationAuthenticationType{ + TpmAttestationAuthenticationTypeDisabled, + TpmAttestationAuthenticationTypeEnabled, + } +} diff --git a/sdk/resourcemanager/attestation/armattestation/fake/internal.go b/sdk/resourcemanager/attestation/armattestation/fake/internal.go index 5f75802a569e..7425b6a669e2 100644 --- a/sdk/resourcemanager/attestation/armattestation/fake/internal.go +++ b/sdk/resourcemanager/attestation/armattestation/fake/internal.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -14,6 +10,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/attestation/armattestation/fake/operations_server.go b/sdk/resourcemanager/attestation/armattestation/fake/operations_server.go index d80f9480eeca..c8d6d378591e 100644 --- a/sdk/resourcemanager/attestation/armattestation/fake/operations_server.go +++ b/sdk/resourcemanager/attestation/armattestation/fake/operations_server.go @@ -1,42 +1,41 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. 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/attestation/armattestation" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2" "net/http" ) // OperationsServer is a fake server for instances of the armattestation.OperationsClient type. type OperationsServer struct { - // List is the fake for method OperationsClient.List + // NewListPager is the fake for method OperationsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, options *armattestation.OperationsClientListOptions) (resp azfake.Responder[armattestation.OperationsClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(options *armattestation.OperationsClientListOptions) (resp azfake.PagerResponder[armattestation.OperationsClientListResponse]) } // NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. // The returned OperationsServerTransport instance is connected to an instance of armattestation.OperationsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { - return &OperationsServerTransport{srv: srv} + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armattestation.OperationsClientListResponse]](), + } } // OperationsServerTransport connects instances of armattestation.OperationsClient to instances of OperationsServer. // Don't use this type directly, use NewOperationsServerTransport instead. type OperationsServerTransport struct { - srv *OperationsServer + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armattestation.OperationsClientListResponse]] } // Do implements the policy.Transporter interface for OperationsServerTransport. @@ -47,38 +46,68 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.List": - resp, err = o.dispatchList(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil -} + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() -func (o *OperationsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if o.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err } - respr, errRespr := o.srv.List(req.Context(), nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } - 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)} + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationList, req) + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/attestation/armattestation/fake/privateendpointconnections_server.go b/sdk/resourcemanager/attestation/armattestation/fake/privateendpointconnections_server.go index 0f0711ebdea6..cf9cab764742 100644 --- a/sdk/resourcemanager/attestation/armattestation/fake/privateendpointconnections_server.go +++ b/sdk/resourcemanager/attestation/armattestation/fake/privateendpointconnections_server.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,7 +11,8 @@ import ( 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/attestation/armattestation" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2" "net/http" "net/url" "regexp" @@ -25,19 +22,19 @@ import ( type PrivateEndpointConnectionsServer struct { // Create is the fake for method PrivateEndpointConnectionsClient.Create // HTTP status codes to indicate success: http.StatusOK - Create func(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, properties armattestation.PrivateEndpointConnection, options *armattestation.PrivateEndpointConnectionsClientCreateOptions) (resp azfake.Responder[armattestation.PrivateEndpointConnectionsClientCreateResponse], errResp azfake.ErrorResponder) + Create func(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, properties armattestation.PrivateEndpointConnection, options *armattestation.PrivateEndpointConnectionsClientCreateOptions) (resp azfake.Responder[armattestation.PrivateEndpointConnectionsClientCreateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method PrivateEndpointConnectionsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, options *armattestation.PrivateEndpointConnectionsClientDeleteOptions) (resp azfake.Responder[armattestation.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, options *armattestation.PrivateEndpointConnectionsClientDeleteOptions) (resp azfake.Responder[armattestation.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method PrivateEndpointConnectionsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, options *armattestation.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armattestation.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, options *armattestation.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armattestation.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) // NewListPager is the fake for method PrivateEndpointConnectionsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(resourceGroupName string, providerName string, options *armattestation.PrivateEndpointConnectionsClientListOptions) (resp azfake.PagerResponder[armattestation.PrivateEndpointConnectionsClientListResponse]) + NewListPager func(resourceGroupName string, providerName string, options *armattestation.PrivateEndpointConnectionsClientListOptions) (resp azfake.PagerResponder[armattestation.PrivateEndpointConnectionsClientListResponse]) } // NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. @@ -45,16 +42,16 @@ type PrivateEndpointConnectionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { return &PrivateEndpointConnectionsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armattestation.PrivateEndpointConnectionsClientListResponse]](), + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armattestation.PrivateEndpointConnectionsClientListResponse]](), } } // PrivateEndpointConnectionsServerTransport connects instances of armattestation.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. // Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. type PrivateEndpointConnectionsServerTransport struct { - srv *PrivateEndpointConnectionsServer - newListPager *tracker[azfake.PagerResponder[armattestation.PrivateEndpointConnectionsClientListResponse]] + srv *PrivateEndpointConnectionsServer + newListPager *tracker[azfake.PagerResponder[armattestation.PrivateEndpointConnectionsClientListResponse]] } // Do implements the policy.Transporter interface for PrivateEndpointConnectionsServerTransport. @@ -65,27 +62,46 @@ func (p *PrivateEndpointConnectionsServerTransport) Do(req *http.Request) (*http return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PrivateEndpointConnectionsClient.Create": - resp, err = p.dispatchCreate(req) - case "PrivateEndpointConnectionsClient.Delete": - resp, err = p.dispatchDelete(req) - case "PrivateEndpointConnectionsClient.Get": - resp, err = p.dispatchGet(req) - case "PrivateEndpointConnectionsClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PrivateEndpointConnectionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if privateEndpointConnectionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = privateEndpointConnectionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrivateEndpointConnectionsClient.Create": + res.resp, res.err = p.dispatchCreate(req) + case "PrivateEndpointConnectionsClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "PrivateEndpointConnectionsClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.NewListPager": + res.resp, res.err = p.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PrivateEndpointConnectionsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { @@ -95,7 +111,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchCreate(req *http.Req const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armattestation.PrivateEndpointConnection](req) @@ -136,7 +152,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchDelete(req *http.Req const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -173,7 +189,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Reques const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -212,7 +228,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -226,6 +242,9 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *ht resp := p.srv.NewListPager(resourceGroupNameParam, providerNameParam, nil) newListPager = &resp p.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armattestation.PrivateEndpointConnectionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -240,3 +259,9 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *ht } return resp, nil } + +// set this to conditionally intercept incoming requests to PrivateEndpointConnectionsServerTransport +var privateEndpointConnectionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/attestation/armattestation/fake/privatelinkresources_server.go b/sdk/resourcemanager/attestation/armattestation/fake/privatelinkresources_server.go new file mode 100644 index 000000000000..1ee6646ae956 --- /dev/null +++ b/sdk/resourcemanager/attestation/armattestation/fake/privatelinkresources_server.go @@ -0,0 +1,121 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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/attestation/armattestation/v2" + "net/http" + "net/url" + "regexp" +) + +// PrivateLinkResourcesServer is a fake server for instances of the armattestation.PrivateLinkResourcesClient type. +type PrivateLinkResourcesServer struct { + // ListByProvider is the fake for method PrivateLinkResourcesClient.ListByProvider + // HTTP status codes to indicate success: http.StatusOK + ListByProvider func(ctx context.Context, resourceGroupName string, providerName string, options *armattestation.PrivateLinkResourcesClientListByProviderOptions) (resp azfake.Responder[armattestation.PrivateLinkResourcesClientListByProviderResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. +// The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armattestation.PrivateLinkResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { + return &PrivateLinkResourcesServerTransport{srv: srv} +} + +// PrivateLinkResourcesServerTransport connects instances of armattestation.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. +// Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. +type PrivateLinkResourcesServerTransport struct { + srv *PrivateLinkResourcesServer +} + +// Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. +func (p *PrivateLinkResourcesServerTransport) 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")} + } + + return p.dispatchToMethodFake(req, method) +} + +func (p *PrivateLinkResourcesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if privateLinkResourcesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = privateLinkResourcesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrivateLinkResourcesClient.ListByProvider": + res.resp, res.err = p.dispatchListByProvider(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (p *PrivateLinkResourcesServerTransport) dispatchListByProvider(req *http.Request) (*http.Response, error) { + if p.srv.ListByProvider == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByProvider not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if 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 + } + providerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("providerName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.ListByProvider(req.Context(), resourceGroupNameParam, providerNameParam, 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).PrivateLinkResourceListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to PrivateLinkResourcesServerTransport +var privateLinkResourcesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/attestation/armattestation/fake/providers_server.go b/sdk/resourcemanager/attestation/armattestation/fake/providers_server.go index 2bff85a00c2e..3515033a1b89 100644 --- a/sdk/resourcemanager/attestation/armattestation/fake/providers_server.go +++ b/sdk/resourcemanager/attestation/armattestation/fake/providers_server.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,7 +11,7 @@ import ( 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/attestation/armattestation" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2" "net/http" "net/url" "regexp" @@ -25,48 +21,54 @@ import ( type ProvidersServer struct { // Create is the fake for method ProvidersClient.Create // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - Create func(ctx context.Context, resourceGroupName string, providerName string, creationParams armattestation.ServiceCreationParams, options *armattestation.ProvidersClientCreateOptions) (resp azfake.Responder[armattestation.ProvidersClientCreateResponse], errResp azfake.ErrorResponder) + Create func(ctx context.Context, resourceGroupName string, providerName string, creationParams armattestation.ServiceCreationParams, options *armattestation.ProvidersClientCreateOptions) (resp azfake.Responder[armattestation.ProvidersClientCreateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ProvidersClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, providerName string, options *armattestation.ProvidersClientDeleteOptions) (resp azfake.Responder[armattestation.ProvidersClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, providerName string, options *armattestation.ProvidersClientDeleteOptions) (resp azfake.Responder[armattestation.ProvidersClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method ProvidersClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, providerName string, options *armattestation.ProvidersClientGetOptions) (resp azfake.Responder[armattestation.ProvidersClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, providerName string, options *armattestation.ProvidersClientGetOptions) (resp azfake.Responder[armattestation.ProvidersClientGetResponse], errResp azfake.ErrorResponder) // GetDefaultByLocation is the fake for method ProvidersClient.GetDefaultByLocation // HTTP status codes to indicate success: http.StatusOK - GetDefaultByLocation func(ctx context.Context, location string, options *armattestation.ProvidersClientGetDefaultByLocationOptions) (resp azfake.Responder[armattestation.ProvidersClientGetDefaultByLocationResponse], errResp azfake.ErrorResponder) + GetDefaultByLocation func(ctx context.Context, location string, options *armattestation.ProvidersClientGetDefaultByLocationOptions) (resp azfake.Responder[armattestation.ProvidersClientGetDefaultByLocationResponse], errResp azfake.ErrorResponder) - // List is the fake for method ProvidersClient.List + // NewListPager is the fake for method ProvidersClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, options *armattestation.ProvidersClientListOptions) (resp azfake.Responder[armattestation.ProvidersClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(options *armattestation.ProvidersClientListOptions) (resp azfake.PagerResponder[armattestation.ProvidersClientListResponse]) - // ListByResourceGroup is the fake for method ProvidersClient.ListByResourceGroup + // NewListByResourceGroupPager is the fake for method ProvidersClient.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK - ListByResourceGroup func(ctx context.Context, resourceGroupName string, options *armattestation.ProvidersClientListByResourceGroupOptions) (resp azfake.Responder[armattestation.ProvidersClientListByResourceGroupResponse], errResp azfake.ErrorResponder) + NewListByResourceGroupPager func(resourceGroupName string, options *armattestation.ProvidersClientListByResourceGroupOptions) (resp azfake.PagerResponder[armattestation.ProvidersClientListByResourceGroupResponse]) // ListDefault is the fake for method ProvidersClient.ListDefault // HTTP status codes to indicate success: http.StatusOK - ListDefault func(ctx context.Context, options *armattestation.ProvidersClientListDefaultOptions) (resp azfake.Responder[armattestation.ProvidersClientListDefaultResponse], errResp azfake.ErrorResponder) + ListDefault func(ctx context.Context, options *armattestation.ProvidersClientListDefaultOptions) (resp azfake.Responder[armattestation.ProvidersClientListDefaultResponse], errResp azfake.ErrorResponder) // Update is the fake for method ProvidersClient.Update // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, resourceGroupName string, providerName string, updateParams armattestation.ServicePatchParams, options *armattestation.ProvidersClientUpdateOptions) (resp azfake.Responder[armattestation.ProvidersClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, resourceGroupName string, providerName string, updateParams armattestation.ServicePatchParams, options *armattestation.ProvidersClientUpdateOptions) (resp azfake.Responder[armattestation.ProvidersClientUpdateResponse], errResp azfake.ErrorResponder) } // NewProvidersServerTransport creates a new instance of ProvidersServerTransport with the provided implementation. // The returned ProvidersServerTransport instance is connected to an instance of armattestation.ProvidersClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewProvidersServerTransport(srv *ProvidersServer) *ProvidersServerTransport { - return &ProvidersServerTransport{srv: srv} + return &ProvidersServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armattestation.ProvidersClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armattestation.ProvidersClientListByResourceGroupResponse]](), + } } // ProvidersServerTransport connects instances of armattestation.ProvidersClient to instances of ProvidersServer. // Don't use this type directly, use NewProvidersServerTransport instead. type ProvidersServerTransport struct { - srv *ProvidersServer + srv *ProvidersServer + newListPager *tracker[azfake.PagerResponder[armattestation.ProvidersClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armattestation.ProvidersClientListByResourceGroupResponse]] } // Do implements the policy.Transporter interface for ProvidersServerTransport. @@ -77,35 +79,54 @@ func (p *ProvidersServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProvidersClient.Create": - resp, err = p.dispatchCreate(req) - case "ProvidersClient.Delete": - resp, err = p.dispatchDelete(req) - case "ProvidersClient.Get": - resp, err = p.dispatchGet(req) - case "ProvidersClient.GetDefaultByLocation": - resp, err = p.dispatchGetDefaultByLocation(req) - case "ProvidersClient.List": - resp, err = p.dispatchList(req) - case "ProvidersClient.ListByResourceGroup": - resp, err = p.dispatchListByResourceGroup(req) - case "ProvidersClient.ListDefault": - resp, err = p.dispatchListDefault(req) - case "ProvidersClient.Update": - resp, err = p.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProvidersServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if providersServerTransportInterceptor != nil { + res.resp, res.err, intercepted = providersServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProvidersClient.Create": + res.resp, res.err = p.dispatchCreate(req) + case "ProvidersClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "ProvidersClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "ProvidersClient.GetDefaultByLocation": + res.resp, res.err = p.dispatchGetDefaultByLocation(req) + case "ProvidersClient.NewListPager": + res.resp, res.err = p.dispatchNewListPager(req) + case "ProvidersClient.NewListByResourceGroupPager": + res.resp, res.err = p.dispatchNewListByResourceGroupPager(req) + case "ProvidersClient.ListDefault": + res.resp, res.err = p.dispatchListDefault(req) + case "ProvidersClient.Update": + res.resp, res.err = p.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProvidersServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { @@ -115,7 +136,7 @@ func (p *ProvidersServerTransport) dispatchCreate(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armattestation.ServiceCreationParams](req) @@ -152,7 +173,7 @@ func (p *ProvidersServerTransport) dispatchDelete(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -185,7 +206,7 @@ func (p *ProvidersServerTransport) dispatchGet(req *http.Request) (*http.Respons const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -218,7 +239,7 @@ func (p *ProvidersServerTransport) dispatchGetDefaultByLocation(req *http.Reques const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/defaultProvider` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) @@ -240,56 +261,66 @@ func (p *ProvidersServerTransport) dispatchGetDefaultByLocation(req *http.Reques return resp, nil } -func (p *ProvidersServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if p.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - respr, errRespr := p.srv.List(req.Context(), 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).ProviderListResult, req) +func (p *ProvidersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := p.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := p.srv.NewListPager(nil) + newListPager = &resp + p.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + p.newListPager.remove(req) + } return resp, nil } -func (p *ProvidersServerTransport) dispatchListByResourceGroup(req *http.Request) (*http.Response, error) { - if p.srv.ListByResourceGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method ListByResourceGroup not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) +func (p *ProvidersServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := p.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if 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 + } + resp := p.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + p.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) if err != nil { return nil, err } - respr, errRespr := p.srv.ListByResourceGroup(req.Context(), resourceGroupNameParam, 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)} + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProviderListResult, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListByResourceGroupPager) { + p.newListByResourceGroupPager.remove(req) } return resp, nil } @@ -301,7 +332,7 @@ func (p *ProvidersServerTransport) dispatchListDefault(req *http.Request) (*http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/defaultProviders` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } respr, errRespr := p.srv.ListDefault(req.Context(), nil) @@ -326,7 +357,7 @@ func (p *ProvidersServerTransport) dispatchUpdate(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Attestation/attestationProviders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armattestation.ServicePatchParams](req) @@ -355,3 +386,9 @@ func (p *ProvidersServerTransport) dispatchUpdate(req *http.Request) (*http.Resp } return resp, nil } + +// set this to conditionally intercept incoming requests to ProvidersServerTransport +var providersServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/attestation/armattestation/fake/server_factory.go b/sdk/resourcemanager/attestation/armattestation/fake/server_factory.go index 7213ae9aeb12..7cdbf719f154 100644 --- a/sdk/resourcemanager/attestation/armattestation/fake/server_factory.go +++ b/sdk/resourcemanager/attestation/armattestation/fake/server_factory.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,9 +15,17 @@ import ( // ServerFactory is a fake server for instances of the armattestation.ClientFactory type. type ServerFactory struct { - OperationsServer OperationsServer + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // PrivateEndpointConnectionsServer contains the fakes for client PrivateEndpointConnectionsClient PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer - ProvidersServer ProvidersServer + + // PrivateLinkResourcesServer contains the fakes for client PrivateLinkResourcesClient + PrivateLinkResourcesServer PrivateLinkResourcesServer + + // ProvidersServer contains the fakes for client ProvidersClient + ProvidersServer ProvidersServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -40,6 +44,7 @@ type ServerFactoryTransport struct { trMu sync.Mutex trOperationsServer *OperationsServerTransport trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport trProvidersServer *ProvidersServerTransport } @@ -64,6 +69,11 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewPrivateEndpointConnectionsServerTransport(&s.srv.PrivateEndpointConnectionsServer) }) resp, err = s.trPrivateEndpointConnectionsServer.Do(req) + case "PrivateLinkResourcesClient": + initServer(s, &s.trPrivateLinkResourcesServer, func() *PrivateLinkResourcesServerTransport { + return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) + }) + resp, err = s.trPrivateLinkResourcesServer.Do(req) case "ProvidersClient": initServer(s, &s.trProvidersServer, func() *ProvidersServerTransport { return NewProvidersServerTransport(&s.srv.ProvidersServer) }) resp, err = s.trProvidersServer.Do(req) diff --git a/sdk/resourcemanager/attestation/armattestation/fake/time_rfc3339.go b/sdk/resourcemanager/attestation/armattestation/fake/time_rfc3339.go deleted file mode 100644 index b0535a7b63e6..000000000000 --- a/sdk/resourcemanager/attestation/armattestation/fake/time_rfc3339.go +++ /dev/null @@ -1,86 +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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// 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+)*"*$`) - -const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { - layout = dateTimeJSON - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { - layout = time.RFC3339Nano - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/attestation/armattestation/go.mod b/sdk/resourcemanager/attestation/armattestation/go.mod index aa1c47101931..0f035e091f5e 100644 --- a/sdk/resourcemanager/attestation/armattestation/go.mod +++ b/sdk/resourcemanager/attestation/armattestation/go.mod @@ -1,14 +1,14 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2 go 1.23.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 - github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.11.1 ) require ( @@ -19,9 +19,9 @@ require ( github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.40.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect + golang.org/x/crypto v0.41.0 // indirect + golang.org/x/net v0.43.0 // indirect + golang.org/x/sys v0.35.0 // indirect + golang.org/x/text v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/attestation/armattestation/go.sum b/sdk/resourcemanager/attestation/armattestation/go.sum index 2bf8ec4cf7b1..a0aea6c2e87c 100644 --- a/sdk/resourcemanager/attestation/armattestation/go.sum +++ b/sdk/resourcemanager/attestation/armattestation/go.sum @@ -1,11 +1,11 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1 h1:Wc1ml6QlJs2BHQ/9Bqu1jiyggbsSjramq2oUmp5WeIo= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 h1:JXg2dwJUmPB9JmtVmdEB16APJ7jurfbY5jnfXpJoRMc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0/go.mod h1:YD5h/ldMsG0XiIw7PdyNhLxaM317eFh5yNLccNfGdyw= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1/go.mod h1:JdM5psgjfBf5fo2uWOZhflPWyDBZ/O/CNAH9CtsuZE4= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 h1:FPKJS1T+clwv+OLGt13a8UjqeRuh0O4SJ3lUriThc+4= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1/go.mod h1:j2chePtV91HrC22tGoRX3sGY42uF13WzmmV80/OdVAA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 h1:2qsIIvxVT+uE6yrNldntJKlLRgxGbZ85kgtz5SNBhMw= @@ -44,17 +44,17 @@ github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhi github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= -golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= +golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= +golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= +golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/sdk/resourcemanager/attestation/armattestation/models.go b/sdk/resourcemanager/attestation/armattestation/models.go index 36b8da5e539a..3f5e66b20e3b 100644 --- a/sdk/resourcemanager/attestation/armattestation/models.go +++ b/sdk/resourcemanager/attestation/armattestation/models.go @@ -1,25 +1,24 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation import "time" type JSONWebKey struct { - // REQUIRED; The "kty" (key type) parameter identifies the cryptographic algorithm family used with the key, such as "RSA" - // or "EC". "kty" values should either be registered in the IANA "JSON Web Key Types" - // registry established by [JWA] or be a value that contains a Collision- Resistant Name. The "kty" value is a case-sensitive - // string. + // REQUIRED; The "kty" (key type) parameter identifies the cryptographic algorithm + // family used with the key, such as "RSA" or "EC". "kty" values should + // either be registered in the IANA "JSON Web Key Types" registry + // established by [JWA] or be a value that contains a Collision- + // Resistant Name. The "kty" value is a case-sensitive string. Kty *string - // The "alg" (algorithm) parameter identifies the algorithm intended for use with the key. The values used should either be - // registered in the IANA "JSON Web Signature and Encryption Algorithms" registry - // established by [JWA] or be a value that contains a Collision- Resistant Name. + // The "alg" (algorithm) parameter identifies the algorithm intended for + // use with the key. The values used should either be registered in the + // IANA "JSON Web Signature and Encryption Algorithms" registry + // established by [JWA] or be a value that contains a Collision- + // Resistant Name. Alg *string // The "crv" (curve) parameter identifies the curve type @@ -40,12 +39,15 @@ type JSONWebKey struct { // Symmetric key K *string - // The "kid" (key ID) parameter is used to match a specific key. This is used, for instance, to choose among a set of keys - // within a JWK Set during key rollover. The structure of the "kid" value is - // unspecified. When "kid" values are used within a JWK Set, different keys within the JWK Set SHOULD use distinct "kid" values. - // (One example in which different keys might use the same "kid" value is if - // they have different "kty" (key type) values but are considered to be equivalent alternatives by the application using them.) - // The "kid" value is a case-sensitive string. + // The "kid" (key ID) parameter is used to match a specific key. This + // is used, for instance, to choose among a set of keys within a JWK Set + // during key rollover. The structure of the "kid" value is + // unspecified. When "kid" values are used within a JWK Set, different + // keys within the JWK Set SHOULD use distinct "kid" values. (One + // example in which different keys might use the same "kid" value is if + // they have different "kty" (key type) values but are considered to be + // equivalent alternatives by the application using them.) The "kid" + // value is a case-sensitive string. Kid *string // RSA modulus, in Base64 @@ -60,18 +62,21 @@ type JSONWebKey struct { // RSA Private Key Parameter Qi *string - // Use ("public key use") identifies the intended use of the public key. The "use" parameter is employed to indicate whether - // a public key is used for encrypting data or verifying the signature on data. - // Values are commonly "sig" (signature) or "enc" (encryption). + // Use ("public key use") identifies the intended use of + // the public key. The "use" parameter is employed to indicate whether + // a public key is used for encrypting data or verifying the signature + // on data. Values are commonly "sig" (signature) or "enc" (encryption). Use *string // X coordinate for the Elliptic Curve point X *string - // The "x5c" (X.509 certificate chain) parameter contains a chain of one or more PKIX certificates [RFC5280]. The certificate - // chain is represented as a JSON array of certificate value strings. Each - // string in the array is a base64-encoded (Section 4 of [RFC4648] -- not base64url-encoded) DER [ITU.X690.1994] PKIX certificate - // value. The PKIX certificate containing the key value MUST be the first + // The "x5c" (X.509 certificate chain) parameter contains a chain of one + // or more PKIX certificates [RFC5280]. The certificate chain is + // represented as a JSON array of certificate value strings. Each + // string in the array is a base64-encoded (Section 4 of [RFC4648] -- + // not base64url-encoded) DER [ITU.X690.1994] PKIX certificate value. + // The PKIX certificate containing the key value MUST be the first // certificate. X5C []*string @@ -80,12 +85,23 @@ type JSONWebKey struct { } type JSONWebKeySet struct { - // The value of the "keys" parameter is an array of JWK values. By default, the order of the JWK values within the array does - // not imply an order of preference among them, although applications of JWK - // Sets can choose to assign a meaning to the order for their purposes, if desired. + // The value of the "keys" parameter is an array of JWK values. By + // default, the order of the JWK values within the array does not imply + // an order of preference among them, although applications of JWK Sets + // can choose to assign a meaning to the order for their purposes, if + // desired. Keys []*JSONWebKey } +// LogSpecification - Specifications of the Log for Microsoft Azure Attestation +type LogSpecification struct { + // Localized friendly display name of the log + DisplayName *string + + // Name of the log + Name *string +} + // OperationList - List of supported operations. type OperationList struct { // List of supported operations. @@ -95,6 +111,12 @@ type OperationList struct { SystemData *SystemData } +// OperationProperties - Extra Operation properties +type OperationProperties struct { + // Service specifications of the operation + ServiceSpecification *ServiceSpecification +} + // OperationsDefinition - Definition object with the name and properties of an operation. type OperationsDefinition struct { // Display object with properties of the operation. @@ -102,6 +124,9 @@ type OperationsDefinition struct { // Name of the operation. Name *string + + // Properties of the operation + Properties *OperationProperties } // OperationsDisplayDefinition - Display object with properties of the operation. @@ -119,9 +144,9 @@ type OperationsDisplayDefinition struct { Resource *string } -// PrivateEndpoint - The Private Endpoint resource. +// PrivateEndpoint - The private endpoint resource. type PrivateEndpoint struct { - // READ-ONLY; The ARM identifier for Private Endpoint + // READ-ONLY; The resource identifier of the private endpoint ID *string } @@ -136,28 +161,73 @@ type PrivateEndpointConnection struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// PrivateEndpointConnectionListResult - List of private endpoint connection associated with the specified storage account +// PrivateEndpointConnectionListResult - The response of a PrivateEndpointConnection list operation. type PrivateEndpointConnectionListResult struct { - // Array of private endpoint connections + // REQUIRED; The PrivateEndpointConnection items on this page Value []*PrivateEndpointConnection + + // The link to the next page of items + NextLink *string } -// PrivateEndpointConnectionProperties - Properties of the PrivateEndpointConnectProperties. +// PrivateEndpointConnectionProperties - Properties of the private endpoint connection. type PrivateEndpointConnectionProperties struct { // REQUIRED; A collection of information about the state of the connection between service consumer and provider. PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState - // The resource of private end point. + // The private endpoint resource. PrivateEndpoint *PrivateEndpoint // READ-ONLY; The provisioning state of the private endpoint connection resource. ProvisioningState *PrivateEndpointConnectionProvisioningState } +// PrivateLinkResource - A private link resource. +type PrivateLinkResource struct { + // Resource properties. + Properties *PrivateLinkResourceProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PrivateLinkResourceListResult - The response of a PrivateLinkResource list operation. +type PrivateLinkResourceListResult struct { + // REQUIRED; The PrivateLinkResource items on this page + Value []*PrivateLinkResource + + // The link to the next page of items + NextLink *string +} + +// PrivateLinkResourceProperties - Properties of a private link resource. +type PrivateLinkResourceProperties struct { + // The private link resource private link DNS zone name. + RequiredZoneNames []*string + + // READ-ONLY; The private link resource group id. + GroupID *string + + // READ-ONLY; The private link resource required member names. + RequiredMembers []*string +} + // PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer // and provider. type PrivateLinkServiceConnectionState struct { @@ -188,7 +258,7 @@ type Provider struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata relating to this resource + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" @@ -204,18 +274,6 @@ type ProviderListResult struct { SystemData *SystemData } -// Resource - Common fields that are returned in the response for all Azure Resource Manager resources -type Resource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - // ServiceCreationParams - Parameters for creating an attestation provider type ServiceCreationParams struct { // REQUIRED; The supported Azure location where the attestation provider should be created. @@ -233,21 +291,51 @@ type ServiceCreationSpecificParams struct { // JSON Web Key Set defining a set of X.509 Certificates that will represent the parent certificate for the signing certificate // used for policy operations PolicySigningCertificates *JSONWebKeySet + + // Controls whether traffic from the public network is allowed to access the Attestation Provider APIs. + PublicNetworkAccess *PublicNetworkAccessType + + // The setting that controls whether authentication is enabled or disabled for TPM Attestation REST APIs. + TpmAttestationAuthentication *TpmAttestationAuthenticationType } // ServicePatchParams - Parameters for patching an attestation provider type ServicePatchParams struct { + // Properties of the attestation provider + Properties *ServicePatchSpecificParams + // The tags that will be assigned to the attestation provider. Tags map[string]*string } +// ServicePatchSpecificParams - Client supplied parameters used to patch an existing attestation provider. +type ServicePatchSpecificParams struct { + // Controls whether traffic from the public network is allowed to access the Attestation Provider APIs. + PublicNetworkAccess *PublicNetworkAccessType + + // The setting that controls whether authentication is enabled or disabled for TPM Attestation REST APIs. + TpmAttestationAuthentication *TpmAttestationAuthenticationType +} + +// ServiceSpecification - Service specification payload +type ServiceSpecification struct { + // Specifications of the Log for Microsoft Azure Attestation + LogSpecifications []*LogSpecification +} + // StatusResult - Status of attestation service. type StatusResult struct { // Gets the uri of attestation service AttestURI *string + // Controls whether traffic from the public network is allowed to access the Attestation Provider APIs. + PublicNetworkAccess *PublicNetworkAccessType + // Status of attestation service. - Status *AttestationServiceStatus + Status *ServiceStatus + + // The setting that controls whether authentication is enabled or disabled for TPM Attestation REST APIs. + TpmAttestationAuthentication *TpmAttestationAuthenticationType // Trust model for the attestation provider. TrustModel *string @@ -276,22 +364,3 @@ type SystemData struct { // The type of identity that last modified the resource. LastModifiedByType *CreatedByType } - -// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' -// and a 'location' -type TrackedResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string - - // Resource tags. - Tags map[string]*string - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} diff --git a/sdk/resourcemanager/attestation/armattestation/models_serde.go b/sdk/resourcemanager/attestation/armattestation/models_serde.go index 25beccba797e..e06845d9d78b 100644 --- a/sdk/resourcemanager/attestation/armattestation/models_serde.go +++ b/sdk/resourcemanager/attestation/armattestation/models_serde.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation @@ -133,6 +129,37 @@ func (j *JSONWebKeySet) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type LogSpecification. +func (l LogSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", l.DisplayName) + populate(objectMap, "name", l.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogSpecification. +func (l *LogSpecification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &l.DisplayName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OperationList. func (o OperationList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -164,11 +191,39 @@ func (o *OperationList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OperationProperties. +func (o OperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serviceSpecification", o.ServiceSpecification) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationProperties. +func (o *OperationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "serviceSpecification": + err = unpopulate(val, "ServiceSpecification", &o.ServiceSpecification) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OperationsDefinition. func (o OperationsDefinition) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) return json.Marshal(objectMap) } @@ -187,6 +242,9 @@ func (o *OperationsDefinition) UnmarshalJSON(data []byte) error { case "name": err = unpopulate(val, "Name", &o.Name) delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -267,6 +325,7 @@ func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } @@ -289,6 +348,9 @@ func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &p.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) @@ -303,6 +365,7 @@ func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } @@ -316,6 +379,9 @@ func (p *PrivateEndpointConnectionListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &p.Value) delete(rawMsg, key) @@ -362,6 +428,115 @@ func (p *PrivateEndpointConnectionProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResource. +func (p *PrivateLinkResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceListResult. +func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceProperties. +func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "groupId": + err = unpopulate(val, "GroupID", &p.GroupID) + delete(rawMsg, key) + case "requiredMembers": + err = unpopulate(val, "RequiredMembers", &p.RequiredMembers) + delete(rawMsg, key) + case "requiredZoneNames": + err = unpopulate(val, "RequiredZoneNames", &p.RequiredZoneNames) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -479,41 +654,6 @@ func (p *ProviderListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ServiceCreationParams. func (s ServiceCreationParams) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -553,6 +693,8 @@ func (s *ServiceCreationParams) UnmarshalJSON(data []byte) error { func (s ServiceCreationSpecificParams) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "policySigningCertificates", s.PolicySigningCertificates) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populate(objectMap, "tpmAttestationAuthentication", s.TpmAttestationAuthentication) return json.Marshal(objectMap) } @@ -568,6 +710,12 @@ func (s *ServiceCreationSpecificParams) UnmarshalJSON(data []byte) error { case "policySigningCertificates": err = unpopulate(val, "PolicySigningCertificates", &s.PolicySigningCertificates) delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "tpmAttestationAuthentication": + err = unpopulate(val, "TpmAttestationAuthentication", &s.TpmAttestationAuthentication) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -579,6 +727,7 @@ func (s *ServiceCreationSpecificParams) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServicePatchParams. func (s ServicePatchParams) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) populate(objectMap, "tags", s.Tags) return json.Marshal(objectMap) } @@ -592,6 +741,9 @@ func (s *ServicePatchParams) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &s.Tags) delete(rawMsg, key) @@ -603,12 +755,72 @@ func (s *ServicePatchParams) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ServicePatchSpecificParams. +func (s ServicePatchSpecificParams) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) + populate(objectMap, "tpmAttestationAuthentication", s.TpmAttestationAuthentication) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePatchSpecificParams. +func (s *ServicePatchSpecificParams) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) + case "tpmAttestationAuthentication": + err = unpopulate(val, "TpmAttestationAuthentication", &s.TpmAttestationAuthentication) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceSpecification. +func (s ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "logSpecifications", s.LogSpecifications) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceSpecification. +func (s *ServiceSpecification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "logSpecifications": + err = unpopulate(val, "LogSpecifications", &s.LogSpecifications) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type StatusResult. func (s StatusResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "attestUri", s.AttestURI) populate(objectMap, "privateEndpointConnections", s.PrivateEndpointConnections) + populate(objectMap, "publicNetworkAccess", s.PublicNetworkAccess) populate(objectMap, "status", s.Status) + populate(objectMap, "tpmAttestationAuthentication", s.TpmAttestationAuthentication) populate(objectMap, "trustModel", s.TrustModel) return json.Marshal(objectMap) } @@ -628,9 +840,15 @@ func (s *StatusResult) UnmarshalJSON(data []byte) error { case "privateEndpointConnections": err = unpopulate(val, "PrivateEndpointConnections", &s.PrivateEndpointConnections) delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &s.PublicNetworkAccess) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &s.Status) delete(rawMsg, key) + case "tpmAttestationAuthentication": + err = unpopulate(val, "TpmAttestationAuthentication", &s.TpmAttestationAuthentication) + delete(rawMsg, key) case "trustModel": err = unpopulate(val, "TrustModel", &s.TrustModel) delete(rawMsg, key) @@ -689,49 +907,6 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. -func (t *TrackedResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &t.Name) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &t.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &t.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - } - return nil -} - func populate(m map[string]any, k string, v any) { if v == nil { return @@ -743,7 +918,7 @@ func populate(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/attestation/armattestation/operations_client.go b/sdk/resourcemanager/attestation/armattestation/operations_client.go index 59cfcc95f97b..7acf4cf2a0e8 100644 --- a/sdk/resourcemanager/attestation/armattestation/operations_client.go +++ b/sdk/resourcemanager/attestation/armattestation/operations_client.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation @@ -25,7 +21,7 @@ type OperationsClient struct { // NewOperationsClient creates a new instance of OperationsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -37,42 +33,43 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// List - Lists all of the available Azure attestation operations. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - List the operations for the provider // -// Generated from API version 2020-10-01 -// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. -func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { - var err error - const operationName = "OperationsClient.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, options) - if err != nil { - return OperationsClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return OperationsClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// Generated from API version 2021-06-01 +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Attestation/operations" 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", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/attestation/armattestation/operations_client_example_test.go b/sdk/resourcemanager/attestation/armattestation/operations_client_example_test.go index 327c7f73f438..19edbebdc279 100644 --- a/sdk/resourcemanager/attestation/armattestation/operations_client_example_test.go +++ b/sdk/resourcemanager/attestation/armattestation/operations_client_example_test.go @@ -1,40 +1,70 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Operations_List.json -func ExampleOperationsClient_List() { +// Generated from example definition: 2021-06-01/Operations_List.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 := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewOperationsClient().List(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %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 = armattestation.OperationsClientListResponse{ + // OperationList: armattestation.OperationList{ + // Value: []*armattestation.OperationsDefinition{ + // { + // Name: to.Ptr("Microsoft.Attestation/attestationProviders/attestation/read"), + // Display: &armattestation.OperationsDisplayDefinition{ + // Description: to.Ptr("Get status of attestation service."), + // Operation: to.Ptr("Get status of attestation service"), + // Provider: to.Ptr("Microsoft Azure Attestation"), + // Resource: to.Ptr("Attestation"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Attestation/attestationProviders/attestation/write"), + // Display: &armattestation.OperationsDisplayDefinition{ + // Description: to.Ptr("Adds attestation service."), + // Operation: to.Ptr("Adds attestation service."), + // Provider: to.Ptr("Microsoft Azure Attestation"), + // Resource: to.Ptr("Attestation"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Attestation/attestationProviders/attestation/delete"), + // Display: &armattestation.OperationsDisplayDefinition{ + // Description: to.Ptr("Removes attestation service"), + // Operation: to.Ptr("Removes attestation service"), + // Provider: to.Ptr("Microsoft Azure Attestation"), + // Resource: to.Ptr("Attestation"), + // }, + // }, + // }, + // }, + // } } - // 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.OperationList = armattestation.OperationList{ - // } } diff --git a/sdk/resourcemanager/attestation/armattestation/options.go b/sdk/resourcemanager/attestation/armattestation/options.go index 111d56ff33ae..ad476d262a9e 100644 --- a/sdk/resourcemanager/attestation/armattestation/options.go +++ b/sdk/resourcemanager/attestation/armattestation/options.go @@ -1,14 +1,10 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -37,6 +33,12 @@ type PrivateEndpointConnectionsClientListOptions struct { // placeholder for future optional parameters } +// PrivateLinkResourcesClientListByProviderOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByProvider +// method. +type PrivateLinkResourcesClientListByProviderOptions struct { + // placeholder for future optional parameters +} + // ProvidersClientCreateOptions contains the optional parameters for the ProvidersClient.Create method. type ProvidersClientCreateOptions struct { // placeholder for future optional parameters @@ -58,7 +60,7 @@ type ProvidersClientGetOptions struct { // placeholder for future optional parameters } -// ProvidersClientListByResourceGroupOptions contains the optional parameters for the ProvidersClient.ListByResourceGroup +// ProvidersClientListByResourceGroupOptions contains the optional parameters for the ProvidersClient.NewListByResourceGroupPager // method. type ProvidersClientListByResourceGroupOptions struct { // placeholder for future optional parameters @@ -69,7 +71,7 @@ type ProvidersClientListDefaultOptions struct { // placeholder for future optional parameters } -// ProvidersClientListOptions contains the optional parameters for the ProvidersClient.List method. +// ProvidersClientListOptions contains the optional parameters for the ProvidersClient.NewListPager method. type ProvidersClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/attestation/armattestation/privateendpointconnections_client.go b/sdk/resourcemanager/attestation/armattestation/privateendpointconnections_client.go index 0b4d1c1c9ebd..03825c6acb65 100644 --- a/sdk/resourcemanager/attestation/armattestation/privateendpointconnections_client.go +++ b/sdk/resourcemanager/attestation/armattestation/privateendpointconnections_client.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation @@ -28,9 +24,9 @@ type PrivateEndpointConnectionsClient struct { } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -46,10 +42,10 @@ func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcor // Create - Update the state of specified private endpoint connection associated with the attestation provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - providerName - The name of the attestation provider. -// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - providerName - Name of the attestation provider. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource. // - properties - The private endpoint connection properties. // - options - PrivateEndpointConnectionsClientCreateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Create // method. @@ -76,8 +72,12 @@ func (client *PrivateEndpointConnectionsClient) Create(ctx context.Context, reso } // createCreateRequest creates the Create request. -func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsClientCreateOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, _ *PrivateEndpointConnectionsClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}/privateEndpointConnections/{privateEndpointConnectionName}" + 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") } @@ -86,10 +86,6 @@ func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context. return nil, errors.New("parameter providerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -99,9 +95,10 @@ func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } @@ -120,10 +117,10 @@ func (client *PrivateEndpointConnectionsClient) createHandleResponse(resp *http. // Delete - Deletes the specified private endpoint connection associated with the attestation provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - providerName - The name of the attestation provider. -// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - providerName - Name of the attestation provider. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource. // - options - PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete // method. func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientDeleteOptions) (PrivateEndpointConnectionsClientDeleteResponse, error) { @@ -148,8 +145,12 @@ func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, reso } // deleteCreateRequest creates the Delete request. -func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientDeleteOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}/privateEndpointConnections/{privateEndpointConnectionName}" + 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") } @@ -158,10 +159,6 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, errors.New("parameter providerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -171,19 +168,18 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // Get - Gets the specified private endpoint connection associated with the attestation provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - providerName - The name of the attestation provider. -// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - providerName - Name of the attestation provider. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource. // - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get // method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { @@ -209,8 +205,12 @@ func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourc } // getCreateRequest creates the Get request. -func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}/privateEndpointConnections/{privateEndpointConnectionName}" + 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") } @@ -219,10 +219,6 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter providerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -232,7 +228,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,29 +245,28 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res // NewListPager - List all the private endpoint connections associated with the attestation provider. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - providerName - The name of the attestation provider. +// - providerName - Name of the attestation provider. // - options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListPager // method. func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName string, providerName string, options *PrivateEndpointConnectionsClientListOptions) *runtime.Pager[PrivateEndpointConnectionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateEndpointConnectionsClientListResponse]{ More: func(page PrivateEndpointConnectionsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PrivateEndpointConnectionsClientListResponse) (PrivateEndpointConnectionsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateEndpointConnectionsClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, providerName, options) - if err != nil { - return PrivateEndpointConnectionsClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, providerName, options) + }, nil) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -279,8 +274,12 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s } // listCreateRequest creates the List request. -func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, providerName string, options *PrivateEndpointConnectionsClientListOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, providerName string, _ *PrivateEndpointConnectionsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}/privateEndpointConnections" + 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") } @@ -289,16 +288,12 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter providerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 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", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/attestation/armattestation/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/attestation/armattestation/privateendpointconnections_client_example_test.go index cbecf6d81b65..dc10d9adb7c5 100644 --- a/sdk/resourcemanager/attestation/armattestation/privateendpointconnections_client_example_test.go +++ b/sdk/resourcemanager/attestation/armattestation/privateendpointconnections_client_example_test.go @@ -1,171 +1,177 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation_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/attestation/armattestation" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/AttestationProviderListPrivateEndpointConnections.json -func ExamplePrivateEndpointConnectionsClient_NewListPager() { +// Generated from example definition: 2021-06-01/AttestationProviderPutPrivateEndpointConnection.json +func ExamplePrivateEndpointConnectionsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListPager("res6977", "sto2527", 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.PrivateEndpointConnectionListResult = armattestation.PrivateEndpointConnectionListResult{ - // Value: []*armattestation.PrivateEndpointConnection{ - // { - // Name: to.Ptr("{privateEndpointConnectionName}"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Attestation/attestationProviders/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), - // Properties: &armattestation.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armattestation.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), - // }, - // PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armattestation.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }, - // { - // Name: to.Ptr("{privateEndpointConnectionName}"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Attestation/attestationProviders/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), - // Properties: &armattestation.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armattestation.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest02"), - // }, - // PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armattestation.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }}, - // } + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Create(ctx, "res7687", "sto9699", "{privateEndpointConnectionName}", armattestation.PrivateEndpointConnection{ + Properties: &armattestation.PrivateEndpointConnectionProperties{ + PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ + Description: to.Ptr("Auto-Approved"), + Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), + }, + }, + }, 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 = armattestation.PrivateEndpointConnectionsClientCreateResponse{ + // PrivateEndpointConnection: &armattestation.PrivateEndpointConnection{ + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Attestation/attestationProviders/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armattestation.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armattestation.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armattestation.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/AttestationProviderGetPrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionsClient_Get() { +// Generated from example definition: 2021-06-01/AttestationProviderDeletePrivateEndpointConnection.json +func ExamplePrivateEndpointConnectionsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Delete(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", 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.PrivateEndpointConnection = armattestation.PrivateEndpointConnection{ - // Name: to.Ptr("{privateEndpointConnectionName}"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Attestation/attestationProviders/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), - // Properties: &armattestation.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armattestation.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), - // }, - // PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armattestation.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, + // res = armattestation.PrivateEndpointConnectionsClientDeleteResponse{ // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/AttestationProviderPutPrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionsClient_Create() { +// Generated from example definition: 2021-06-01/AttestationProviderGetPrivateEndpointConnection.json +func ExamplePrivateEndpointConnectionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPrivateEndpointConnectionsClient().Create(ctx, "res7687", "sto9699", "{privateEndpointConnectionName}", armattestation.PrivateEndpointConnection{ - Properties: &armattestation.PrivateEndpointConnectionProperties{ - PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ - Description: to.Ptr("Auto-Approved"), - Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), - }, - }, - }, nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", 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.PrivateEndpointConnection = armattestation.PrivateEndpointConnection{ - // Name: to.Ptr("{privateEndpointConnectionName}"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Attestation/attestationProviders/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), - // Properties: &armattestation.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armattestation.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), - // }, - // PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), + // res = armattestation.PrivateEndpointConnectionsClientGetResponse{ + // PrivateEndpointConnection: &armattestation.PrivateEndpointConnection{ + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Attestation/attestationProviders/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armattestation.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armattestation.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armattestation.PrivateEndpointConnectionProvisioningStateSucceeded), // }, - // ProvisioningState: to.Ptr(armattestation.PrivateEndpointConnectionProvisioningStateSucceeded), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/AttestationProviderDeletePrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionsClient_Delete() { +// Generated from example definition: 2021-06-01/AttestationProviderListPrivateEndpointConnections.json +func ExamplePrivateEndpointConnectionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewPrivateEndpointConnectionsClient().Delete(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListPager("res6977", "sto2527", 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 = armattestation.PrivateEndpointConnectionsClientListResponse{ + // PrivateEndpointConnectionListResult: armattestation.PrivateEndpointConnectionListResult{ + // Value: []*armattestation.PrivateEndpointConnection{ + // { + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Attestation/attestationProviders/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armattestation.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armattestation.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armattestation.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Attestation/attestationProviders/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armattestation.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armattestation.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest02"), + // }, + // PrivateLinkServiceConnectionState: &armattestation.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // Status: to.Ptr(armattestation.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armattestation.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // }, + // }, + // } } } diff --git a/sdk/resourcemanager/attestation/armattestation/privatelinkresources_client.go b/sdk/resourcemanager/attestation/armattestation/privatelinkresources_client.go new file mode 100644 index 000000000000..23c6267e8540 --- /dev/null +++ b/sdk/resourcemanager/attestation/armattestation/privatelinkresources_client.go @@ -0,0 +1,105 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armattestation + +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" +) + +// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. +// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. +type PrivateLinkResourcesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PrivateLinkResourcesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// ListByProvider - Gets the private link resources supported for the attestation provider. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - providerName - Name of the attestation provider. +// - options - PrivateLinkResourcesClientListByProviderOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByProvider +// method. +func (client *PrivateLinkResourcesClient) ListByProvider(ctx context.Context, resourceGroupName string, providerName string, options *PrivateLinkResourcesClientListByProviderOptions) (PrivateLinkResourcesClientListByProviderResponse, error) { + var err error + const operationName = "PrivateLinkResourcesClient.ListByProvider" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByProviderCreateRequest(ctx, resourceGroupName, providerName, options) + if err != nil { + return PrivateLinkResourcesClientListByProviderResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrivateLinkResourcesClientListByProviderResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkResourcesClientListByProviderResponse{}, err + } + resp, err := client.listByProviderHandleResponse(httpResp) + return resp, err +} + +// listByProviderCreateRequest creates the ListByProvider request. +func (client *PrivateLinkResourcesClient) listByProviderCreateRequest(ctx context.Context, resourceGroupName string, providerName string, _ *PrivateLinkResourcesClientListByProviderOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}/privateLinkResources" + 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 providerName == "" { + return nil, errors.New("parameter providerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName)) + 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", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProviderHandleResponse handles the ListByProvider response. +func (client *PrivateLinkResourcesClient) listByProviderHandleResponse(resp *http.Response) (PrivateLinkResourcesClientListByProviderResponse, error) { + result := PrivateLinkResourcesClientListByProviderResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkResourceListResult); err != nil { + return PrivateLinkResourcesClientListByProviderResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/attestation/armattestation/privatelinkresources_client_example_test.go b/sdk/resourcemanager/attestation/armattestation/privatelinkresources_client_example_test.go new file mode 100644 index 000000000000..59b53ded25c7 --- /dev/null +++ b/sdk/resourcemanager/attestation/armattestation/privatelinkresources_client_example_test.go @@ -0,0 +1,52 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armattestation_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2" + "log" +) + +// Generated from example definition: 2021-06-01/AttestationProviderListPrivateLinkResources.json +func ExamplePrivateLinkResourcesClient_ListByProvider() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armattestation.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateLinkResourcesClient().ListByProvider(ctx, "MyResourceGroup", "myattestationprovider", 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 = armattestation.PrivateLinkResourcesClientListByProviderResponse{ + // PrivateLinkResourceListResult: &armattestation.PrivateLinkResourceListResult{ + // Value: []*armattestation.PrivateLinkResource{ + // { + // Name: to.Ptr("tenant"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders/privateLinkResources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Attestation/attestationProviders/myattestationprovider/privateLinkResources/tenant"), + // Properties: &armattestation.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("standard"), + // RequiredMembers: []*string{ + // to.Ptr("default"), + // }, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.attest.azure.net"), + // }, + // }, + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/attestation/armattestation/providers_client.go b/sdk/resourcemanager/attestation/armattestation/providers_client.go index 44e8ee0372f8..2b5062f58d4f 100644 --- a/sdk/resourcemanager/attestation/armattestation/providers_client.go +++ b/sdk/resourcemanager/attestation/armattestation/providers_client.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation @@ -20,7 +16,7 @@ import ( "strings" ) -// ProvidersClient contains the methods for the AttestationProviders group. +// ProvidersClient contains the methods for the Providers group. // Don't use this type directly, use NewProvidersClient() instead. type ProvidersClient struct { internal *arm.Client @@ -28,9 +24,9 @@ type ProvidersClient struct { } // NewProvidersClient creates a new instance of ProvidersClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewProvidersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProvidersClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -43,10 +39,10 @@ func NewProvidersClient(subscriptionID string, credential azcore.TokenCredential return client, nil } -// Create - Creates a new Attestation Provider. +// Create - Creates or updates an Attestation Provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - providerName - Name of the attestation provider. // - creationParams - Client supplied parameters. @@ -74,7 +70,7 @@ func (client *ProvidersClient) Create(ctx context.Context, resourceGroupName str } // createCreateRequest creates the Create request. -func (client *ProvidersClient) createCreateRequest(ctx context.Context, resourceGroupName string, providerName string, creationParams ServiceCreationParams, options *ProvidersClientCreateOptions) (*policy.Request, error) { +func (client *ProvidersClient) createCreateRequest(ctx context.Context, resourceGroupName string, providerName string, creationParams ServiceCreationParams, _ *ProvidersClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -93,9 +89,10 @@ func (client *ProvidersClient) createCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, creationParams); err != nil { return nil, err } @@ -114,9 +111,9 @@ func (client *ProvidersClient) createHandleResponse(resp *http.Response) (Provid // Delete - Delete Attestation Service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - providerName - Name of the attestation service +// - providerName - Name of the attestation provider. // - options - ProvidersClientDeleteOptions contains the optional parameters for the ProvidersClient.Delete method. func (client *ProvidersClient) Delete(ctx context.Context, resourceGroupName string, providerName string, options *ProvidersClientDeleteOptions) (ProvidersClientDeleteResponse, error) { var err error @@ -140,7 +137,7 @@ func (client *ProvidersClient) Delete(ctx context.Context, resourceGroupName str } // deleteCreateRequest creates the Delete request. -func (client *ProvidersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, providerName string, options *ProvidersClientDeleteOptions) (*policy.Request, error) { +func (client *ProvidersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, providerName string, _ *ProvidersClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -159,16 +156,15 @@ func (client *ProvidersClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // Get - Get the status of Attestation Provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - providerName - Name of the attestation provider. // - options - ProvidersClientGetOptions contains the optional parameters for the ProvidersClient.Get method. @@ -195,7 +191,7 @@ func (client *ProvidersClient) Get(ctx context.Context, resourceGroupName string } // getCreateRequest creates the Get request. -func (client *ProvidersClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, options *ProvidersClientGetOptions) (*policy.Request, error) { +func (client *ProvidersClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, _ *ProvidersClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -214,7 +210,7 @@ func (client *ProvidersClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -232,8 +228,8 @@ func (client *ProvidersClient) getHandleResponse(resp *http.Response) (Providers // GetDefaultByLocation - Get the default provider by location. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 -// - location - The location of the default provider. +// Generated from API version 2021-06-01 +// - location - The location name. // - options - ProvidersClientGetDefaultByLocationOptions contains the optional parameters for the ProvidersClient.GetDefaultByLocation // method. func (client *ProvidersClient) GetDefaultByLocation(ctx context.Context, location string, options *ProvidersClientGetDefaultByLocationOptions) (ProvidersClientGetDefaultByLocationResponse, error) { @@ -259,22 +255,22 @@ func (client *ProvidersClient) GetDefaultByLocation(ctx context.Context, locatio } // getDefaultByLocationCreateRequest creates the GetDefaultByLocation request. -func (client *ProvidersClient) getDefaultByLocationCreateRequest(ctx context.Context, location string, options *ProvidersClientGetDefaultByLocationOptions) (*policy.Request, error) { +func (client *ProvidersClient) getDefaultByLocationCreateRequest(ctx context.Context, location string, _ *ProvidersClientGetDefaultByLocationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Attestation/locations/{location}/defaultProvider" - if location == "" { - return nil, errors.New("parameter location cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) 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", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -289,35 +285,36 @@ func (client *ProvidersClient) getDefaultByLocationHandleResponse(resp *http.Res return result, nil } -// List - Returns a list of attestation providers in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Returns a list of attestation providers in a subscription. // -// Generated from API version 2020-10-01 -// - options - ProvidersClientListOptions contains the optional parameters for the ProvidersClient.List method. -func (client *ProvidersClient) List(ctx context.Context, options *ProvidersClientListOptions) (ProvidersClientListResponse, error) { - var err error - const operationName = "ProvidersClient.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, options) - if err != nil { - return ProvidersClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ProvidersClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ProvidersClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// Generated from API version 2021-06-01 +// - options - ProvidersClientListOptions contains the optional parameters for the ProvidersClient.NewListPager method. +func (client *ProvidersClient) NewListPager(options *ProvidersClientListOptions) *runtime.Pager[ProvidersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ProvidersClientListResponse]{ + More: func(page ProvidersClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *ProvidersClientListResponse) (ProvidersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ProvidersClient.NewListPager") + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return ProvidersClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProvidersClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProvidersClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. -func (client *ProvidersClient) listCreateRequest(ctx context.Context, options *ProvidersClientListOptions) (*policy.Request, error) { +func (client *ProvidersClient) listCreateRequest(ctx context.Context, _ *ProvidersClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Attestation/attestationProviders" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -328,7 +325,7 @@ func (client *ProvidersClient) listCreateRequest(ctx context.Context, options *P return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -343,52 +340,53 @@ func (client *ProvidersClient) listHandleResponse(resp *http.Response) (Provider return result, nil } -// ListByResourceGroup - Returns attestation providers list in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListByResourceGroupPager - Returns attestation providers list in a resource group. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - options - ProvidersClientListByResourceGroupOptions contains the optional parameters for the ProvidersClient.ListByResourceGroup +// - options - ProvidersClientListByResourceGroupOptions contains the optional parameters for the ProvidersClient.NewListByResourceGroupPager // method. -func (client *ProvidersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *ProvidersClientListByResourceGroupOptions) (ProvidersClientListByResourceGroupResponse, error) { - var err error - const operationName = "ProvidersClient.ListByResourceGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - if err != nil { - return ProvidersClientListByResourceGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ProvidersClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ProvidersClientListByResourceGroupResponse{}, err - } - resp, err := client.listByResourceGroupHandleResponse(httpResp) - return resp, err +func (client *ProvidersClient) NewListByResourceGroupPager(resourceGroupName string, options *ProvidersClientListByResourceGroupOptions) *runtime.Pager[ProvidersClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ProvidersClientListByResourceGroupResponse]{ + More: func(page ProvidersClientListByResourceGroupResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *ProvidersClientListByResourceGroupResponse) (ProvidersClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ProvidersClient.NewListByResourceGroupPager") + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return ProvidersClientListByResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProvidersClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProvidersClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *ProvidersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ProvidersClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *ProvidersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ProvidersClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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)) 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", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -406,7 +404,7 @@ func (client *ProvidersClient) listByResourceGroupHandleResponse(resp *http.Resp // ListDefault - Get the default provider // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - options - ProvidersClientListDefaultOptions contains the optional parameters for the ProvidersClient.ListDefault method. func (client *ProvidersClient) ListDefault(ctx context.Context, options *ProvidersClientListDefaultOptions) (ProvidersClientListDefaultResponse, error) { var err error @@ -431,7 +429,7 @@ func (client *ProvidersClient) ListDefault(ctx context.Context, options *Provide } // listDefaultCreateRequest creates the ListDefault request. -func (client *ProvidersClient) listDefaultCreateRequest(ctx context.Context, options *ProvidersClientListDefaultOptions) (*policy.Request, error) { +func (client *ProvidersClient) listDefaultCreateRequest(ctx context.Context, _ *ProvidersClientListDefaultOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Attestation/defaultProviders" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -442,7 +440,7 @@ func (client *ProvidersClient) listDefaultCreateRequest(ctx context.Context, opt return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -460,7 +458,7 @@ func (client *ProvidersClient) listDefaultHandleResponse(resp *http.Response) (P // Update - Updates the Attestation Provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - providerName - Name of the attestation provider. // - updateParams - Client supplied parameters. @@ -488,7 +486,7 @@ func (client *ProvidersClient) Update(ctx context.Context, resourceGroupName str } // updateCreateRequest creates the Update request. -func (client *ProvidersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, updateParams ServicePatchParams, options *ProvidersClientUpdateOptions) (*policy.Request, error) { +func (client *ProvidersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, updateParams ServicePatchParams, _ *ProvidersClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -507,9 +505,10 @@ func (client *ProvidersClient) updateCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, updateParams); err != nil { return nil, err } diff --git a/sdk/resourcemanager/attestation/armattestation/providers_client_example_test.go b/sdk/resourcemanager/attestation/armattestation/providers_client_example_test.go index 24dc9399bae5..c7c2a69a0485 100644 --- a/sdk/resourcemanager/attestation/armattestation/providers_client_example_test.go +++ b/sdk/resourcemanager/attestation/armattestation/providers_client_example_test.go @@ -1,244 +1,271 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation_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/attestation/armattestation" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Get_AttestationProvider.json -func ExampleProvidersClient_Get() { +// Generated from example definition: 2021-06-01/Create_AttestationProvider.json +func ExampleProvidersClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProvidersClient().Get(ctx, "MyResourceGroup", "myattestationprovider", nil) + res, err := clientFactory.NewProvidersClient().Create(ctx, "MyResourceGroup", "myattestationprovider", armattestation.ServiceCreationParams{ + Location: to.Ptr("East US"), + Properties: &armattestation.ServiceCreationSpecificParams{ + PublicNetworkAccess: to.Ptr(armattestation.PublicNetworkAccessTypeEnabled), + TpmAttestationAuthentication: to.Ptr(armattestation.TpmAttestationAuthenticationTypeEnabled), + }, + Tags: map[string]*string{ + "Property1": to.Ptr("Value1"), + "Property2": to.Ptr("Value2"), + "Property3": to.Ptr("Value3"), + }, + }, 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.Provider = armattestation.Provider{ - // Name: to.Ptr("myattestationprovider"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "Property1": to.Ptr("Value1"), - // "Property2": to.Ptr("Value2"), - // "Property3": to.Ptr("Value3"), - // }, - // Properties: &armattestation.StatusResult{ - // AttestURI: to.Ptr("https://superservice.attestation.azure.net"), - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // TrustModel: to.Ptr("Isolated"), + // res = armattestation.ProvidersClientCreateResponse{ + // Provider: &armattestation.Provider{ + // Name: to.Ptr("myattestationprovider"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), + // Location: to.Ptr("East US"), + // Properties: &armattestation.StatusResult{ + // AttestURI: to.Ptr("https://myattestationprovider.eus.attest.azure.net"), + // PublicNetworkAccess: to.Ptr(armattestation.PublicNetworkAccessTypeEnabled), + // Status: to.Ptr(armattestation.ServiceStatusReady), + // TpmAttestationAuthentication: to.Ptr(armattestation.TpmAttestationAuthenticationTypeEnabled), + // TrustModel: to.Ptr("AAD"), + // }, + // Tags: map[string]*string{ + // "Property1": to.Ptr("Value1"), + // "Property2": to.Ptr("Value2"), + // "Property3": to.Ptr("Value3"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Create_AttestationProvider.json -func ExampleProvidersClient_Create() { +// Generated from example definition: 2021-06-01/Delete_AttestationProvider.json +func ExampleProvidersClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProvidersClient().Create(ctx, "MyResourceGroup", "myattestationprovider", armattestation.ServiceCreationParams{}, nil) + res, err := clientFactory.NewProvidersClient().Delete(ctx, "sample-resource-group", "myattestationprovider", 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.Provider = armattestation.Provider{ - // Name: to.Ptr("myattestationprovider"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "Property1": to.Ptr("Value1"), - // "Property2": to.Ptr("Value2"), - // "Property3": to.Ptr("Value3"), - // }, - // Properties: &armattestation.StatusResult{ - // AttestURI: to.Ptr("https://superservice.attestation.azure.net"), - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // TrustModel: to.Ptr("Isolated"), - // }, + // res = armattestation.ProvidersClientDeleteResponse{ // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Update_AttestationProvider.json -func ExampleProvidersClient_Update() { +// Generated from example definition: 2021-06-01/Get_AttestationProvider.json +func ExampleProvidersClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProvidersClient().Update(ctx, "MyResourceGroup", "myattestationprovider", armattestation.ServicePatchParams{ - Tags: map[string]*string{ - "Property1": to.Ptr("Value1"), - "Property2": to.Ptr("Value2"), - "Property3": to.Ptr("Value3"), - }, - }, nil) + res, err := clientFactory.NewProvidersClient().Get(ctx, "MyResourceGroup", "myattestationprovider", 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.Provider = armattestation.Provider{ - // Name: to.Ptr("myattestationprovider"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "Property1": to.Ptr("Value1"), - // "Property2": to.Ptr("Value2"), - // "Property3": to.Ptr("Value3"), - // }, - // Properties: &armattestation.StatusResult{ - // AttestURI: to.Ptr("https://superservice.attestation.azure.net"), - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // TrustModel: to.Ptr("Isolated"), + // res = armattestation.ProvidersClientGetResponse{ + // Provider: &armattestation.Provider{ + // Name: to.Ptr("myattestationprovider"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), + // Location: to.Ptr("East US"), + // Properties: &armattestation.StatusResult{ + // AttestURI: to.Ptr("https://superservice.attestation.azure.net"), + // PublicNetworkAccess: to.Ptr(armattestation.PublicNetworkAccessTypeEnabled), + // Status: to.Ptr(armattestation.ServiceStatusReady), + // TpmAttestationAuthentication: to.Ptr(armattestation.TpmAttestationAuthenticationTypeEnabled), + // TrustModel: to.Ptr("Isolated"), + // }, + // Tags: map[string]*string{ + // "Property1": to.Ptr("Value1"), + // "Property2": to.Ptr("Value2"), + // "Property3": to.Ptr("Value3"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Delete_AttestationProvider.json -func ExampleProvidersClient_Delete() { +// Generated from example definition: 2021-06-01/Get_DefaultProviderByLocation.json +func ExampleProvidersClient_GetDefaultByLocation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("6c96b33e-f5b8-40a6-9011-5cb1c58b0915", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewProvidersClient().Delete(ctx, "sample-resource-group", "myattestationprovider", nil) + res, err := clientFactory.NewProvidersClient().GetDefaultByLocation(ctx, "Central US", 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 = armattestation.ProvidersClientGetDefaultByLocationResponse{ + // Provider: &armattestation.Provider{ + // Name: to.Ptr("sharedcus"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("providers/Microsoft.Attestation/attestationProviders/sharedcus"), + // Location: to.Ptr("Central US"), + // Properties: &armattestation.StatusResult{ + // AttestURI: to.Ptr("https://sharedcus.cus.attest.azure.net"), + // PublicNetworkAccess: to.Ptr(armattestation.PublicNetworkAccessTypeEnabled), + // Status: to.Ptr(armattestation.ServiceStatusReady), + // TpmAttestationAuthentication: to.Ptr(armattestation.TpmAttestationAuthenticationTypeEnabled), + // TrustModel: to.Ptr("AAD"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Get_AttestationProvidersList.json -func ExampleProvidersClient_List() { +// Generated from example definition: 2021-06-01/Get_AttestationProvidersList.json +func ExampleProvidersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProvidersClient().List(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewProvidersClient().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 = armattestation.ProvidersClientListResponse{ + // ProviderListResult: armattestation.ProviderListResult{ + // Value: []*armattestation.Provider{ + // { + // Name: to.Ptr("myattestationprovider"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("subscriptions/6c96b33e-f5b8-40a6-9011-5cb1c58b0915/resourceGroups/testrg1/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), + // Location: to.Ptr("East US"), + // Properties: &armattestation.StatusResult{ + // Status: to.Ptr(armattestation.ServiceStatusReady), + // }, + // }, + // { + // Name: to.Ptr("codes2"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("subscriptions/6c96b33e-f5b8-40a6-9011-5cb1c58b0915/resourceGroups/testrg2/providers/Microsoft.Attestation/attestationProviders/codes2"), + // Location: to.Ptr("East US"), + // Properties: &armattestation.StatusResult{ + // Status: to.Ptr(armattestation.ServiceStatusReady), + // }, + // }, + // }, + // }, + // } } - // 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.ProviderListResult = armattestation.ProviderListResult{ - // Value: []*armattestation.Provider{ - // { - // Name: to.Ptr("myattestationprovider"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("subscriptions/6c96b33e-f5b8-40a6-9011-5cb1c58b0915/resourceGroups/testrg1/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), - // Location: to.Ptr("East US"), - // Properties: &armattestation.StatusResult{ - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // }, - // }, - // { - // Name: to.Ptr("codes2"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("subscriptions/6c96b33e-f5b8-40a6-9011-5cb1c58b0915/resourceGroups/testrg2/providers/Microsoft.Attestation/attestationProviders/codes2"), - // Location: to.Ptr("East US"), - // Properties: &armattestation.StatusResult{ - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // }, - // }}, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Get_AttestationProvidersListByResourceGroup.json -func ExampleProvidersClient_ListByResourceGroup() { +// Generated from example definition: 2021-06-01/Get_AttestationProvidersListByResourceGroup.json +func ExampleProvidersClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("6c96b33e-f5b8-40a6-9011-5cb1c58b0915", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProvidersClient().ListByResourceGroup(ctx, "testrg1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewProvidersClient().NewListByResourceGroupPager("testrg1", 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 = armattestation.ProvidersClientListByResourceGroupResponse{ + // ProviderListResult: armattestation.ProviderListResult{ + // Value: []*armattestation.Provider{ + // { + // Name: to.Ptr("myattestationprovider"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("subscriptions/6c96b33e-f5b8-40a6-9011-5cb1c58b0915/resourceGroups/testrg1/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), + // Location: to.Ptr("East US"), + // Properties: &armattestation.StatusResult{ + // Status: to.Ptr(armattestation.ServiceStatusReady), + // }, + // }, + // { + // Name: to.Ptr("codes2"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("subscriptions/6c96b33e-f5b8-40a6-9011-5cb1c58b0915/resourceGroups/testrg1/providers/Microsoft.Attestation/attestationProviders/codes2"), + // Location: to.Ptr("East US"), + // Properties: &armattestation.StatusResult{ + // Status: to.Ptr(armattestation.ServiceStatusReady), + // }, + // }, + // }, + // }, + // } } - // 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.ProviderListResult = armattestation.ProviderListResult{ - // Value: []*armattestation.Provider{ - // { - // Name: to.Ptr("myattestationprovider"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("subscriptions/6c96b33e-f5b8-40a6-9011-5cb1c58b0915/resourceGroups/testrg1/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), - // Location: to.Ptr("East US"), - // Properties: &armattestation.StatusResult{ - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // }, - // }, - // { - // Name: to.Ptr("codes2"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("subscriptions/6c96b33e-f5b8-40a6-9011-5cb1c58b0915/resourceGroups/testrg1/providers/Microsoft.Attestation/attestationProviders/codes2"), - // Location: to.Ptr("East US"), - // Properties: &armattestation.StatusResult{ - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // }, - // }}, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Get_DefaultProviders.json +// Generated from example definition: 2021-06-01/Get_DefaultProviders.json func ExampleProvidersClient_ListDefault() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("6c96b33e-f5b8-40a6-9011-5cb1c58b0915", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -249,60 +276,86 @@ func ExampleProvidersClient_ListDefault() { // 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.ProviderListResult = armattestation.ProviderListResult{ - // Value: []*armattestation.Provider{ - // { - // Name: to.Ptr("sharedcus"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("providers/Microsoft.Attestation/attestationProviders/sharedcus"), - // Location: to.Ptr("Central US"), - // Properties: &armattestation.StatusResult{ - // AttestURI: to.Ptr("https://sharedcus.cus.attest.azure.net"), - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // TrustModel: to.Ptr("AAD"), + // res = armattestation.ProvidersClientListDefaultResponse{ + // ProviderListResult: &armattestation.ProviderListResult{ + // Value: []*armattestation.Provider{ + // { + // Name: to.Ptr("sharedcus"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("providers/Microsoft.Attestation/attestationProviders/sharedcus"), + // Location: to.Ptr("Central US"), + // Properties: &armattestation.StatusResult{ + // AttestURI: to.Ptr("https://sharedcus.cus.attest.azure.net"), + // PublicNetworkAccess: to.Ptr(armattestation.PublicNetworkAccessTypeEnabled), + // Status: to.Ptr(armattestation.ServiceStatusReady), + // TpmAttestationAuthentication: to.Ptr(armattestation.TpmAttestationAuthenticationTypeEnabled), + // TrustModel: to.Ptr("AAD"), + // }, // }, - // }, - // { - // Name: to.Ptr("shareduks"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("providers/Microsoft.Attestation/attestationProviders/shareduks"), - // Location: to.Ptr("UK South"), - // Properties: &armattestation.StatusResult{ - // AttestURI: to.Ptr("https://shareduks.uks.attest.azure.net"), - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // TrustModel: to.Ptr("AAD"), + // { + // Name: to.Ptr("shareduks"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("providers/Microsoft.Attestation/attestationProviders/shareduks"), + // Location: to.Ptr("UK South"), + // Properties: &armattestation.StatusResult{ + // AttestURI: to.Ptr("https://shareduks.uks.attest.azure.net"), + // PublicNetworkAccess: to.Ptr(armattestation.PublicNetworkAccessTypeEnabled), + // Status: to.Ptr(armattestation.ServiceStatusReady), + // TpmAttestationAuthentication: to.Ptr(armattestation.TpmAttestationAuthenticationTypeEnabled), + // TrustModel: to.Ptr("AAD"), + // }, // }, - // }}, + // }, + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/attestation/resource-manager/Microsoft.Attestation/stable/2020-10-01/examples/Get_DefaultProviderByLocation.json -func ExampleProvidersClient_GetDefaultByLocation() { +// Generated from example definition: 2021-06-01/Update_AttestationProvider.json +func ExampleProvidersClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armattestation.NewClientFactory("", cred, nil) + clientFactory, err := armattestation.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProvidersClient().GetDefaultByLocation(ctx, "Central US", nil) + res, err := clientFactory.NewProvidersClient().Update(ctx, "MyResourceGroup", "myattestationprovider", armattestation.ServicePatchParams{ + Properties: &armattestation.ServicePatchSpecificParams{ + PublicNetworkAccess: to.Ptr(armattestation.PublicNetworkAccessTypeDisabled), + TpmAttestationAuthentication: to.Ptr(armattestation.TpmAttestationAuthenticationTypeDisabled), + }, + Tags: map[string]*string{ + "Property1": to.Ptr("Value1"), + "Property2": to.Ptr("Value2"), + "Property3": to.Ptr("Value3"), + }, + }, 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.Provider = armattestation.Provider{ - // Name: to.Ptr("sharedcus"), - // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), - // ID: to.Ptr("providers/Microsoft.Attestation/attestationProviders/sharedcus"), - // Location: to.Ptr("Central US"), - // Properties: &armattestation.StatusResult{ - // AttestURI: to.Ptr("https://sharedcus.cus.attest.azure.net"), - // Status: to.Ptr(armattestation.AttestationServiceStatusReady), - // TrustModel: to.Ptr("AAD"), + // res = armattestation.ProvidersClientUpdateResponse{ + // Provider: &armattestation.Provider{ + // Name: to.Ptr("myattestationprovider"), + // Type: to.Ptr("Microsoft.Attestation/attestationProviders"), + // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Attestation/attestationProviders/myattestationprovider"), + // Location: to.Ptr("East US"), + // Properties: &armattestation.StatusResult{ + // AttestURI: to.Ptr("https://superservice.attestation.azure.net"), + // PublicNetworkAccess: to.Ptr(armattestation.PublicNetworkAccessTypeDisabled), + // Status: to.Ptr(armattestation.ServiceStatusReady), + // TpmAttestationAuthentication: to.Ptr(armattestation.TpmAttestationAuthenticationTypeDisabled), + // TrustModel: to.Ptr("Isolated"), + // }, + // Tags: map[string]*string{ + // "Property1": to.Ptr("Value1"), + // "Property2": to.Ptr("Value2"), + // "Property3": to.Ptr("Value3"), + // }, // }, // } } diff --git a/sdk/resourcemanager/attestation/armattestation/response_types.go b/sdk/resourcemanager/attestation/armattestation/responses.go similarity index 84% rename from sdk/resourcemanager/attestation/armattestation/response_types.go rename to sdk/resourcemanager/attestation/armattestation/responses.go index 038250901ad4..63980feaf4a1 100644 --- a/sdk/resourcemanager/attestation/armattestation/response_types.go +++ b/sdk/resourcemanager/attestation/armattestation/responses.go @@ -1,14 +1,10 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { // List of supported operations. OperationList @@ -33,10 +29,16 @@ type PrivateEndpointConnectionsClientGetResponse struct { // PrivateEndpointConnectionsClientListResponse contains the response from method PrivateEndpointConnectionsClient.NewListPager. type PrivateEndpointConnectionsClientListResponse struct { - // List of private endpoint connection associated with the specified storage account + // The response of a PrivateEndpointConnection list operation. PrivateEndpointConnectionListResult } +// PrivateLinkResourcesClientListByProviderResponse contains the response from method PrivateLinkResourcesClient.ListByProvider. +type PrivateLinkResourcesClientListByProviderResponse struct { + // The response of a PrivateLinkResource list operation. + PrivateLinkResourceListResult +} + // ProvidersClientCreateResponse contains the response from method ProvidersClient.Create. type ProvidersClientCreateResponse struct { // Attestation service response message. @@ -60,7 +62,7 @@ type ProvidersClientGetResponse struct { Provider } -// ProvidersClientListByResourceGroupResponse contains the response from method ProvidersClient.ListByResourceGroup. +// ProvidersClientListByResourceGroupResponse contains the response from method ProvidersClient.NewListByResourceGroupPager. type ProvidersClientListByResourceGroupResponse struct { // Attestation Providers List. ProviderListResult @@ -72,7 +74,7 @@ type ProvidersClientListDefaultResponse struct { ProviderListResult } -// ProvidersClientListResponse contains the response from method ProvidersClient.List. +// ProvidersClientListResponse contains the response from method ProvidersClient.NewListPager. type ProvidersClientListResponse struct { // Attestation Providers List. ProviderListResult diff --git a/sdk/resourcemanager/attestation/armattestation/testdata/_metadata.json b/sdk/resourcemanager/attestation/armattestation/testdata/_metadata.json new file mode 100644 index 000000000000..2e52fd1eab30 --- /dev/null +++ b/sdk/resourcemanager/attestation/armattestation/testdata/_metadata.json @@ -0,0 +1,4 @@ +{ + "apiVersion": "2021-06-01", + "emitterVersion": "0.8.5" +} \ No newline at end of file diff --git a/sdk/resourcemanager/attestation/armattestation/time_rfc3339.go b/sdk/resourcemanager/attestation/armattestation/time_rfc3339.go index d9fff000b5f0..dc8af0c7fece 100644 --- a/sdk/resourcemanager/attestation/armattestation/time_rfc3339.go +++ b/sdk/resourcemanager/attestation/armattestation/time_rfc3339.go @@ -1,10 +1,6 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armattestation @@ -19,12 +15,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 +40,36 @@ 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) { + if len(data) == 0 { + return nil + } + 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 +80,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 +97,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/attestation/armattestation/tsp-location.yaml b/sdk/resourcemanager/attestation/armattestation/tsp-location.yaml new file mode 100644 index 000000000000..a59160c925a7 --- /dev/null +++ b/sdk/resourcemanager/attestation/armattestation/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/attestation/resource-manager/Microsoft.Attestation/Attestation +commit: baa05d0899d6b74a4d32cdcae6be6f3e24b26952 +repo: i-specs +additionalDirectories: diff --git a/sdk/resourcemanager/attestation/armattestation/version.go b/sdk/resourcemanager/attestation/armattestation/version.go new file mode 100644 index 000000000000..ae4bb80b097b --- /dev/null +++ b/sdk/resourcemanager/attestation/armattestation/version.go @@ -0,0 +1,10 @@ +// 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) Go Code Generator. + +package armattestation + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/attestation/armattestation" + moduleVersion = "v2.0.0" +)