From e62df235d53b91152fd7b41a0e8e65727eb0c725 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 8 Apr 2021 08:20:09 +0000 Subject: [PATCH] CodeGen from PR 13646 in Azure/azure-rest-api-specs Add Microsoft.M365SecurityAndCompliance RP (#13646) * Add Microsoft.M365SecurityAndCompliance RP * fix datetime and common-types file path * update common-types file path * add preview path in readmego * replace stable with preview * remove duplicate tags * refer MIPPolicySync json in readme --- .../m365securityandcompliance/CHANGELOG.md | 5 + .../m365securityandcompliance/client.go | 42 + .../m365securityandcompliance/enums.go | 160 + .../interfaces.go | 231 ++ .../m365securityandcompliance/models.go | 3471 +++++++++++++++++ .../operationresults.go | 108 + .../m365securityandcompliance/operations.go | 140 + .../privateendpointconnectionsadtapi.go | 441 +++ .../privateendpointconnectionscomp.go | 441 +++ .../privateendpointconnectionsforedm.go | 441 +++ ...vateendpointconnectionsformippolicysync.go | 442 +++ ...vateendpointconnectionsforsccpowershell.go | 442 +++ .../privateendpointconnectionssec.go | 441 +++ .../privatelinkresources.go | 209 + .../privatelinkresourcesadtapi.go | 209 + .../privatelinkresourcescomp.go | 209 + .../privatelinkresourcesformippolicysync.go | 210 + .../privatelinkresourcesforsccpowershell.go | 210 + .../privatelinkresourcessec.go | 209 + .../privatelinkservicesforedmupload.go | 556 +++ ...vatelinkservicesform365compliancecenter.go | 645 +++ ...rivatelinkservicesform365securitycenter.go | 645 +++ .../privatelinkservicesformippolicysync.go | 645 +++ ...inkservicesforo365managementactivityapi.go | 645 +++ .../privatelinkservicesforsccpowershell.go | 645 +++ .../m365securityandcompliance/services.go | 120 + .../m365securityandcompliance/version.go | 19 + 27 files changed, 11981 insertions(+) create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/CHANGELOG.md create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/client.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/enums.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/m365securityandcomplianceapi/interfaces.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/models.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/operationresults.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/operations.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsadtapi.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionscomp.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsforedm.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsformippolicysync.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsforsccpowershell.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionssec.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresources.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesadtapi.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcescomp.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesformippolicysync.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesforsccpowershell.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcessec.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforedmupload.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesform365compliancecenter.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesform365securitycenter.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesformippolicysync.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforo365managementactivityapi.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforsccpowershell.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/services.go create mode 100644 services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/version.go diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/CHANGELOG.md b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/CHANGELOG.md new file mode 100644 index 000000000000..ce47fc66c161 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/CHANGELOG.md @@ -0,0 +1,5 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/7e3bf6306c5ffd00b97a93870945fa5debd873af/specification/m365securityandcompliance/resource-manager/readme.md tag: `package-2021-03-25-preview` + +Code generator + + diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/client.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/client.go new file mode 100644 index 000000000000..cd4bf5d66a60 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/client.go @@ -0,0 +1,42 @@ +// Package m365securityandcompliance implements the Azure ARM M365securityandcompliance service API version +// 2021-03-25-preview. +// +// Security And Compliance Client +package m365securityandcompliance + +// 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service M365securityandcompliance + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for M365securityandcompliance. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/enums.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/enums.go new file mode 100644 index 000000000000..7a02af5d151e --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/enums.go @@ -0,0 +1,160 @@ +package m365securityandcompliance + +// 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. + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// Kind enumerates the values for kind. +type Kind string + +const ( + // Fhir ... + Fhir Kind = "fhir" + // FhirR4 ... + FhirR4 Kind = "fhir-R4" + // FhirStu3 ... + FhirStu3 Kind = "fhir-Stu3" +) + +// PossibleKindValues returns an array of possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{Fhir, FhirR4, FhirStu3} +} + +// ManagedServiceIdentityType enumerates the values for managed service identity type. +type ManagedServiceIdentityType string + +const ( + // None ... + None ManagedServiceIdentityType = "None" + // SystemAssigned ... + SystemAssigned ManagedServiceIdentityType = "SystemAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns an array of possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{None, SystemAssigned} +} + +// OperationResultStatus enumerates the values for operation result status. +type OperationResultStatus string + +const ( + // Canceled ... + Canceled OperationResultStatus = "Canceled" + // Failed ... + Failed OperationResultStatus = "Failed" + // Requested ... + Requested OperationResultStatus = "Requested" + // Running ... + Running OperationResultStatus = "Running" + // Succeeded ... + Succeeded OperationResultStatus = "Succeeded" +) + +// PossibleOperationResultStatusValues returns an array of possible values for the OperationResultStatus const type. +func PossibleOperationResultStatusValues() []OperationResultStatus { + return []OperationResultStatus{Canceled, Failed, Requested, Running, Succeeded} +} + +// PrivateEndpointConnectionProvisioningState enumerates the values for private endpoint connection +// provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + // PrivateEndpointConnectionProvisioningStateCreating ... + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + // PrivateEndpointConnectionProvisioningStateDeleting ... + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + // PrivateEndpointConnectionProvisioningStateFailed ... + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + // PrivateEndpointConnectionProvisioningStateSucceeded ... + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns an array of possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{PrivateEndpointConnectionProvisioningStateCreating, PrivateEndpointConnectionProvisioningStateDeleting, PrivateEndpointConnectionProvisioningStateFailed, PrivateEndpointConnectionProvisioningStateSucceeded} +} + +// PrivateEndpointServiceConnectionStatus enumerates the values for private endpoint service connection status. +type PrivateEndpointServiceConnectionStatus string + +const ( + // Approved ... + Approved PrivateEndpointServiceConnectionStatus = "Approved" + // Pending ... + Pending PrivateEndpointServiceConnectionStatus = "Pending" + // Rejected ... + Rejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateEndpointServiceConnectionStatusValues returns an array of possible values for the PrivateEndpointServiceConnectionStatus const type. +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{Approved, Pending, Rejected} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted ... + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating ... + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateDeprovisioned ... + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateVerifying ... + ProvisioningStateVerifying ProvisioningState = "Verifying" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateAccepted, ProvisioningStateCanceled, ProvisioningStateCreating, ProvisioningStateDeleting, ProvisioningStateDeprovisioned, ProvisioningStateFailed, ProvisioningStateSucceeded, ProvisioningStateUpdating, ProvisioningStateVerifying} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // Disabled ... + Disabled PublicNetworkAccess = "Disabled" + // Enabled ... + Enabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{Disabled, Enabled} +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/m365securityandcomplianceapi/interfaces.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/m365securityandcomplianceapi/interfaces.go new file mode 100644 index 000000000000..cf2cda545380 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/m365securityandcomplianceapi/interfaces.go @@ -0,0 +1,231 @@ +package m365securityandcomplianceapi + +// 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result m365securityandcompliance.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result m365securityandcompliance.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*m365securityandcompliance.OperationsClient)(nil) + +// OperationResultsClientAPI contains the set of methods on the OperationResultsClient type. +type OperationResultsClientAPI interface { + Get(ctx context.Context, locationName string, operationResultID string) (result m365securityandcompliance.OperationResultsDescription, err error) +} + +var _ OperationResultsClientAPI = (*m365securityandcompliance.OperationResultsClient)(nil) + +// PrivateLinkServicesForEDMUploadClientAPI contains the set of methods on the PrivateLinkServicesForEDMUploadClient type. +type PrivateLinkServicesForEDMUploadClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForEDMUploadDescription m365securityandcompliance.PrivateLinkServicesForEDMUploadDescription) (result m365securityandcompliance.PrivateLinkServicesForEDMUploadCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForEDMUploadDescription, err error) + List(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForEDMUploadDescriptionListResultPage, err error) + ListComplete(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForEDMUploadDescriptionListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForEDMUploadDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForEDMUploadDescriptionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription m365securityandcompliance.ServicesPatchDescription) (result m365securityandcompliance.PrivateLinkServicesForEDMUploadUpdateFuture, err error) +} + +var _ PrivateLinkServicesForEDMUploadClientAPI = (*m365securityandcompliance.PrivateLinkServicesForEDMUploadClient)(nil) + +// ServicesClientAPI contains the set of methods on the ServicesClient type. +type ServicesClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.ServicesDeleteFuture, err error) +} + +var _ ServicesClientAPI = (*m365securityandcompliance.ServicesClient)(nil) + +// PrivateEndpointConnectionsForEDMClientAPI contains the set of methods on the PrivateEndpointConnectionsForEDMClient type. +type PrivateEndpointConnectionsForEDMClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties m365securityandcompliance.PrivateEndpointConnection) (result m365securityandcompliance.PrivateEndpointConnectionsForEDMCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnectionsForEDMDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnection, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsForEDMClientAPI = (*m365securityandcompliance.PrivateEndpointConnectionsForEDMClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result m365securityandcompliance.PrivateLinkResource, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*m365securityandcompliance.PrivateLinkResourcesClient)(nil) + +// PrivateLinkServicesForM365ComplianceCenterClientAPI contains the set of methods on the PrivateLinkServicesForM365ComplianceCenterClient type. +type PrivateLinkServicesForM365ComplianceCenterClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForM365ComplianceCenterDescription m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDescription) (result m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDescription, err error) + List(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage, err error) + ListComplete(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription m365securityandcompliance.ServicesPatchDescription) (result m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterUpdateFuture, err error) +} + +var _ PrivateLinkServicesForM365ComplianceCenterClientAPI = (*m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient)(nil) + +// PrivateEndpointConnectionsCompClientAPI contains the set of methods on the PrivateEndpointConnectionsCompClient type. +type PrivateEndpointConnectionsCompClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties m365securityandcompliance.PrivateEndpointConnection) (result m365securityandcompliance.PrivateEndpointConnectionsCompCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnectionsCompDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnection, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsCompClientAPI = (*m365securityandcompliance.PrivateEndpointConnectionsCompClient)(nil) + +// PrivateLinkResourcesCompClientAPI contains the set of methods on the PrivateLinkResourcesCompClient type. +type PrivateLinkResourcesCompClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result m365securityandcompliance.PrivateLinkResource, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesCompClientAPI = (*m365securityandcompliance.PrivateLinkResourcesCompClient)(nil) + +// PrivateLinkServicesForM365SecurityCenterClientAPI contains the set of methods on the PrivateLinkServicesForM365SecurityCenterClient type. +type PrivateLinkServicesForM365SecurityCenterClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForM365SecurityCenterDescription m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDescription) (result m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDescription, err error) + List(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage, err error) + ListComplete(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription m365securityandcompliance.ServicesPatchDescription) (result m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterUpdateFuture, err error) +} + +var _ PrivateLinkServicesForM365SecurityCenterClientAPI = (*m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient)(nil) + +// PrivateEndpointConnectionsSecClientAPI contains the set of methods on the PrivateEndpointConnectionsSecClient type. +type PrivateEndpointConnectionsSecClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties m365securityandcompliance.PrivateEndpointConnection) (result m365securityandcompliance.PrivateEndpointConnectionsSecCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnectionsSecDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnection, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsSecClientAPI = (*m365securityandcompliance.PrivateEndpointConnectionsSecClient)(nil) + +// PrivateLinkResourcesSecClientAPI contains the set of methods on the PrivateLinkResourcesSecClient type. +type PrivateLinkResourcesSecClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result m365securityandcompliance.PrivateLinkResource, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesSecClientAPI = (*m365securityandcompliance.PrivateLinkResourcesSecClient)(nil) + +// PrivateLinkServicesForO365ManagementActivityAPIClientAPI contains the set of methods on the PrivateLinkServicesForO365ManagementActivityAPIClient type. +type PrivateLinkServicesForO365ManagementActivityAPIClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForO365ManagementActivityAPIDescription m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDescription) (result m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDescription, err error) + List(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage, err error) + ListComplete(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription m365securityandcompliance.ServicesPatchDescription) (result m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture, err error) +} + +var _ PrivateLinkServicesForO365ManagementActivityAPIClientAPI = (*m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient)(nil) + +// PrivateEndpointConnectionsAdtAPIClientAPI contains the set of methods on the PrivateEndpointConnectionsAdtAPIClient type. +type PrivateEndpointConnectionsAdtAPIClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties m365securityandcompliance.PrivateEndpointConnection) (result m365securityandcompliance.PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnectionsAdtAPIDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnection, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsAdtAPIClientAPI = (*m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient)(nil) + +// PrivateLinkResourcesAdtAPIClientAPI contains the set of methods on the PrivateLinkResourcesAdtAPIClient type. +type PrivateLinkResourcesAdtAPIClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result m365securityandcompliance.PrivateLinkResource, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesAdtAPIClientAPI = (*m365securityandcompliance.PrivateLinkResourcesAdtAPIClient)(nil) + +// PrivateLinkServicesForSCCPowershellClientAPI contains the set of methods on the PrivateLinkServicesForSCCPowershellClient type. +type PrivateLinkServicesForSCCPowershellClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForSCCPowershellDescription m365securityandcompliance.PrivateLinkServicesForSCCPowershellDescription) (result m365securityandcompliance.PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForSCCPowershellDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForSCCPowershellDescription, err error) + List(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForSCCPowershellDescriptionListResultPage, err error) + ListComplete(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForSCCPowershellDescriptionListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForSCCPowershellDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForSCCPowershellDescriptionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription m365securityandcompliance.ServicesPatchDescription) (result m365securityandcompliance.PrivateLinkServicesForSCCPowershellUpdateFuture, err error) +} + +var _ PrivateLinkServicesForSCCPowershellClientAPI = (*m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient)(nil) + +// PrivateEndpointConnectionsForSCCPowershellClientAPI contains the set of methods on the PrivateEndpointConnectionsForSCCPowershellClient type. +type PrivateEndpointConnectionsForSCCPowershellClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties m365securityandcompliance.PrivateEndpointConnection) (result m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnection, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsForSCCPowershellClientAPI = (*m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient)(nil) + +// PrivateLinkResourcesForSCCPowershellClientAPI contains the set of methods on the PrivateLinkResourcesForSCCPowershellClient type. +type PrivateLinkResourcesForSCCPowershellClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result m365securityandcompliance.PrivateLinkResource, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesForSCCPowershellClientAPI = (*m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient)(nil) + +// PrivateLinkServicesForMIPPolicySyncClientAPI contains the set of methods on the PrivateLinkServicesForMIPPolicySyncClient type. +type PrivateLinkServicesForMIPPolicySyncClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForMIPPolicySyncDescription m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDescription) (result m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDescription, err error) + List(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage, err error) + ListComplete(ctx context.Context) (result m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription m365securityandcompliance.ServicesPatchDescription) (result m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncUpdateFuture, err error) +} + +var _ PrivateLinkServicesForMIPPolicySyncClientAPI = (*m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient)(nil) + +// PrivateEndpointConnectionsForMIPPolicySyncClientAPI contains the set of methods on the PrivateEndpointConnectionsForMIPPolicySyncClient type. +type PrivateEndpointConnectionsForMIPPolicySyncClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties m365securityandcompliance.PrivateEndpointConnection) (result m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result m365securityandcompliance.PrivateEndpointConnection, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsForMIPPolicySyncClientAPI = (*m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient)(nil) + +// PrivateLinkResourcesForMIPPolicySyncClientAPI contains the set of methods on the PrivateLinkResourcesForMIPPolicySyncClient type. +type PrivateLinkResourcesForMIPPolicySyncClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result m365securityandcompliance.PrivateLinkResource, err error) + ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result m365securityandcompliance.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesForMIPPolicySyncClientAPI = (*m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient)(nil) diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/models.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/models.go new file mode 100644 index 000000000000..c94e0dbb40a2 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/models.go @@ -0,0 +1,3471 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance" + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// ErrorDetails error details. +type ErrorDetails struct { + // Error - Object containing error details. + Error *ErrorDetailsInternal `json:"error,omitempty"` +} + +// ErrorDetailsInternal error details. +type ErrorDetailsInternal struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The target of the particular error. + Target *string `json:"target,omitempty"` +} + +// Operation service REST API operation. +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} + Name *string `json:"name,omitempty"` + // IsDataAction - READ-ONLY; Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Origin - READ-ONLY; Default value is 'user,system'. + Origin *string `json:"origin,omitempty"` + // Display - READ-ONLY; The information displayed about the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft.M365SecurityAndCompliance + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource Type: Services + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Name of the operation + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Friendly description for the operation, + Description *string `json:"description,omitempty"` +} + +// OperationListResult a list of service operations. It contains a list of operations and a URL link to get +// the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // NextLink - READ-ONLY; The link used to get the next page of service description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - READ-ONLY; A list of service operations supported by the Microsoft.M365SecurityAndCompliance resource provider. + Value *[]Operation `json:"value,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OperationResultsDescription the properties indicating the operation result of an operation on a service. +type OperationResultsDescription struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The ID of the operation returned. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the operation result. + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; The status of the operation being performed. Possible values include: 'Canceled', 'Succeeded', 'Failed', 'Requested', 'Running' + Status OperationResultStatus `json:"status,omitempty"` + // StartTime - READ-ONLY; The time that the operation was started. + StartTime *string `json:"startTime,omitempty"` + // Properties - Additional properties of the operation result. + Properties interface{} `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationResultsDescription. +func (ord OperationResultsDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ord.Properties != nil { + objectMap["properties"] = ord.Properties + } + return json.Marshal(objectMap) +} + +// PrivateEndpoint the Private Endpoint resource. +type PrivateEndpoint struct { + // ID - READ-ONLY; The ARM identifier for Private Endpoint + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointConnection the Private Endpoint Connection resource. +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.SystemData != nil { + objectMap["systemData"] = pec.SystemData + } + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + pec.SystemData = &systemData + } + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult list of private endpoint connection associated with the specified +// storage account +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - Array of private endpoint connections + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // NextLink - READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionListResult. +func (peclr PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if peclr.Value != nil { + objectMap["value"] = peclr.Value + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionListResultIterator provides access to a complete listing of +// PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultIterator struct { + i int + page PrivateEndpointConnectionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListResultIterator type. +func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator { + return PrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool { + return peclr.Value == nil || len(*peclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool { + return peclr.NextLink != nil && len(*peclr.NextLink) != 0 +} + +// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !peclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(peclr.NextLink))) +} + +// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultPage struct { + fn func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error) + peclr PrivateEndpointConnectionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.peclr) + if err != nil { + return err + } + page.peclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.peclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult { + return page.peclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection { + if page.peclr.IsEmpty() { + return nil + } + return *page.peclr.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListResultPage type. +func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage { + return PrivateEndpointConnectionListResultPage{ + fn: getNextPage, + peclr: cur, + } +} + +// PrivateEndpointConnectionProperties properties of the PrivateEndpointConnectProperties. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - The resource of private end point. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer and provider. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - The provisioning state of the private endpoint connection resource. Possible values include: 'PrivateEndpointConnectionProvisioningStateSucceeded', 'PrivateEndpointConnectionProvisioningStateCreating', 'PrivateEndpointConnectionProvisioningStateDeleting', 'PrivateEndpointConnectionProvisioningStateFailed' + ProvisioningState PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} + +// PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsAdtAPIClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture) result(client PrivateEndpointConnectionsAdtAPIClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsAdtAPIDeleteFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type PrivateEndpointConnectionsAdtAPIDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsAdtAPIClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsAdtAPIDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsAdtAPIDeleteFuture.Result. +func (future *PrivateEndpointConnectionsAdtAPIDeleteFuture) result(client PrivateEndpointConnectionsAdtAPIClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsAdtAPIDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointConnectionsCompCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateEndpointConnectionsCompCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsCompClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCompCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsCompCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCompCreateOrUpdateFuture) result(client PrivateEndpointConnectionsCompClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsCompCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsCompDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsCompDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsCompClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCompDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsCompDeleteFuture.Result. +func (future *PrivateEndpointConnectionsCompDeleteFuture) result(client PrivateEndpointConnectionsCompClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsCompDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointConnectionsForEDMCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateEndpointConnectionsForEDMCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsForEDMClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsForEDMCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsForEDMCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsForEDMCreateOrUpdateFuture) result(client PrivateEndpointConnectionsForEDMClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsForEDMCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsForEDMDeleteFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type PrivateEndpointConnectionsForEDMDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsForEDMClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsForEDMDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsForEDMDeleteFuture.Result. +func (future *PrivateEndpointConnectionsForEDMDeleteFuture) result(client PrivateEndpointConnectionsForEDMClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsForEDMDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsForMIPPolicySyncClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture) result(client PrivateEndpointConnectionsForMIPPolicySyncClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsForMIPPolicySyncClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture.Result. +func (future *PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture) result(client PrivateEndpointConnectionsForMIPPolicySyncClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsForSCCPowershellClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture) result(client PrivateEndpointConnectionsForSCCPowershellClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsForSCCPowershellDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateEndpointConnectionsForSCCPowershellDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsForSCCPowershellClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsForSCCPowershellDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsForSCCPowershellDeleteFuture.Result. +func (future *PrivateEndpointConnectionsForSCCPowershellDeleteFuture) result(client PrivateEndpointConnectionsForSCCPowershellClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointConnectionsSecCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateEndpointConnectionsSecCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsSecClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsSecCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsSecCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsSecCreateOrUpdateFuture) result(client PrivateEndpointConnectionsSecClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsSecCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsSecDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsSecDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsSecClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsSecDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsSecDeleteFuture.Result. +func (future *PrivateEndpointConnectionsSecDeleteFuture) result(client PrivateEndpointConnectionsSecClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateEndpointConnectionsSecDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // PrivateLinkResourceProperties - Resource properties. + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.SystemData != nil { + objectMap["systemData"] = plr.SystemData + } + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + plr.SystemData = &systemData + } + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceListResult a list of private link resources +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - Array of private link resources + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceListResult. +func (plrlr PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plrlr.Value != nil { + objectMap["value"] = plrlr.Value + } + return json.Marshal(objectMap) +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - The private link resource Private link DNS zone name. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plrp.RequiredZoneNames != nil { + objectMap["requiredZoneNames"] = plrp.RequiredZoneNames + } + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionState a collection of information about the state of the connection between +// service consumer and provider. +type PrivateLinkServiceConnectionState struct { + // Status - Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Possible values include: 'Pending', 'Approved', 'Rejected' + Status PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` + // Description - The reason for approval/rejection of the connection. + Description *string `json:"description,omitempty"` + // ActionsRequired - A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// PrivateLinkServicesForEDMUploadCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateLinkServicesForEDMUploadCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForEDMUploadClient) (PrivateLinkServicesForEDMUploadDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForEDMUploadCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForEDMUploadCreateOrUpdateFuture.Result. +func (future *PrivateLinkServicesForEDMUploadCreateOrUpdateFuture) result(client PrivateLinkServicesForEDMUploadClient) (plsfeud PrivateLinkServicesForEDMUploadDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForEDMUploadCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfeud.Response.Response, err = future.GetResult(sender); err == nil && plsfeud.Response.Response.StatusCode != http.StatusNoContent { + plsfeud, err = client.CreateOrUpdateResponder(plsfeud.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadCreateOrUpdateFuture", "Result", plsfeud.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForEDMUploadDescription the description of the service. +type PrivateLinkServicesForEDMUploadDescription struct { + autorest.Response `json:"-"` + // Properties - The common properties of a service. + Properties *ServicesProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // Kind - The kind of the service. Possible values include: 'Fhir', 'FhirStu3', 'FhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForEDMUploadDescription. +func (plsfeud PrivateLinkServicesForEDMUploadDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfeud.Properties != nil { + objectMap["properties"] = plsfeud.Properties + } + if plsfeud.SystemData != nil { + objectMap["systemData"] = plsfeud.SystemData + } + if plsfeud.Kind != "" { + objectMap["kind"] = plsfeud.Kind + } + if plsfeud.Location != nil { + objectMap["location"] = plsfeud.Location + } + if plsfeud.Tags != nil { + objectMap["tags"] = plsfeud.Tags + } + if plsfeud.Etag != nil { + objectMap["etag"] = plsfeud.Etag + } + if plsfeud.Identity != nil { + objectMap["identity"] = plsfeud.Identity + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForEDMUploadDescriptionListResult a list of service description objects with a next +// link. +type PrivateLinkServicesForEDMUploadDescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - READ-ONLY; The link used to get the next page of service description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of service description objects. + Value *[]PrivateLinkServicesForEDMUploadDescription `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForEDMUploadDescriptionListResult. +func (plsfeudlr PrivateLinkServicesForEDMUploadDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfeudlr.Value != nil { + objectMap["value"] = plsfeudlr.Value + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForEDMUploadDescriptionListResultIterator provides access to a complete listing of +// PrivateLinkServicesForEDMUploadDescription values. +type PrivateLinkServicesForEDMUploadDescriptionListResultIterator struct { + i int + page PrivateLinkServicesForEDMUploadDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkServicesForEDMUploadDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkServicesForEDMUploadDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkServicesForEDMUploadDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkServicesForEDMUploadDescriptionListResultIterator) Response() PrivateLinkServicesForEDMUploadDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkServicesForEDMUploadDescriptionListResultIterator) Value() PrivateLinkServicesForEDMUploadDescription { + if !iter.page.NotDone() { + return PrivateLinkServicesForEDMUploadDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkServicesForEDMUploadDescriptionListResultIterator type. +func NewPrivateLinkServicesForEDMUploadDescriptionListResultIterator(page PrivateLinkServicesForEDMUploadDescriptionListResultPage) PrivateLinkServicesForEDMUploadDescriptionListResultIterator { + return PrivateLinkServicesForEDMUploadDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plsfeudlr PrivateLinkServicesForEDMUploadDescriptionListResult) IsEmpty() bool { + return plsfeudlr.Value == nil || len(*plsfeudlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plsfeudlr PrivateLinkServicesForEDMUploadDescriptionListResult) hasNextLink() bool { + return plsfeudlr.NextLink != nil && len(*plsfeudlr.NextLink) != 0 +} + +// privateLinkServicesForEDMUploadDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plsfeudlr PrivateLinkServicesForEDMUploadDescriptionListResult) privateLinkServicesForEDMUploadDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plsfeudlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plsfeudlr.NextLink))) +} + +// PrivateLinkServicesForEDMUploadDescriptionListResultPage contains a page of +// PrivateLinkServicesForEDMUploadDescription values. +type PrivateLinkServicesForEDMUploadDescriptionListResultPage struct { + fn func(context.Context, PrivateLinkServicesForEDMUploadDescriptionListResult) (PrivateLinkServicesForEDMUploadDescriptionListResult, error) + plsfeudlr PrivateLinkServicesForEDMUploadDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkServicesForEDMUploadDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plsfeudlr) + if err != nil { + return err + } + page.plsfeudlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkServicesForEDMUploadDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkServicesForEDMUploadDescriptionListResultPage) NotDone() bool { + return !page.plsfeudlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkServicesForEDMUploadDescriptionListResultPage) Response() PrivateLinkServicesForEDMUploadDescriptionListResult { + return page.plsfeudlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkServicesForEDMUploadDescriptionListResultPage) Values() []PrivateLinkServicesForEDMUploadDescription { + if page.plsfeudlr.IsEmpty() { + return nil + } + return *page.plsfeudlr.Value +} + +// Creates a new instance of the PrivateLinkServicesForEDMUploadDescriptionListResultPage type. +func NewPrivateLinkServicesForEDMUploadDescriptionListResultPage(cur PrivateLinkServicesForEDMUploadDescriptionListResult, getNextPage func(context.Context, PrivateLinkServicesForEDMUploadDescriptionListResult) (PrivateLinkServicesForEDMUploadDescriptionListResult, error)) PrivateLinkServicesForEDMUploadDescriptionListResultPage { + return PrivateLinkServicesForEDMUploadDescriptionListResultPage{ + fn: getNextPage, + plsfeudlr: cur, + } +} + +// PrivateLinkServicesForEDMUploadUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type PrivateLinkServicesForEDMUploadUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForEDMUploadClient) (PrivateLinkServicesForEDMUploadDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForEDMUploadUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForEDMUploadUpdateFuture.Result. +func (future *PrivateLinkServicesForEDMUploadUpdateFuture) result(client PrivateLinkServicesForEDMUploadClient) (plsfeud PrivateLinkServicesForEDMUploadDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForEDMUploadUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfeud.Response.Response, err = future.GetResult(sender); err == nil && plsfeud.Response.Response.StatusCode != http.StatusNoContent { + plsfeud, err = client.UpdateResponder(plsfeud.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadUpdateFuture", "Result", plsfeud.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForM365ComplianceCenterClient) (PrivateLinkServicesForM365ComplianceCenterDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture.Result. +func (future *PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture) result(client PrivateLinkServicesForM365ComplianceCenterClient) (plsfmccd PrivateLinkServicesForM365ComplianceCenterDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfmccd.Response.Response, err = future.GetResult(sender); err == nil && plsfmccd.Response.Response.StatusCode != http.StatusNoContent { + plsfmccd, err = client.CreateOrUpdateResponder(plsfmccd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture", "Result", plsfmccd.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForM365ComplianceCenterDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateLinkServicesForM365ComplianceCenterDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForM365ComplianceCenterClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForM365ComplianceCenterDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForM365ComplianceCenterDeleteFuture.Result. +func (future *PrivateLinkServicesForM365ComplianceCenterDeleteFuture) result(client PrivateLinkServicesForM365ComplianceCenterClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkServicesForM365ComplianceCenterDescription the description of the service. +type PrivateLinkServicesForM365ComplianceCenterDescription struct { + autorest.Response `json:"-"` + // Properties - The common properties of a service. + Properties *ServicesProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // Kind - The kind of the service. Possible values include: 'Fhir', 'FhirStu3', 'FhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForM365ComplianceCenterDescription. +func (plsfmccd PrivateLinkServicesForM365ComplianceCenterDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfmccd.Properties != nil { + objectMap["properties"] = plsfmccd.Properties + } + if plsfmccd.SystemData != nil { + objectMap["systemData"] = plsfmccd.SystemData + } + if plsfmccd.Kind != "" { + objectMap["kind"] = plsfmccd.Kind + } + if plsfmccd.Location != nil { + objectMap["location"] = plsfmccd.Location + } + if plsfmccd.Tags != nil { + objectMap["tags"] = plsfmccd.Tags + } + if plsfmccd.Etag != nil { + objectMap["etag"] = plsfmccd.Etag + } + if plsfmccd.Identity != nil { + objectMap["identity"] = plsfmccd.Identity + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForM365ComplianceCenterDescriptionListResult a list of service description objects +// with a next link. +type PrivateLinkServicesForM365ComplianceCenterDescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - READ-ONLY; The link used to get the next page of service description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of service description objects. + Value *[]PrivateLinkServicesForM365ComplianceCenterDescription `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForM365ComplianceCenterDescriptionListResult. +func (plsfmccdlr PrivateLinkServicesForM365ComplianceCenterDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfmccdlr.Value != nil { + objectMap["value"] = plsfmccdlr.Value + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator provides access to a complete +// listing of PrivateLinkServicesForM365ComplianceCenterDescription values. +type PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator struct { + i int + page PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator) Response() PrivateLinkServicesForM365ComplianceCenterDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator) Value() PrivateLinkServicesForM365ComplianceCenterDescription { + if !iter.page.NotDone() { + return PrivateLinkServicesForM365ComplianceCenterDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator type. +func NewPrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator(page PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage) PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator { + return PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plsfmccdlr PrivateLinkServicesForM365ComplianceCenterDescriptionListResult) IsEmpty() bool { + return plsfmccdlr.Value == nil || len(*plsfmccdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plsfmccdlr PrivateLinkServicesForM365ComplianceCenterDescriptionListResult) hasNextLink() bool { + return plsfmccdlr.NextLink != nil && len(*plsfmccdlr.NextLink) != 0 +} + +// privateLinkServicesForM365ComplianceCenterDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plsfmccdlr PrivateLinkServicesForM365ComplianceCenterDescriptionListResult) privateLinkServicesForM365ComplianceCenterDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plsfmccdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plsfmccdlr.NextLink))) +} + +// PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage contains a page of +// PrivateLinkServicesForM365ComplianceCenterDescription values. +type PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage struct { + fn func(context.Context, PrivateLinkServicesForM365ComplianceCenterDescriptionListResult) (PrivateLinkServicesForM365ComplianceCenterDescriptionListResult, error) + plsfmccdlr PrivateLinkServicesForM365ComplianceCenterDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plsfmccdlr) + if err != nil { + return err + } + page.plsfmccdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage) NotDone() bool { + return !page.plsfmccdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage) Response() PrivateLinkServicesForM365ComplianceCenterDescriptionListResult { + return page.plsfmccdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage) Values() []PrivateLinkServicesForM365ComplianceCenterDescription { + if page.plsfmccdlr.IsEmpty() { + return nil + } + return *page.plsfmccdlr.Value +} + +// Creates a new instance of the PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage type. +func NewPrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage(cur PrivateLinkServicesForM365ComplianceCenterDescriptionListResult, getNextPage func(context.Context, PrivateLinkServicesForM365ComplianceCenterDescriptionListResult) (PrivateLinkServicesForM365ComplianceCenterDescriptionListResult, error)) PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage { + return PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage{ + fn: getNextPage, + plsfmccdlr: cur, + } +} + +// PrivateLinkServicesForM365ComplianceCenterUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateLinkServicesForM365ComplianceCenterUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForM365ComplianceCenterClient) (PrivateLinkServicesForM365ComplianceCenterDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForM365ComplianceCenterUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForM365ComplianceCenterUpdateFuture.Result. +func (future *PrivateLinkServicesForM365ComplianceCenterUpdateFuture) result(client PrivateLinkServicesForM365ComplianceCenterClient) (plsfmccd PrivateLinkServicesForM365ComplianceCenterDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfmccd.Response.Response, err = future.GetResult(sender); err == nil && plsfmccd.Response.Response.StatusCode != http.StatusNoContent { + plsfmccd, err = client.UpdateResponder(plsfmccd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterUpdateFuture", "Result", plsfmccd.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForM365SecurityCenterClient) (PrivateLinkServicesForM365SecurityCenterDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture.Result. +func (future *PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture) result(client PrivateLinkServicesForM365SecurityCenterClient) (plsfmscd PrivateLinkServicesForM365SecurityCenterDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfmscd.Response.Response, err = future.GetResult(sender); err == nil && plsfmscd.Response.Response.StatusCode != http.StatusNoContent { + plsfmscd, err = client.CreateOrUpdateResponder(plsfmscd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture", "Result", plsfmscd.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForM365SecurityCenterDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateLinkServicesForM365SecurityCenterDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForM365SecurityCenterClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForM365SecurityCenterDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForM365SecurityCenterDeleteFuture.Result. +func (future *PrivateLinkServicesForM365SecurityCenterDeleteFuture) result(client PrivateLinkServicesForM365SecurityCenterClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkServicesForM365SecurityCenterDescription the description of the service. +type PrivateLinkServicesForM365SecurityCenterDescription struct { + autorest.Response `json:"-"` + // Properties - The common properties of a service. + Properties *ServicesProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // Kind - The kind of the service. Possible values include: 'Fhir', 'FhirStu3', 'FhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForM365SecurityCenterDescription. +func (plsfmscd PrivateLinkServicesForM365SecurityCenterDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfmscd.Properties != nil { + objectMap["properties"] = plsfmscd.Properties + } + if plsfmscd.SystemData != nil { + objectMap["systemData"] = plsfmscd.SystemData + } + if plsfmscd.Kind != "" { + objectMap["kind"] = plsfmscd.Kind + } + if plsfmscd.Location != nil { + objectMap["location"] = plsfmscd.Location + } + if plsfmscd.Tags != nil { + objectMap["tags"] = plsfmscd.Tags + } + if plsfmscd.Etag != nil { + objectMap["etag"] = plsfmscd.Etag + } + if plsfmscd.Identity != nil { + objectMap["identity"] = plsfmscd.Identity + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForM365SecurityCenterDescriptionListResult a list of service description objects with +// a next link. +type PrivateLinkServicesForM365SecurityCenterDescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - READ-ONLY; The link used to get the next page of service description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of service description objects. + Value *[]PrivateLinkServicesForM365SecurityCenterDescription `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForM365SecurityCenterDescriptionListResult. +func (plsfmscdlr PrivateLinkServicesForM365SecurityCenterDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfmscdlr.Value != nil { + objectMap["value"] = plsfmscdlr.Value + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator provides access to a complete +// listing of PrivateLinkServicesForM365SecurityCenterDescription values. +type PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator struct { + i int + page PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator) Response() PrivateLinkServicesForM365SecurityCenterDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator) Value() PrivateLinkServicesForM365SecurityCenterDescription { + if !iter.page.NotDone() { + return PrivateLinkServicesForM365SecurityCenterDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator type. +func NewPrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator(page PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage) PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator { + return PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plsfmscdlr PrivateLinkServicesForM365SecurityCenterDescriptionListResult) IsEmpty() bool { + return plsfmscdlr.Value == nil || len(*plsfmscdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plsfmscdlr PrivateLinkServicesForM365SecurityCenterDescriptionListResult) hasNextLink() bool { + return plsfmscdlr.NextLink != nil && len(*plsfmscdlr.NextLink) != 0 +} + +// privateLinkServicesForM365SecurityCenterDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plsfmscdlr PrivateLinkServicesForM365SecurityCenterDescriptionListResult) privateLinkServicesForM365SecurityCenterDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plsfmscdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plsfmscdlr.NextLink))) +} + +// PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage contains a page of +// PrivateLinkServicesForM365SecurityCenterDescription values. +type PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage struct { + fn func(context.Context, PrivateLinkServicesForM365SecurityCenterDescriptionListResult) (PrivateLinkServicesForM365SecurityCenterDescriptionListResult, error) + plsfmscdlr PrivateLinkServicesForM365SecurityCenterDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plsfmscdlr) + if err != nil { + return err + } + page.plsfmscdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage) NotDone() bool { + return !page.plsfmscdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage) Response() PrivateLinkServicesForM365SecurityCenterDescriptionListResult { + return page.plsfmscdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage) Values() []PrivateLinkServicesForM365SecurityCenterDescription { + if page.plsfmscdlr.IsEmpty() { + return nil + } + return *page.plsfmscdlr.Value +} + +// Creates a new instance of the PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage type. +func NewPrivateLinkServicesForM365SecurityCenterDescriptionListResultPage(cur PrivateLinkServicesForM365SecurityCenterDescriptionListResult, getNextPage func(context.Context, PrivateLinkServicesForM365SecurityCenterDescriptionListResult) (PrivateLinkServicesForM365SecurityCenterDescriptionListResult, error)) PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage { + return PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage{ + fn: getNextPage, + plsfmscdlr: cur, + } +} + +// PrivateLinkServicesForM365SecurityCenterUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateLinkServicesForM365SecurityCenterUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForM365SecurityCenterClient) (PrivateLinkServicesForM365SecurityCenterDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForM365SecurityCenterUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForM365SecurityCenterUpdateFuture.Result. +func (future *PrivateLinkServicesForM365SecurityCenterUpdateFuture) result(client PrivateLinkServicesForM365SecurityCenterClient) (plsfmscd PrivateLinkServicesForM365SecurityCenterDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfmscd.Response.Response, err = future.GetResult(sender); err == nil && plsfmscd.Response.Response.StatusCode != http.StatusNoContent { + plsfmscd, err = client.UpdateResponder(plsfmscd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterUpdateFuture", "Result", plsfmscd.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForMIPPolicySyncClient) (PrivateLinkServicesForMIPPolicySyncDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture.Result. +func (future *PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture) result(client PrivateLinkServicesForMIPPolicySyncClient) (plsfmpsd PrivateLinkServicesForMIPPolicySyncDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfmpsd.Response.Response, err = future.GetResult(sender); err == nil && plsfmpsd.Response.Response.StatusCode != http.StatusNoContent { + plsfmpsd, err = client.CreateOrUpdateResponder(plsfmpsd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture", "Result", plsfmpsd.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForMIPPolicySyncDeleteFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateLinkServicesForMIPPolicySyncDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForMIPPolicySyncClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForMIPPolicySyncDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForMIPPolicySyncDeleteFuture.Result. +func (future *PrivateLinkServicesForMIPPolicySyncDeleteFuture) result(client PrivateLinkServicesForMIPPolicySyncClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkServicesForMIPPolicySyncDescription the description of the service. +type PrivateLinkServicesForMIPPolicySyncDescription struct { + autorest.Response `json:"-"` + // Properties - The common properties of a service. + Properties *ServicesProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // Kind - The kind of the service. Possible values include: 'Fhir', 'FhirStu3', 'FhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForMIPPolicySyncDescription. +func (plsfmpsd PrivateLinkServicesForMIPPolicySyncDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfmpsd.Properties != nil { + objectMap["properties"] = plsfmpsd.Properties + } + if plsfmpsd.SystemData != nil { + objectMap["systemData"] = plsfmpsd.SystemData + } + if plsfmpsd.Kind != "" { + objectMap["kind"] = plsfmpsd.Kind + } + if plsfmpsd.Location != nil { + objectMap["location"] = plsfmpsd.Location + } + if plsfmpsd.Tags != nil { + objectMap["tags"] = plsfmpsd.Tags + } + if plsfmpsd.Etag != nil { + objectMap["etag"] = plsfmpsd.Etag + } + if plsfmpsd.Identity != nil { + objectMap["identity"] = plsfmpsd.Identity + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForMIPPolicySyncDescriptionListResult a list of service description objects with a +// next link. +type PrivateLinkServicesForMIPPolicySyncDescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - READ-ONLY; The link used to get the next page of service description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of service description objects. + Value *[]PrivateLinkServicesForMIPPolicySyncDescription `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForMIPPolicySyncDescriptionListResult. +func (plsfmpsdlr PrivateLinkServicesForMIPPolicySyncDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfmpsdlr.Value != nil { + objectMap["value"] = plsfmpsdlr.Value + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator provides access to a complete listing +// of PrivateLinkServicesForMIPPolicySyncDescription values. +type PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator struct { + i int + page PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator) Response() PrivateLinkServicesForMIPPolicySyncDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator) Value() PrivateLinkServicesForMIPPolicySyncDescription { + if !iter.page.NotDone() { + return PrivateLinkServicesForMIPPolicySyncDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator type. +func NewPrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator(page PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage) PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator { + return PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plsfmpsdlr PrivateLinkServicesForMIPPolicySyncDescriptionListResult) IsEmpty() bool { + return plsfmpsdlr.Value == nil || len(*plsfmpsdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plsfmpsdlr PrivateLinkServicesForMIPPolicySyncDescriptionListResult) hasNextLink() bool { + return plsfmpsdlr.NextLink != nil && len(*plsfmpsdlr.NextLink) != 0 +} + +// privateLinkServicesForMIPPolicySyncDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plsfmpsdlr PrivateLinkServicesForMIPPolicySyncDescriptionListResult) privateLinkServicesForMIPPolicySyncDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plsfmpsdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plsfmpsdlr.NextLink))) +} + +// PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage contains a page of +// PrivateLinkServicesForMIPPolicySyncDescription values. +type PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage struct { + fn func(context.Context, PrivateLinkServicesForMIPPolicySyncDescriptionListResult) (PrivateLinkServicesForMIPPolicySyncDescriptionListResult, error) + plsfmpsdlr PrivateLinkServicesForMIPPolicySyncDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plsfmpsdlr) + if err != nil { + return err + } + page.plsfmpsdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage) NotDone() bool { + return !page.plsfmpsdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage) Response() PrivateLinkServicesForMIPPolicySyncDescriptionListResult { + return page.plsfmpsdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage) Values() []PrivateLinkServicesForMIPPolicySyncDescription { + if page.plsfmpsdlr.IsEmpty() { + return nil + } + return *page.plsfmpsdlr.Value +} + +// Creates a new instance of the PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage type. +func NewPrivateLinkServicesForMIPPolicySyncDescriptionListResultPage(cur PrivateLinkServicesForMIPPolicySyncDescriptionListResult, getNextPage func(context.Context, PrivateLinkServicesForMIPPolicySyncDescriptionListResult) (PrivateLinkServicesForMIPPolicySyncDescriptionListResult, error)) PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage { + return PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage{ + fn: getNextPage, + plsfmpsdlr: cur, + } +} + +// PrivateLinkServicesForMIPPolicySyncUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateLinkServicesForMIPPolicySyncUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForMIPPolicySyncClient) (PrivateLinkServicesForMIPPolicySyncDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForMIPPolicySyncUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForMIPPolicySyncUpdateFuture.Result. +func (future *PrivateLinkServicesForMIPPolicySyncUpdateFuture) result(client PrivateLinkServicesForMIPPolicySyncClient) (plsfmpsd PrivateLinkServicesForMIPPolicySyncDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfmpsd.Response.Response, err = future.GetResult(sender); err == nil && plsfmpsd.Response.Response.StatusCode != http.StatusNoContent { + plsfmpsd, err = client.UpdateResponder(plsfmpsd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncUpdateFuture", "Result", plsfmpsd.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForO365ManagementActivityAPIClient) (PrivateLinkServicesForO365ManagementActivityAPIDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture.Result. +func (future *PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture) result(client PrivateLinkServicesForO365ManagementActivityAPIClient) (plsfomaad PrivateLinkServicesForO365ManagementActivityAPIDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfomaad.Response.Response, err = future.GetResult(sender); err == nil && plsfomaad.Response.Response.StatusCode != http.StatusNoContent { + plsfomaad, err = client.CreateOrUpdateResponder(plsfomaad.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture", "Result", plsfomaad.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForO365ManagementActivityAPIClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture.Result. +func (future *PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture) result(client PrivateLinkServicesForO365ManagementActivityAPIClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkServicesForO365ManagementActivityAPIDescription the description of the service. +type PrivateLinkServicesForO365ManagementActivityAPIDescription struct { + autorest.Response `json:"-"` + // Properties - The common properties of a service. + Properties *ServicesProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // Kind - The kind of the service. Possible values include: 'Fhir', 'FhirStu3', 'FhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForO365ManagementActivityAPIDescription. +func (plsfomaad PrivateLinkServicesForO365ManagementActivityAPIDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfomaad.Properties != nil { + objectMap["properties"] = plsfomaad.Properties + } + if plsfomaad.SystemData != nil { + objectMap["systemData"] = plsfomaad.SystemData + } + if plsfomaad.Kind != "" { + objectMap["kind"] = plsfomaad.Kind + } + if plsfomaad.Location != nil { + objectMap["location"] = plsfomaad.Location + } + if plsfomaad.Tags != nil { + objectMap["tags"] = plsfomaad.Tags + } + if plsfomaad.Etag != nil { + objectMap["etag"] = plsfomaad.Etag + } + if plsfomaad.Identity != nil { + objectMap["identity"] = plsfomaad.Identity + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult a list of service description +// objects with a next link. +type PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - READ-ONLY; The link used to get the next page of service description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of service description objects. + Value *[]PrivateLinkServicesForO365ManagementActivityAPIDescription `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult. +func (plsfomaadlr PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfomaadlr.Value != nil { + objectMap["value"] = plsfomaadlr.Value + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator provides access to a +// complete listing of PrivateLinkServicesForO365ManagementActivityAPIDescription values. +type PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator struct { + i int + page PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator) Response() PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator) Value() PrivateLinkServicesForO365ManagementActivityAPIDescription { + if !iter.page.NotDone() { + return PrivateLinkServicesForO365ManagementActivityAPIDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator type. +func NewPrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator(page PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage) PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator { + return PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plsfomaadlr PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult) IsEmpty() bool { + return plsfomaadlr.Value == nil || len(*plsfomaadlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plsfomaadlr PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult) hasNextLink() bool { + return plsfomaadlr.NextLink != nil && len(*plsfomaadlr.NextLink) != 0 +} + +// privateLinkServicesForO365ManagementActivityAPIDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plsfomaadlr PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult) privateLinkServicesForO365ManagementActivityAPIDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plsfomaadlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plsfomaadlr.NextLink))) +} + +// PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage contains a page of +// PrivateLinkServicesForO365ManagementActivityAPIDescription values. +type PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage struct { + fn func(context.Context, PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult) (PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult, error) + plsfomaadlr PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plsfomaadlr) + if err != nil { + return err + } + page.plsfomaadlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage) NotDone() bool { + return !page.plsfomaadlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage) Response() PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult { + return page.plsfomaadlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage) Values() []PrivateLinkServicesForO365ManagementActivityAPIDescription { + if page.plsfomaadlr.IsEmpty() { + return nil + } + return *page.plsfomaadlr.Value +} + +// Creates a new instance of the PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage type. +func NewPrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage(cur PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult, getNextPage func(context.Context, PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult) (PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult, error)) PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage { + return PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage{ + fn: getNextPage, + plsfomaadlr: cur, + } +} + +// PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForO365ManagementActivityAPIClient) (PrivateLinkServicesForO365ManagementActivityAPIDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture.Result. +func (future *PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture) result(client PrivateLinkServicesForO365ManagementActivityAPIClient) (plsfomaad PrivateLinkServicesForO365ManagementActivityAPIDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfomaad.Response.Response, err = future.GetResult(sender); err == nil && plsfomaad.Response.Response.StatusCode != http.StatusNoContent { + plsfomaad, err = client.UpdateResponder(plsfomaad.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture", "Result", plsfomaad.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForSCCPowershellClient) (PrivateLinkServicesForSCCPowershellDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture.Result. +func (future *PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture) result(client PrivateLinkServicesForSCCPowershellClient) (plsfspd PrivateLinkServicesForSCCPowershellDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfspd.Response.Response, err = future.GetResult(sender); err == nil && plsfspd.Response.Response.StatusCode != http.StatusNoContent { + plsfspd, err = client.CreateOrUpdateResponder(plsfspd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture", "Result", plsfspd.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkServicesForSCCPowershellDeleteFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateLinkServicesForSCCPowershellDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForSCCPowershellClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForSCCPowershellDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForSCCPowershellDeleteFuture.Result. +func (future *PrivateLinkServicesForSCCPowershellDeleteFuture) result(client PrivateLinkServicesForSCCPowershellClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForSCCPowershellDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkServicesForSCCPowershellDescription the description of the service. +type PrivateLinkServicesForSCCPowershellDescription struct { + autorest.Response `json:"-"` + // Properties - The common properties of a service. + Properties *ServicesProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // Kind - The kind of the service. Possible values include: 'Fhir', 'FhirStu3', 'FhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForSCCPowershellDescription. +func (plsfspd PrivateLinkServicesForSCCPowershellDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfspd.Properties != nil { + objectMap["properties"] = plsfspd.Properties + } + if plsfspd.SystemData != nil { + objectMap["systemData"] = plsfspd.SystemData + } + if plsfspd.Kind != "" { + objectMap["kind"] = plsfspd.Kind + } + if plsfspd.Location != nil { + objectMap["location"] = plsfspd.Location + } + if plsfspd.Tags != nil { + objectMap["tags"] = plsfspd.Tags + } + if plsfspd.Etag != nil { + objectMap["etag"] = plsfspd.Etag + } + if plsfspd.Identity != nil { + objectMap["identity"] = plsfspd.Identity + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForSCCPowershellDescriptionListResult a list of service description objects with a +// next link. +type PrivateLinkServicesForSCCPowershellDescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - READ-ONLY; The link used to get the next page of service description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of service description objects. + Value *[]PrivateLinkServicesForSCCPowershellDescription `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServicesForSCCPowershellDescriptionListResult. +func (plsfspdlr PrivateLinkServicesForSCCPowershellDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsfspdlr.Value != nil { + objectMap["value"] = plsfspdlr.Value + } + return json.Marshal(objectMap) +} + +// PrivateLinkServicesForSCCPowershellDescriptionListResultIterator provides access to a complete listing +// of PrivateLinkServicesForSCCPowershellDescription values. +type PrivateLinkServicesForSCCPowershellDescriptionListResultIterator struct { + i int + page PrivateLinkServicesForSCCPowershellDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkServicesForSCCPowershellDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkServicesForSCCPowershellDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkServicesForSCCPowershellDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkServicesForSCCPowershellDescriptionListResultIterator) Response() PrivateLinkServicesForSCCPowershellDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkServicesForSCCPowershellDescriptionListResultIterator) Value() PrivateLinkServicesForSCCPowershellDescription { + if !iter.page.NotDone() { + return PrivateLinkServicesForSCCPowershellDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkServicesForSCCPowershellDescriptionListResultIterator type. +func NewPrivateLinkServicesForSCCPowershellDescriptionListResultIterator(page PrivateLinkServicesForSCCPowershellDescriptionListResultPage) PrivateLinkServicesForSCCPowershellDescriptionListResultIterator { + return PrivateLinkServicesForSCCPowershellDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plsfspdlr PrivateLinkServicesForSCCPowershellDescriptionListResult) IsEmpty() bool { + return plsfspdlr.Value == nil || len(*plsfspdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plsfspdlr PrivateLinkServicesForSCCPowershellDescriptionListResult) hasNextLink() bool { + return plsfspdlr.NextLink != nil && len(*plsfspdlr.NextLink) != 0 +} + +// privateLinkServicesForSCCPowershellDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plsfspdlr PrivateLinkServicesForSCCPowershellDescriptionListResult) privateLinkServicesForSCCPowershellDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plsfspdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plsfspdlr.NextLink))) +} + +// PrivateLinkServicesForSCCPowershellDescriptionListResultPage contains a page of +// PrivateLinkServicesForSCCPowershellDescription values. +type PrivateLinkServicesForSCCPowershellDescriptionListResultPage struct { + fn func(context.Context, PrivateLinkServicesForSCCPowershellDescriptionListResult) (PrivateLinkServicesForSCCPowershellDescriptionListResult, error) + plsfspdlr PrivateLinkServicesForSCCPowershellDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkServicesForSCCPowershellDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plsfspdlr) + if err != nil { + return err + } + page.plsfspdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkServicesForSCCPowershellDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkServicesForSCCPowershellDescriptionListResultPage) NotDone() bool { + return !page.plsfspdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkServicesForSCCPowershellDescriptionListResultPage) Response() PrivateLinkServicesForSCCPowershellDescriptionListResult { + return page.plsfspdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkServicesForSCCPowershellDescriptionListResultPage) Values() []PrivateLinkServicesForSCCPowershellDescription { + if page.plsfspdlr.IsEmpty() { + return nil + } + return *page.plsfspdlr.Value +} + +// Creates a new instance of the PrivateLinkServicesForSCCPowershellDescriptionListResultPage type. +func NewPrivateLinkServicesForSCCPowershellDescriptionListResultPage(cur PrivateLinkServicesForSCCPowershellDescriptionListResult, getNextPage func(context.Context, PrivateLinkServicesForSCCPowershellDescriptionListResult) (PrivateLinkServicesForSCCPowershellDescriptionListResult, error)) PrivateLinkServicesForSCCPowershellDescriptionListResultPage { + return PrivateLinkServicesForSCCPowershellDescriptionListResultPage{ + fn: getNextPage, + plsfspdlr: cur, + } +} + +// PrivateLinkServicesForSCCPowershellUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateLinkServicesForSCCPowershellUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkServicesForSCCPowershellClient) (PrivateLinkServicesForSCCPowershellDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkServicesForSCCPowershellUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkServicesForSCCPowershellUpdateFuture.Result. +func (future *PrivateLinkServicesForSCCPowershellUpdateFuture) result(client PrivateLinkServicesForSCCPowershellClient) (plsfspd PrivateLinkServicesForSCCPowershellDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.PrivateLinkServicesForSCCPowershellUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if plsfspd.Response.Response, err = future.GetResult(sender); err == nil && plsfspd.Response.Response.StatusCode != http.StatusNoContent { + plsfspd, err = client.UpdateResponder(plsfspd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellUpdateFuture", "Result", plsfspd.Response.Response, "Failure responding to request") + } + } + return +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// ServiceAccessPolicyEntry an access policy entry. +type ServiceAccessPolicyEntry struct { + // ObjectID - An Azure AD object ID (User or Apps) that is allowed access to the FHIR service. + ObjectID *string `json:"objectId,omitempty"` +} + +// ServiceAuthenticationConfigurationInfo authentication configuration information +type ServiceAuthenticationConfigurationInfo struct { + // Authority - The authority url for the service + Authority *string `json:"authority,omitempty"` + // Audience - The audience url for the service + Audience *string `json:"audience,omitempty"` + // SmartProxyEnabled - If the SMART on FHIR proxy is enabled + SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` +} + +// ServiceCorsConfigurationInfo the settings for the CORS configuration of the service instance. +type ServiceCorsConfigurationInfo struct { + // Origins - The origins to be allowed via CORS. + Origins *[]string `json:"origins,omitempty"` + // Headers - The headers to be allowed via CORS. + Headers *[]string `json:"headers,omitempty"` + // Methods - The methods to be allowed via CORS. + Methods *[]string `json:"methods,omitempty"` + // MaxAge - The max age to be allowed via CORS. + MaxAge *int64 `json:"maxAge,omitempty"` + // AllowCredentials - If credentials are allowed via CORS. + AllowCredentials *bool `json:"allowCredentials,omitempty"` +} + +// ServiceCosmosDbConfigurationInfo the settings for the Cosmos DB database backing the service. +type ServiceCosmosDbConfigurationInfo struct { + // OfferThroughput - The provisioned throughput for the backing database. + OfferThroughput *int64 `json:"offerThroughput,omitempty"` + // KeyVaultKeyURI - The URI of the customer-managed key for the backing database. + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` +} + +// ServiceExportConfigurationInfo export operation configuration information +type ServiceExportConfigurationInfo struct { + // StorageAccountName - The name of the default export storage account. + StorageAccountName *string `json:"storageAccountName,omitempty"` +} + +// ServicesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServicesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServicesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServicesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServicesDeleteFuture.Result. +func (future *ServicesDeleteFuture) result(client ServicesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.ServicesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("m365securityandcompliance.ServicesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServicesPatchDescription the description of the service. +type ServicesPatchDescription struct { + // Tags - Instance tags + Tags map[string]*string `json:"tags"` + // ServicesPropertiesUpdateParameters - The properties for updating a service instance. + *ServicesPropertiesUpdateParameters `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesPatchDescription. +func (spd ServicesPatchDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spd.Tags != nil { + objectMap["tags"] = spd.Tags + } + if spd.ServicesPropertiesUpdateParameters != nil { + objectMap["properties"] = spd.ServicesPropertiesUpdateParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServicesPatchDescription struct. +func (spd *ServicesPatchDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + spd.Tags = tags + } + case "properties": + if v != nil { + var servicesPropertiesUpdateParameters ServicesPropertiesUpdateParameters + err = json.Unmarshal(*v, &servicesPropertiesUpdateParameters) + if err != nil { + return err + } + spd.ServicesPropertiesUpdateParameters = &servicesPropertiesUpdateParameters + } + } + } + + return nil +} + +// ServicesProperties the properties of a service instance. +type ServicesProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateCreating', 'ProvisioningStateAccepted', 'ProvisioningStateVerifying', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeprovisioned' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // AccessPolicies - The access policies of the service instance. + AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` + // CosmosDbConfiguration - The settings for the Cosmos DB database backing the service. + CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` + // AuthenticationConfiguration - The authentication configuration for the service instance. + AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` + // CorsConfiguration - The settings for the CORS configuration of the service instance. + CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` + // ExportConfiguration - The settings for the export operation of the service instance. + ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` + // PrivateEndpointConnections - The list of private endpoint connections that are set up for this resource. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesProperties. +func (sp ServicesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.AccessPolicies != nil { + objectMap["accessPolicies"] = sp.AccessPolicies + } + if sp.CosmosDbConfiguration != nil { + objectMap["cosmosDbConfiguration"] = sp.CosmosDbConfiguration + } + if sp.AuthenticationConfiguration != nil { + objectMap["authenticationConfiguration"] = sp.AuthenticationConfiguration + } + if sp.CorsConfiguration != nil { + objectMap["corsConfiguration"] = sp.CorsConfiguration + } + if sp.ExportConfiguration != nil { + objectMap["exportConfiguration"] = sp.ExportConfiguration + } + if sp.PrivateEndpointConnections != nil { + objectMap["privateEndpointConnections"] = sp.PrivateEndpointConnections + } + if sp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = sp.PublicNetworkAccess + } + return json.Marshal(objectMap) +} + +// ServicesPropertiesUpdateParameters the properties for updating a service instance. +type ServicesPropertiesUpdateParameters struct { + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// ServicesResource the common properties of a service. +type ServicesResource struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - Required property for system data + SystemData *SystemData `json:"systemData,omitempty"` + // Kind - The kind of the service. Possible values include: 'Fhir', 'FhirStu3', 'FhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesResource. +func (sr ServicesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.SystemData != nil { + objectMap["systemData"] = sr.SystemData + } + if sr.Kind != "" { + objectMap["kind"] = sr.Kind + } + if sr.Location != nil { + objectMap["location"] = sr.Location + } + if sr.Tags != nil { + objectMap["tags"] = sr.Tags + } + if sr.Etag != nil { + objectMap["etag"] = sr.Etag + } + if sr.Identity != nil { + objectMap["identity"] = sr.Identity + } + return json.Marshal(objectMap) +} + +// ServicesResourceIdentity setting indicating whether the service has a managed identity associated with +// it. +type ServicesResourceIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of the resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of the resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - Type of identity being specified, currently SystemAssigned and None are allowed. Possible values include: 'SystemAssigned', 'None' + Type ManagedServiceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesResourceIdentity. +func (sr ServicesResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.Type != "" { + objectMap["type"] = sr.Type + } + return json.Marshal(objectMap) +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/operationresults.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/operationresults.go new file mode 100644 index 000000000000..6e051189187f --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/operationresults.go @@ -0,0 +1,108 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationResultsClient is the security And Compliance Client +type OperationResultsClient struct { + BaseClient +} + +// NewOperationResultsClient creates an instance of the OperationResultsClient client. +func NewOperationResultsClient(subscriptionID string) OperationResultsClient { + return NewOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationResultsClientWithBaseURI creates an instance of the OperationResultsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) OperationResultsClient { + return OperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the operation result for a long running operation. +// Parameters: +// locationName - the location of the operation. +// operationResultID - the ID of the operation result to get. +func (client OperationResultsClient) Get(ctx context.Context, locationName string, operationResultID string) (result OperationResultsDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationResultsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, operationResultID) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.OperationResultsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.OperationResultsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.OperationResultsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OperationResultsClient) GetPreparer(ctx context.Context, locationName string, operationResultID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "operationResultId": autorest.Encode("path", operationResultID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.M365SecurityAndCompliance/locations/{locationName}/operationresults/{operationResultId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OperationResultsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OperationResultsClient) GetResponder(resp *http.Response) (result OperationResultsDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/operations.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/operations.go new file mode 100644 index 000000000000..7ddf8e22904d --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/operations.go @@ -0,0 +1,140 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the security And Compliance Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available M365SecurityAndCompliance REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.M365SecurityAndCompliance/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsadtapi.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsadtapi.go new file mode 100644 index 000000000000..da6848479fee --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsadtapi.go @@ -0,0 +1,441 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsAdtAPIClient is the security And Compliance Client +type PrivateEndpointConnectionsAdtAPIClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsAdtAPIClient creates an instance of the PrivateEndpointConnectionsAdtAPIClient client. +func NewPrivateEndpointConnectionsAdtAPIClient(subscriptionID string) PrivateEndpointConnectionsAdtAPIClient { + return NewPrivateEndpointConnectionsAdtAPIClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsAdtAPIClientWithBaseURI creates an instance of the +// PrivateEndpointConnectionsAdtAPIClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateEndpointConnectionsAdtAPIClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsAdtAPIClient { + return PrivateEndpointConnectionsAdtAPIClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client PrivateEndpointConnectionsAdtAPIClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsAdtAPIClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsAdtAPIClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsAdtAPIClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsAdtAPICreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsAdtAPIClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsAdtAPIClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsAdtAPIDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsAdtAPIClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsAdtAPIClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsAdtAPIClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsAdtAPIDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsAdtAPIClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsAdtAPIClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsAdtAPIClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsAdtAPIClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsAdtAPIClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsAdtAPIClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists all private endpoint connections for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateEndpointConnectionsAdtAPIClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsAdtAPIClient.ListByService") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "ListByService", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "ListByService", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateEndpointConnectionsAdtAPIClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsAdtAPIClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsAdtAPIClient) ListByServiceResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsAdtAPIClient) listByServiceNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsAdtAPIClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsAdtAPIClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsAdtAPIClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionscomp.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionscomp.go new file mode 100644 index 000000000000..e2fa3500a761 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionscomp.go @@ -0,0 +1,441 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsCompClient is the security And Compliance Client +type PrivateEndpointConnectionsCompClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsCompClient creates an instance of the PrivateEndpointConnectionsCompClient client. +func NewPrivateEndpointConnectionsCompClient(subscriptionID string) PrivateEndpointConnectionsCompClient { + return NewPrivateEndpointConnectionsCompClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsCompClientWithBaseURI creates an instance of the PrivateEndpointConnectionsCompClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewPrivateEndpointConnectionsCompClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsCompClient { + return PrivateEndpointConnectionsCompClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client PrivateEndpointConnectionsCompClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnectionsCompCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsCompClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsCompClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsCompClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsCompClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCompCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsCompClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsCompClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsCompDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsCompClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsCompClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsCompClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsCompClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsCompDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsCompClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsCompClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsCompClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsCompClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsCompClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsCompClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsCompClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists all private endpoint connections for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateEndpointConnectionsCompClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsCompClient.ListByService") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsCompClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "ListByService", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "ListByService", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateEndpointConnectionsCompClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsCompClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsCompClient) ListByServiceResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsCompClient) listByServiceNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsCompClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsCompClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsCompClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsforedm.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsforedm.go new file mode 100644 index 000000000000..5dd3f51ae40d --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsforedm.go @@ -0,0 +1,441 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsForEDMClient is the security And Compliance Client +type PrivateEndpointConnectionsForEDMClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsForEDMClient creates an instance of the PrivateEndpointConnectionsForEDMClient client. +func NewPrivateEndpointConnectionsForEDMClient(subscriptionID string) PrivateEndpointConnectionsForEDMClient { + return NewPrivateEndpointConnectionsForEDMClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsForEDMClientWithBaseURI creates an instance of the +// PrivateEndpointConnectionsForEDMClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateEndpointConnectionsForEDMClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsForEDMClient { + return PrivateEndpointConnectionsForEDMClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client PrivateEndpointConnectionsForEDMClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnectionsForEDMCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForEDMClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsForEDMClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForEDMClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsForEDMCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForEDMClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsForEDMClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsForEDMDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForEDMClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsForEDMClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForEDMClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsForEDMDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForEDMClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsForEDMClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForEDMClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsForEDMClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForEDMClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForEDMClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists all private endpoint connections for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateEndpointConnectionsForEDMClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForEDMClient.ListByService") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "ListByService", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "ListByService", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateEndpointConnectionsForEDMClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForEDMClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForEDMClient) ListByServiceResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsForEDMClient) listByServiceNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForEDMClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsForEDMClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForEDMClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsformippolicysync.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsformippolicysync.go new file mode 100644 index 000000000000..419b114b96d4 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsformippolicysync.go @@ -0,0 +1,442 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsForMIPPolicySyncClient is the security And Compliance Client +type PrivateEndpointConnectionsForMIPPolicySyncClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsForMIPPolicySyncClient creates an instance of the +// PrivateEndpointConnectionsForMIPPolicySyncClient client. +func NewPrivateEndpointConnectionsForMIPPolicySyncClient(subscriptionID string) PrivateEndpointConnectionsForMIPPolicySyncClient { + return NewPrivateEndpointConnectionsForMIPPolicySyncClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsForMIPPolicySyncClientWithBaseURI creates an instance of the +// PrivateEndpointConnectionsForMIPPolicySyncClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateEndpointConnectionsForMIPPolicySyncClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsForMIPPolicySyncClient { + return PrivateEndpointConnectionsForMIPPolicySyncClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForMIPPolicySyncClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsForMIPPolicySyncCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForMIPPolicySyncClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsForMIPPolicySyncDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForMIPPolicySyncClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists all private endpoint connections for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForMIPPolicySyncClient.ListByService") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "ListByService", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "ListByService", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) ListByServiceResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) listByServiceNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForMIPPolicySyncClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsForMIPPolicySyncClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForMIPPolicySyncClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsforsccpowershell.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsforsccpowershell.go new file mode 100644 index 000000000000..d9af3a5aaa41 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionsforsccpowershell.go @@ -0,0 +1,442 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsForSCCPowershellClient is the security And Compliance Client +type PrivateEndpointConnectionsForSCCPowershellClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsForSCCPowershellClient creates an instance of the +// PrivateEndpointConnectionsForSCCPowershellClient client. +func NewPrivateEndpointConnectionsForSCCPowershellClient(subscriptionID string) PrivateEndpointConnectionsForSCCPowershellClient { + return NewPrivateEndpointConnectionsForSCCPowershellClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsForSCCPowershellClientWithBaseURI creates an instance of the +// PrivateEndpointConnectionsForSCCPowershellClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateEndpointConnectionsForSCCPowershellClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsForSCCPowershellClient { + return PrivateEndpointConnectionsForSCCPowershellClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client PrivateEndpointConnectionsForSCCPowershellClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForSCCPowershellClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsForSCCPowershellClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForSCCPowershellClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsForSCCPowershellCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForSCCPowershellClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsForSCCPowershellClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsForSCCPowershellDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForSCCPowershellClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsForSCCPowershellClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForSCCPowershellClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsForSCCPowershellDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForSCCPowershellClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsForSCCPowershellClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForSCCPowershellClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsForSCCPowershellClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForSCCPowershellClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForSCCPowershellClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists all private endpoint connections for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateEndpointConnectionsForSCCPowershellClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForSCCPowershellClient.ListByService") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "ListByService", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "ListByService", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateEndpointConnectionsForSCCPowershellClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsForSCCPowershellClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsForSCCPowershellClient) ListByServiceResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsForSCCPowershellClient) listByServiceNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsForSCCPowershellClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsForSCCPowershellClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsForSCCPowershellClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionssec.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionssec.go new file mode 100644 index 000000000000..8dca53e7992c --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privateendpointconnectionssec.go @@ -0,0 +1,441 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsSecClient is the security And Compliance Client +type PrivateEndpointConnectionsSecClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsSecClient creates an instance of the PrivateEndpointConnectionsSecClient client. +func NewPrivateEndpointConnectionsSecClient(subscriptionID string) PrivateEndpointConnectionsSecClient { + return NewPrivateEndpointConnectionsSecClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsSecClientWithBaseURI creates an instance of the PrivateEndpointConnectionsSecClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewPrivateEndpointConnectionsSecClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsSecClient { + return PrivateEndpointConnectionsSecClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client PrivateEndpointConnectionsSecClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnectionsSecCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsSecClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsSecClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsSecClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsSecClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsSecCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsSecClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsSecClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsSecDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsSecClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsSecClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsSecClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsSecClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsSecDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsSecClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsSecClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsSecClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsSecClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsSecClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsSecClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsSecClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists all private endpoint connections for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateEndpointConnectionsSecClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsSecClient.ListByService") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateEndpointConnectionsSecClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "ListByService", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "ListByService", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateEndpointConnectionsSecClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsSecClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsSecClient) ListByServiceResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsSecClient) listByServiceNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateEndpointConnectionsSecClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsSecClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsSecClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresources.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresources.go new file mode 100644 index 000000000000..088d5c9bc4a5 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresources.go @@ -0,0 +1,209 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the security And Compliance Client +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// groupName - the name of the private link resource group. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets the private link resources that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkResourcesClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateLinkResourcesClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByServiceResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesadtapi.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesadtapi.go new file mode 100644 index 000000000000..4195fcbd98a9 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesadtapi.go @@ -0,0 +1,209 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesAdtAPIClient is the security And Compliance Client +type PrivateLinkResourcesAdtAPIClient struct { + BaseClient +} + +// NewPrivateLinkResourcesAdtAPIClient creates an instance of the PrivateLinkResourcesAdtAPIClient client. +func NewPrivateLinkResourcesAdtAPIClient(subscriptionID string) PrivateLinkResourcesAdtAPIClient { + return NewPrivateLinkResourcesAdtAPIClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesAdtAPIClientWithBaseURI creates an instance of the PrivateLinkResourcesAdtAPIClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateLinkResourcesAdtAPIClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesAdtAPIClient { + return PrivateLinkResourcesAdtAPIClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// groupName - the name of the private link resource group. +func (client PrivateLinkResourcesAdtAPIClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesAdtAPIClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesAdtAPIClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesAdtAPIClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesAdtAPIClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesAdtAPIClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesAdtAPIClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesAdtAPIClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesAdtAPIClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets the private link resources that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkResourcesAdtAPIClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesAdtAPIClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesAdtAPIClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesAdtAPIClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesAdtAPIClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesAdtAPIClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateLinkResourcesAdtAPIClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesAdtAPIClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesAdtAPIClient) ListByServiceResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcescomp.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcescomp.go new file mode 100644 index 000000000000..241915d9d406 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcescomp.go @@ -0,0 +1,209 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesCompClient is the security And Compliance Client +type PrivateLinkResourcesCompClient struct { + BaseClient +} + +// NewPrivateLinkResourcesCompClient creates an instance of the PrivateLinkResourcesCompClient client. +func NewPrivateLinkResourcesCompClient(subscriptionID string) PrivateLinkResourcesCompClient { + return NewPrivateLinkResourcesCompClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesCompClientWithBaseURI creates an instance of the PrivateLinkResourcesCompClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateLinkResourcesCompClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesCompClient { + return PrivateLinkResourcesCompClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// groupName - the name of the private link resource group. +func (client PrivateLinkResourcesCompClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesCompClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesCompClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesCompClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesCompClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesCompClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesCompClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesCompClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesCompClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets the private link resources that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkResourcesCompClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesCompClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesCompClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesCompClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesCompClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesCompClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateLinkResourcesCompClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesCompClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesCompClient) ListByServiceResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesformippolicysync.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesformippolicysync.go new file mode 100644 index 000000000000..e47df9f971da --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesformippolicysync.go @@ -0,0 +1,210 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesForMIPPolicySyncClient is the security And Compliance Client +type PrivateLinkResourcesForMIPPolicySyncClient struct { + BaseClient +} + +// NewPrivateLinkResourcesForMIPPolicySyncClient creates an instance of the PrivateLinkResourcesForMIPPolicySyncClient +// client. +func NewPrivateLinkResourcesForMIPPolicySyncClient(subscriptionID string) PrivateLinkResourcesForMIPPolicySyncClient { + return NewPrivateLinkResourcesForMIPPolicySyncClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesForMIPPolicySyncClientWithBaseURI creates an instance of the +// PrivateLinkResourcesForMIPPolicySyncClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateLinkResourcesForMIPPolicySyncClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesForMIPPolicySyncClient { + return PrivateLinkResourcesForMIPPolicySyncClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// groupName - the name of the private link resource group. +func (client PrivateLinkResourcesForMIPPolicySyncClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesForMIPPolicySyncClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesForMIPPolicySyncClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesForMIPPolicySyncClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesForMIPPolicySyncClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets the private link resources that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkResourcesForMIPPolicySyncClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesForMIPPolicySyncClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForMIPPolicySyncClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateLinkResourcesForMIPPolicySyncClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesForMIPPolicySyncClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesForMIPPolicySyncClient) ListByServiceResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesforsccpowershell.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesforsccpowershell.go new file mode 100644 index 000000000000..c1842159327e --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcesforsccpowershell.go @@ -0,0 +1,210 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesForSCCPowershellClient is the security And Compliance Client +type PrivateLinkResourcesForSCCPowershellClient struct { + BaseClient +} + +// NewPrivateLinkResourcesForSCCPowershellClient creates an instance of the PrivateLinkResourcesForSCCPowershellClient +// client. +func NewPrivateLinkResourcesForSCCPowershellClient(subscriptionID string) PrivateLinkResourcesForSCCPowershellClient { + return NewPrivateLinkResourcesForSCCPowershellClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesForSCCPowershellClientWithBaseURI creates an instance of the +// PrivateLinkResourcesForSCCPowershellClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateLinkResourcesForSCCPowershellClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesForSCCPowershellClient { + return PrivateLinkResourcesForSCCPowershellClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// groupName - the name of the private link resource group. +func (client PrivateLinkResourcesForSCCPowershellClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesForSCCPowershellClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesForSCCPowershellClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesForSCCPowershellClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesForSCCPowershellClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets the private link resources that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkResourcesForSCCPowershellClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesForSCCPowershellClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesForSCCPowershellClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateLinkResourcesForSCCPowershellClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesForSCCPowershellClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesForSCCPowershellClient) ListByServiceResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcessec.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcessec.go new file mode 100644 index 000000000000..27509d91100d --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkresourcessec.go @@ -0,0 +1,209 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesSecClient is the security And Compliance Client +type PrivateLinkResourcesSecClient struct { + BaseClient +} + +// NewPrivateLinkResourcesSecClient creates an instance of the PrivateLinkResourcesSecClient client. +func NewPrivateLinkResourcesSecClient(subscriptionID string) PrivateLinkResourcesSecClient { + return NewPrivateLinkResourcesSecClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesSecClientWithBaseURI creates an instance of the PrivateLinkResourcesSecClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewPrivateLinkResourcesSecClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesSecClient { + return PrivateLinkResourcesSecClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// groupName - the name of the private link resource group. +func (client PrivateLinkResourcesSecClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesSecClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesSecClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesSecClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesSecClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesSecClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesSecClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesSecClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesSecClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets the private link resources that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkResourcesSecClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesSecClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkResourcesSecClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesSecClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesSecClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkResourcesSecClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateLinkResourcesSecClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesSecClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesSecClient) ListByServiceResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforedmupload.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforedmupload.go new file mode 100644 index 000000000000..77a0079c53f1 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforedmupload.go @@ -0,0 +1,556 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkServicesForEDMUploadClient is the security And Compliance Client +type PrivateLinkServicesForEDMUploadClient struct { + BaseClient +} + +// NewPrivateLinkServicesForEDMUploadClient creates an instance of the PrivateLinkServicesForEDMUploadClient client. +func NewPrivateLinkServicesForEDMUploadClient(subscriptionID string) PrivateLinkServicesForEDMUploadClient { + return NewPrivateLinkServicesForEDMUploadClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkServicesForEDMUploadClientWithBaseURI creates an instance of the PrivateLinkServicesForEDMUploadClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewPrivateLinkServicesForEDMUploadClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkServicesForEDMUploadClient { + return PrivateLinkServicesForEDMUploadClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update the metadata of a privateLinkServicesForEDMUpload instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateLinkServicesForEDMUploadDescription - the service instance metadata. +func (client PrivateLinkServicesForEDMUploadClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForEDMUploadDescription PrivateLinkServicesForEDMUploadDescription) (result PrivateLinkServicesForEDMUploadCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: privateLinkServicesForEDMUploadDescription, + Constraints: []validation.Constraint{{Target: "privateLinkServicesForEDMUploadDescription.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForEDMUploadDescription.Properties.CosmosDbConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForEDMUploadDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForEDMUploadDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMaximum, Rule: int64(10000), Chain: nil}, + {Target: "privateLinkServicesForEDMUploadDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMinimum, Rule: int64(400), Chain: nil}, + }}, + }}, + {Target: "privateLinkServicesForEDMUploadDescription.Properties.CorsConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForEDMUploadDescription.Properties.CorsConfiguration.MaxAge", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForEDMUploadDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMaximum, Rule: int64(99999), Chain: nil}, + {Target: "privateLinkServicesForEDMUploadDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateLinkServicesForEDMUploadDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkServicesForEDMUploadClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForEDMUploadDescription PrivateLinkServicesForEDMUploadDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}", pathParameters), + autorest.WithJSON(privateLinkServicesForEDMUploadDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForEDMUploadClient) CreateOrUpdateSender(req *http.Request) (future PrivateLinkServicesForEDMUploadCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForEDMUploadClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateLinkServicesForEDMUploadDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the metadata of a privateLinkServicesForEDMUpload resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForEDMUploadClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForEDMUploadDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkServicesForEDMUploadClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForEDMUploadClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForEDMUploadClient) GetResponder(resp *http.Response) (result PrivateLinkServicesForEDMUploadDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the privateLinkServicesForEDMUpload instances in a subscription. +func (client PrivateLinkServicesForEDMUploadClient) List(ctx context.Context) (result PrivateLinkServicesForEDMUploadDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadClient.List") + defer func() { + sc := -1 + if result.plsfeudlr.Response.Response != nil { + sc = result.plsfeudlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plsfeudlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "List", resp, "Failure sending request") + return + } + + result.plsfeudlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "List", resp, "Failure responding to request") + return + } + if result.plsfeudlr.hasNextLink() && result.plsfeudlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkServicesForEDMUploadClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForEDMUploadClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForEDMUploadClient) ListResponder(resp *http.Response) (result PrivateLinkServicesForEDMUploadDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForEDMUploadClient) listNextResults(ctx context.Context, lastResults PrivateLinkServicesForEDMUploadDescriptionListResult) (result PrivateLinkServicesForEDMUploadDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForEDMUploadDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForEDMUploadClient) ListComplete(ctx context.Context) (result PrivateLinkServicesForEDMUploadDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup get all the service instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +func (client PrivateLinkServicesForEDMUploadClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForEDMUploadDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.plsfeudlr.Response.Response != nil { + sc = result.plsfeudlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.plsfeudlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.plsfeudlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.plsfeudlr.hasNextLink() && result.plsfeudlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PrivateLinkServicesForEDMUploadClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForEDMUploadClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForEDMUploadClient) ListByResourceGroupResponder(resp *http.Response) (result PrivateLinkServicesForEDMUploadDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForEDMUploadClient) listByResourceGroupNextResults(ctx context.Context, lastResults PrivateLinkServicesForEDMUploadDescriptionListResult) (result PrivateLinkServicesForEDMUploadDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForEDMUploadDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForEDMUploadClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForEDMUploadDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update the metadata of a privateLinkServicesForEDMUpload instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// servicePatchDescription - the service instance metadata and security metadata. +func (client PrivateLinkServicesForEDMUploadClient) Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (result PrivateLinkServicesForEDMUploadUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForEDMUploadClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, servicePatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForEDMUploadClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateLinkServicesForEDMUploadClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}", pathParameters), + autorest.WithJSON(servicePatchDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForEDMUploadClient) UpdateSender(req *http.Request) (future PrivateLinkServicesForEDMUploadUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForEDMUploadClient) UpdateResponder(resp *http.Response) (result PrivateLinkServicesForEDMUploadDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesform365compliancecenter.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesform365compliancecenter.go new file mode 100644 index 000000000000..9389e68c1143 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesform365compliancecenter.go @@ -0,0 +1,645 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkServicesForM365ComplianceCenterClient is the security And Compliance Client +type PrivateLinkServicesForM365ComplianceCenterClient struct { + BaseClient +} + +// NewPrivateLinkServicesForM365ComplianceCenterClient creates an instance of the +// PrivateLinkServicesForM365ComplianceCenterClient client. +func NewPrivateLinkServicesForM365ComplianceCenterClient(subscriptionID string) PrivateLinkServicesForM365ComplianceCenterClient { + return NewPrivateLinkServicesForM365ComplianceCenterClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkServicesForM365ComplianceCenterClientWithBaseURI creates an instance of the +// PrivateLinkServicesForM365ComplianceCenterClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateLinkServicesForM365ComplianceCenterClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkServicesForM365ComplianceCenterClient { + return PrivateLinkServicesForM365ComplianceCenterClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update the metadata of a privateLinkServicesForM365ComplianceCenter instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateLinkServicesForM365ComplianceCenterDescription - the service instance metadata. +func (client PrivateLinkServicesForM365ComplianceCenterClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForM365ComplianceCenterDescription PrivateLinkServicesForM365ComplianceCenterDescription) (result PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: privateLinkServicesForM365ComplianceCenterDescription, + Constraints: []validation.Constraint{{Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties.CosmosDbConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMaximum, Rule: int64(10000), Chain: nil}, + {Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMinimum, Rule: int64(400), Chain: nil}, + }}, + }}, + {Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties.CorsConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties.CorsConfiguration.MaxAge", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMaximum, Rule: int64(99999), Chain: nil}, + {Target: "privateLinkServicesForM365ComplianceCenterDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateLinkServicesForM365ComplianceCenterDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkServicesForM365ComplianceCenterClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForM365ComplianceCenterDescription PrivateLinkServicesForM365ComplianceCenterDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}", pathParameters), + autorest.WithJSON(privateLinkServicesForM365ComplianceCenterDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365ComplianceCenterClient) CreateOrUpdateSender(req *http.Request) (future PrivateLinkServicesForM365ComplianceCenterCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365ComplianceCenterClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateLinkServicesForM365ComplianceCenterDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForM365ComplianceCenterClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForM365ComplianceCenterDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkServicesForM365ComplianceCenterClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365ComplianceCenterClient) DeleteSender(req *http.Request) (future PrivateLinkServicesForM365ComplianceCenterDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365ComplianceCenterClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the metadata of a privateLinkServicesForM365ComplianceCenter resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForM365ComplianceCenterClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForM365ComplianceCenterDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkServicesForM365ComplianceCenterClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365ComplianceCenterClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365ComplianceCenterClient) GetResponder(resp *http.Response) (result PrivateLinkServicesForM365ComplianceCenterDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the privateLinkServicesForM365ComplianceCenter instances in a subscription. +func (client PrivateLinkServicesForM365ComplianceCenterClient) List(ctx context.Context) (result PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterClient.List") + defer func() { + sc := -1 + if result.plsfmccdlr.Response.Response != nil { + sc = result.plsfmccdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plsfmccdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "List", resp, "Failure sending request") + return + } + + result.plsfmccdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "List", resp, "Failure responding to request") + return + } + if result.plsfmccdlr.hasNextLink() && result.plsfmccdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListResponder(resp *http.Response) (result PrivateLinkServicesForM365ComplianceCenterDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForM365ComplianceCenterClient) listNextResults(ctx context.Context, lastResults PrivateLinkServicesForM365ComplianceCenterDescriptionListResult) (result PrivateLinkServicesForM365ComplianceCenterDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForM365ComplianceCenterDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListComplete(ctx context.Context) (result PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup get all the service instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForM365ComplianceCenterDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.plsfmccdlr.Response.Response != nil { + sc = result.plsfmccdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.plsfmccdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.plsfmccdlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.plsfmccdlr.hasNextLink() && result.plsfmccdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListByResourceGroupResponder(resp *http.Response) (result PrivateLinkServicesForM365ComplianceCenterDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForM365ComplianceCenterClient) listByResourceGroupNextResults(ctx context.Context, lastResults PrivateLinkServicesForM365ComplianceCenterDescriptionListResult) (result PrivateLinkServicesForM365ComplianceCenterDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForM365ComplianceCenterDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForM365ComplianceCenterClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForM365ComplianceCenterDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update the metadata of a privateLinkServicesForM365ComplianceCenter instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// servicePatchDescription - the service instance metadata and security metadata. +func (client PrivateLinkServicesForM365ComplianceCenterClient) Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (result PrivateLinkServicesForM365ComplianceCenterUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365ComplianceCenterClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, servicePatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365ComplianceCenterClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateLinkServicesForM365ComplianceCenterClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365ComplianceCenter/{resourceName}", pathParameters), + autorest.WithJSON(servicePatchDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365ComplianceCenterClient) UpdateSender(req *http.Request) (future PrivateLinkServicesForM365ComplianceCenterUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365ComplianceCenterClient) UpdateResponder(resp *http.Response) (result PrivateLinkServicesForM365ComplianceCenterDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesform365securitycenter.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesform365securitycenter.go new file mode 100644 index 000000000000..390afa98f872 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesform365securitycenter.go @@ -0,0 +1,645 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkServicesForM365SecurityCenterClient is the security And Compliance Client +type PrivateLinkServicesForM365SecurityCenterClient struct { + BaseClient +} + +// NewPrivateLinkServicesForM365SecurityCenterClient creates an instance of the +// PrivateLinkServicesForM365SecurityCenterClient client. +func NewPrivateLinkServicesForM365SecurityCenterClient(subscriptionID string) PrivateLinkServicesForM365SecurityCenterClient { + return NewPrivateLinkServicesForM365SecurityCenterClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkServicesForM365SecurityCenterClientWithBaseURI creates an instance of the +// PrivateLinkServicesForM365SecurityCenterClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateLinkServicesForM365SecurityCenterClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkServicesForM365SecurityCenterClient { + return PrivateLinkServicesForM365SecurityCenterClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update the metadata of a privateLinkServicesForM365SecurityCenter instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateLinkServicesForM365SecurityCenterDescription - the service instance metadata. +func (client PrivateLinkServicesForM365SecurityCenterClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForM365SecurityCenterDescription PrivateLinkServicesForM365SecurityCenterDescription) (result PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: privateLinkServicesForM365SecurityCenterDescription, + Constraints: []validation.Constraint{{Target: "privateLinkServicesForM365SecurityCenterDescription.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365SecurityCenterDescription.Properties.CosmosDbConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365SecurityCenterDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365SecurityCenterDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMaximum, Rule: int64(10000), Chain: nil}, + {Target: "privateLinkServicesForM365SecurityCenterDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMinimum, Rule: int64(400), Chain: nil}, + }}, + }}, + {Target: "privateLinkServicesForM365SecurityCenterDescription.Properties.CorsConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365SecurityCenterDescription.Properties.CorsConfiguration.MaxAge", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForM365SecurityCenterDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMaximum, Rule: int64(99999), Chain: nil}, + {Target: "privateLinkServicesForM365SecurityCenterDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateLinkServicesForM365SecurityCenterDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkServicesForM365SecurityCenterClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForM365SecurityCenterDescription PrivateLinkServicesForM365SecurityCenterDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}", pathParameters), + autorest.WithJSON(privateLinkServicesForM365SecurityCenterDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365SecurityCenterClient) CreateOrUpdateSender(req *http.Request) (future PrivateLinkServicesForM365SecurityCenterCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365SecurityCenterClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateLinkServicesForM365SecurityCenterDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForM365SecurityCenterClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForM365SecurityCenterDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkServicesForM365SecurityCenterClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365SecurityCenterClient) DeleteSender(req *http.Request) (future PrivateLinkServicesForM365SecurityCenterDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365SecurityCenterClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the metadata of a privateLinkServicesForM365SecurityCenter resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForM365SecurityCenterClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForM365SecurityCenterDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkServicesForM365SecurityCenterClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365SecurityCenterClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365SecurityCenterClient) GetResponder(resp *http.Response) (result PrivateLinkServicesForM365SecurityCenterDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the privateLinkServicesForM365SecurityCenter instances in a subscription. +func (client PrivateLinkServicesForM365SecurityCenterClient) List(ctx context.Context) (result PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterClient.List") + defer func() { + sc := -1 + if result.plsfmscdlr.Response.Response != nil { + sc = result.plsfmscdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plsfmscdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "List", resp, "Failure sending request") + return + } + + result.plsfmscdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "List", resp, "Failure responding to request") + return + } + if result.plsfmscdlr.hasNextLink() && result.plsfmscdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListResponder(resp *http.Response) (result PrivateLinkServicesForM365SecurityCenterDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForM365SecurityCenterClient) listNextResults(ctx context.Context, lastResults PrivateLinkServicesForM365SecurityCenterDescriptionListResult) (result PrivateLinkServicesForM365SecurityCenterDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForM365SecurityCenterDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListComplete(ctx context.Context) (result PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup get all the service instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForM365SecurityCenterDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.plsfmscdlr.Response.Response != nil { + sc = result.plsfmscdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.plsfmscdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.plsfmscdlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.plsfmscdlr.hasNextLink() && result.plsfmscdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListByResourceGroupResponder(resp *http.Response) (result PrivateLinkServicesForM365SecurityCenterDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForM365SecurityCenterClient) listByResourceGroupNextResults(ctx context.Context, lastResults PrivateLinkServicesForM365SecurityCenterDescriptionListResult) (result PrivateLinkServicesForM365SecurityCenterDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForM365SecurityCenterDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForM365SecurityCenterClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForM365SecurityCenterDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update the metadata of a privateLinkServicesForM365SecurityCenter instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// servicePatchDescription - the service instance metadata and security metadata. +func (client PrivateLinkServicesForM365SecurityCenterClient) Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (result PrivateLinkServicesForM365SecurityCenterUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForM365SecurityCenterClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, servicePatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForM365SecurityCenterClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateLinkServicesForM365SecurityCenterClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForM365SecurityCenter/{resourceName}", pathParameters), + autorest.WithJSON(servicePatchDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForM365SecurityCenterClient) UpdateSender(req *http.Request) (future PrivateLinkServicesForM365SecurityCenterUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForM365SecurityCenterClient) UpdateResponder(resp *http.Response) (result PrivateLinkServicesForM365SecurityCenterDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesformippolicysync.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesformippolicysync.go new file mode 100644 index 000000000000..fbded69408c0 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesformippolicysync.go @@ -0,0 +1,645 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkServicesForMIPPolicySyncClient is the security And Compliance Client +type PrivateLinkServicesForMIPPolicySyncClient struct { + BaseClient +} + +// NewPrivateLinkServicesForMIPPolicySyncClient creates an instance of the PrivateLinkServicesForMIPPolicySyncClient +// client. +func NewPrivateLinkServicesForMIPPolicySyncClient(subscriptionID string) PrivateLinkServicesForMIPPolicySyncClient { + return NewPrivateLinkServicesForMIPPolicySyncClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkServicesForMIPPolicySyncClientWithBaseURI creates an instance of the +// PrivateLinkServicesForMIPPolicySyncClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateLinkServicesForMIPPolicySyncClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkServicesForMIPPolicySyncClient { + return PrivateLinkServicesForMIPPolicySyncClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update the metadata of a privateLinkServicesForMIPPolicySync instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateLinkServicesForMIPPolicySyncDescription - the service instance metadata. +func (client PrivateLinkServicesForMIPPolicySyncClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForMIPPolicySyncDescription PrivateLinkServicesForMIPPolicySyncDescription) (result PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: privateLinkServicesForMIPPolicySyncDescription, + Constraints: []validation.Constraint{{Target: "privateLinkServicesForMIPPolicySyncDescription.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForMIPPolicySyncDescription.Properties.CosmosDbConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForMIPPolicySyncDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForMIPPolicySyncDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMaximum, Rule: int64(10000), Chain: nil}, + {Target: "privateLinkServicesForMIPPolicySyncDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMinimum, Rule: int64(400), Chain: nil}, + }}, + }}, + {Target: "privateLinkServicesForMIPPolicySyncDescription.Properties.CorsConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForMIPPolicySyncDescription.Properties.CorsConfiguration.MaxAge", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForMIPPolicySyncDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMaximum, Rule: int64(99999), Chain: nil}, + {Target: "privateLinkServicesForMIPPolicySyncDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateLinkServicesForMIPPolicySyncDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkServicesForMIPPolicySyncClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForMIPPolicySyncDescription PrivateLinkServicesForMIPPolicySyncDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}", pathParameters), + autorest.WithJSON(privateLinkServicesForMIPPolicySyncDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForMIPPolicySyncClient) CreateOrUpdateSender(req *http.Request) (future PrivateLinkServicesForMIPPolicySyncCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForMIPPolicySyncClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateLinkServicesForMIPPolicySyncDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForMIPPolicySyncClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForMIPPolicySyncDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkServicesForMIPPolicySyncClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForMIPPolicySyncClient) DeleteSender(req *http.Request) (future PrivateLinkServicesForMIPPolicySyncDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForMIPPolicySyncClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the metadata of a privateLinkServicesForMIPPolicySync resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForMIPPolicySyncClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForMIPPolicySyncDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkServicesForMIPPolicySyncClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForMIPPolicySyncClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForMIPPolicySyncClient) GetResponder(resp *http.Response) (result PrivateLinkServicesForMIPPolicySyncDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the privateLinkServicesForMIPPolicySync instances in a subscription. +func (client PrivateLinkServicesForMIPPolicySyncClient) List(ctx context.Context) (result PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncClient.List") + defer func() { + sc := -1 + if result.plsfmpsdlr.Response.Response != nil { + sc = result.plsfmpsdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plsfmpsdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "List", resp, "Failure sending request") + return + } + + result.plsfmpsdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "List", resp, "Failure responding to request") + return + } + if result.plsfmpsdlr.hasNextLink() && result.plsfmpsdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListResponder(resp *http.Response) (result PrivateLinkServicesForMIPPolicySyncDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForMIPPolicySyncClient) listNextResults(ctx context.Context, lastResults PrivateLinkServicesForMIPPolicySyncDescriptionListResult) (result PrivateLinkServicesForMIPPolicySyncDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForMIPPolicySyncDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListComplete(ctx context.Context) (result PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup get all the service instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForMIPPolicySyncDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.plsfmpsdlr.Response.Response != nil { + sc = result.plsfmpsdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.plsfmpsdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.plsfmpsdlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.plsfmpsdlr.hasNextLink() && result.plsfmpsdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListByResourceGroupResponder(resp *http.Response) (result PrivateLinkServicesForMIPPolicySyncDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForMIPPolicySyncClient) listByResourceGroupNextResults(ctx context.Context, lastResults PrivateLinkServicesForMIPPolicySyncDescriptionListResult) (result PrivateLinkServicesForMIPPolicySyncDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForMIPPolicySyncDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForMIPPolicySyncClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForMIPPolicySyncDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update the metadata of a privateLinkServicesForMIPPolicySync instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// servicePatchDescription - the service instance metadata and security metadata. +func (client PrivateLinkServicesForMIPPolicySyncClient) Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (result PrivateLinkServicesForMIPPolicySyncUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForMIPPolicySyncClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, servicePatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForMIPPolicySyncClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateLinkServicesForMIPPolicySyncClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForMIPPolicySync/{resourceName}", pathParameters), + autorest.WithJSON(servicePatchDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForMIPPolicySyncClient) UpdateSender(req *http.Request) (future PrivateLinkServicesForMIPPolicySyncUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForMIPPolicySyncClient) UpdateResponder(resp *http.Response) (result PrivateLinkServicesForMIPPolicySyncDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforo365managementactivityapi.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforo365managementactivityapi.go new file mode 100644 index 000000000000..05ce2bf6e308 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforo365managementactivityapi.go @@ -0,0 +1,645 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkServicesForO365ManagementActivityAPIClient is the security And Compliance Client +type PrivateLinkServicesForO365ManagementActivityAPIClient struct { + BaseClient +} + +// NewPrivateLinkServicesForO365ManagementActivityAPIClient creates an instance of the +// PrivateLinkServicesForO365ManagementActivityAPIClient client. +func NewPrivateLinkServicesForO365ManagementActivityAPIClient(subscriptionID string) PrivateLinkServicesForO365ManagementActivityAPIClient { + return NewPrivateLinkServicesForO365ManagementActivityAPIClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkServicesForO365ManagementActivityAPIClientWithBaseURI creates an instance of the +// PrivateLinkServicesForO365ManagementActivityAPIClient client using a custom endpoint. Use this when interacting +// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateLinkServicesForO365ManagementActivityAPIClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkServicesForO365ManagementActivityAPIClient { + return PrivateLinkServicesForO365ManagementActivityAPIClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update the metadata of a privateLinkServicesForO365ManagementActivityAPI instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateLinkServicesForO365ManagementActivityAPIDescription - the service instance metadata. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForO365ManagementActivityAPIDescription PrivateLinkServicesForO365ManagementActivityAPIDescription) (result PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: privateLinkServicesForO365ManagementActivityAPIDescription, + Constraints: []validation.Constraint{{Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties.CosmosDbConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMaximum, Rule: int64(10000), Chain: nil}, + {Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMinimum, Rule: int64(400), Chain: nil}, + }}, + }}, + {Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties.CorsConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties.CorsConfiguration.MaxAge", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMaximum, Rule: int64(99999), Chain: nil}, + {Target: "privateLinkServicesForO365ManagementActivityAPIDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateLinkServicesForO365ManagementActivityAPIDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForO365ManagementActivityAPIDescription PrivateLinkServicesForO365ManagementActivityAPIDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}", pathParameters), + autorest.WithJSON(privateLinkServicesForO365ManagementActivityAPIDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) CreateOrUpdateSender(req *http.Request) (future PrivateLinkServicesForO365ManagementActivityAPICreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateLinkServicesForO365ManagementActivityAPIDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) DeleteSender(req *http.Request) (future PrivateLinkServicesForO365ManagementActivityAPIDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the metadata of a privateLinkServicesForO365ManagementActivityAPI resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForO365ManagementActivityAPIDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) GetResponder(resp *http.Response) (result PrivateLinkServicesForO365ManagementActivityAPIDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the privateLinkServicesForO365ManagementActivityAPI instances in a subscription. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) List(ctx context.Context) (result PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIClient.List") + defer func() { + sc := -1 + if result.plsfomaadlr.Response.Response != nil { + sc = result.plsfomaadlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plsfomaadlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "List", resp, "Failure sending request") + return + } + + result.plsfomaadlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "List", resp, "Failure responding to request") + return + } + if result.plsfomaadlr.hasNextLink() && result.plsfomaadlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListResponder(resp *http.Response) (result PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) listNextResults(ctx context.Context, lastResults PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult) (result PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForO365ManagementActivityAPIDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListComplete(ctx context.Context) (result PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup get all the service instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.plsfomaadlr.Response.Response != nil { + sc = result.plsfomaadlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.plsfomaadlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.plsfomaadlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.plsfomaadlr.hasNextLink() && result.plsfomaadlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListByResourceGroupResponder(resp *http.Response) (result PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) listByResourceGroupNextResults(ctx context.Context, lastResults PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult) (result PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForO365ManagementActivityAPIDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForO365ManagementActivityAPIDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update the metadata of a privateLinkServicesForO365ManagementActivityAPI instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// servicePatchDescription - the service instance metadata and security metadata. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (result PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForO365ManagementActivityAPIClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, servicePatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForO365ManagementActivityAPIClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForO365ManagementActivityAPI/{resourceName}", pathParameters), + autorest.WithJSON(servicePatchDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) UpdateSender(req *http.Request) (future PrivateLinkServicesForO365ManagementActivityAPIUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForO365ManagementActivityAPIClient) UpdateResponder(resp *http.Response) (result PrivateLinkServicesForO365ManagementActivityAPIDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforsccpowershell.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforsccpowershell.go new file mode 100644 index 000000000000..230fb5ea397e --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/privatelinkservicesforsccpowershell.go @@ -0,0 +1,645 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkServicesForSCCPowershellClient is the security And Compliance Client +type PrivateLinkServicesForSCCPowershellClient struct { + BaseClient +} + +// NewPrivateLinkServicesForSCCPowershellClient creates an instance of the PrivateLinkServicesForSCCPowershellClient +// client. +func NewPrivateLinkServicesForSCCPowershellClient(subscriptionID string) PrivateLinkServicesForSCCPowershellClient { + return NewPrivateLinkServicesForSCCPowershellClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkServicesForSCCPowershellClientWithBaseURI creates an instance of the +// PrivateLinkServicesForSCCPowershellClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrivateLinkServicesForSCCPowershellClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkServicesForSCCPowershellClient { + return PrivateLinkServicesForSCCPowershellClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update the metadata of a privateLinkServicesForSCCPowershell instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateLinkServicesForSCCPowershellDescription - the service instance metadata. +func (client PrivateLinkServicesForSCCPowershellClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForSCCPowershellDescription PrivateLinkServicesForSCCPowershellDescription) (result PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: privateLinkServicesForSCCPowershellDescription, + Constraints: []validation.Constraint{{Target: "privateLinkServicesForSCCPowershellDescription.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForSCCPowershellDescription.Properties.CosmosDbConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForSCCPowershellDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForSCCPowershellDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMaximum, Rule: int64(10000), Chain: nil}, + {Target: "privateLinkServicesForSCCPowershellDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMinimum, Rule: int64(400), Chain: nil}, + }}, + }}, + {Target: "privateLinkServicesForSCCPowershellDescription.Properties.CorsConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForSCCPowershellDescription.Properties.CorsConfiguration.MaxAge", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateLinkServicesForSCCPowershellDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMaximum, Rule: int64(99999), Chain: nil}, + {Target: "privateLinkServicesForSCCPowershellDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateLinkServicesForSCCPowershellDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkServicesForSCCPowershellClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateLinkServicesForSCCPowershellDescription PrivateLinkServicesForSCCPowershellDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}", pathParameters), + autorest.WithJSON(privateLinkServicesForSCCPowershellDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForSCCPowershellClient) CreateOrUpdateSender(req *http.Request) (future PrivateLinkServicesForSCCPowershellCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForSCCPowershellClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateLinkServicesForSCCPowershellDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForSCCPowershellClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForSCCPowershellDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkServicesForSCCPowershellClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForSCCPowershellClient) DeleteSender(req *http.Request) (future PrivateLinkServicesForSCCPowershellDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForSCCPowershellClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the metadata of a privateLinkServicesForSCCPowershell resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkServicesForSCCPowershellClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkServicesForSCCPowershellDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkServicesForSCCPowershellClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForSCCPowershellClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForSCCPowershellClient) GetResponder(resp *http.Response) (result PrivateLinkServicesForSCCPowershellDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the privateLinkServicesForSCCPowershell instances in a subscription. +func (client PrivateLinkServicesForSCCPowershellClient) List(ctx context.Context) (result PrivateLinkServicesForSCCPowershellDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellClient.List") + defer func() { + sc := -1 + if result.plsfspdlr.Response.Response != nil { + sc = result.plsfspdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plsfspdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "List", resp, "Failure sending request") + return + } + + result.plsfspdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "List", resp, "Failure responding to request") + return + } + if result.plsfspdlr.hasNextLink() && result.plsfspdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkServicesForSCCPowershellClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForSCCPowershellClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForSCCPowershellClient) ListResponder(resp *http.Response) (result PrivateLinkServicesForSCCPowershellDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForSCCPowershellClient) listNextResults(ctx context.Context, lastResults PrivateLinkServicesForSCCPowershellDescriptionListResult) (result PrivateLinkServicesForSCCPowershellDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForSCCPowershellDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForSCCPowershellClient) ListComplete(ctx context.Context) (result PrivateLinkServicesForSCCPowershellDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup get all the service instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +func (client PrivateLinkServicesForSCCPowershellClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForSCCPowershellDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.plsfspdlr.Response.Response != nil { + sc = result.plsfspdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.plsfspdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.plsfspdlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.plsfspdlr.hasNextLink() && result.plsfspdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PrivateLinkServicesForSCCPowershellClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForSCCPowershellClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForSCCPowershellClient) ListByResourceGroupResponder(resp *http.Response) (result PrivateLinkServicesForSCCPowershellDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client PrivateLinkServicesForSCCPowershellClient) listByResourceGroupNextResults(ctx context.Context, lastResults PrivateLinkServicesForSCCPowershellDescriptionListResult) (result PrivateLinkServicesForSCCPowershellDescriptionListResult, err error) { + req, err := lastResults.privateLinkServicesForSCCPowershellDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkServicesForSCCPowershellClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PrivateLinkServicesForSCCPowershellDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update the metadata of a privateLinkServicesForSCCPowershell instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// servicePatchDescription - the service instance metadata and security metadata. +func (client PrivateLinkServicesForSCCPowershellClient) Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (result PrivateLinkServicesForSCCPowershellUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkServicesForSCCPowershellClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, servicePatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.PrivateLinkServicesForSCCPowershellClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateLinkServicesForSCCPowershellClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForSCCPowershell/{resourceName}", pathParameters), + autorest.WithJSON(servicePatchDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkServicesForSCCPowershellClient) UpdateSender(req *http.Request) (future PrivateLinkServicesForSCCPowershellUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateLinkServicesForSCCPowershellClient) UpdateResponder(resp *http.Response) (result PrivateLinkServicesForSCCPowershellDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/services.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/services.go new file mode 100644 index 000000000000..38081d31c361 --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/services.go @@ -0,0 +1,120 @@ +package m365securityandcompliance + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServicesClient is the security And Compliance Client +type ServicesClient struct { + BaseClient +} + +// NewServicesClient creates an instance of the ServicesClient client. +func NewServicesClient(subscriptionID string) ServicesClient { + return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicesClientWithBaseURI creates an instance of the ServicesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { + return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result ServicesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("m365securityandcompliance.ServicesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.ServicesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "m365securityandcompliance.ServicesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-25-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.M365SecurityAndCompliance/privateLinkServicesForEDMUpload/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) DeleteSender(req *http.Request) (future ServicesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/version.go b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/version.go new file mode 100644 index 000000000000..4af1975b7c0d --- /dev/null +++ b/services/preview/m365securityandcompliance/mgmt/2021-03-25-preview/m365securityandcompliance/version.go @@ -0,0 +1,19 @@ +package m365securityandcompliance + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " m365securityandcompliance/2021-03-25-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}