diff --git a/sdk/resourcemanager/fileshares/armfileshares/CHANGELOG.md b/sdk/resourcemanager/fileshares/armfileshares/CHANGELOG.md new file mode 100644 index 000000000000..702c1ecd5b55 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-05-08) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/fileshares/armfileshares/LICENSE.txt b/sdk/resourcemanager/fileshares/armfileshares/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/fileshares/armfileshares/README.md b/sdk/resourcemanager/fileshares/armfileshares/README.md new file mode 100644 index 000000000000..d626f08b1929 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/README.md @@ -0,0 +1,90 @@ +# Azure Fileshares Module for Go + +The `armfileshares` module provides operations for working with Azure Fileshares. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/fileshares/armfileshares) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Fileshares module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Fileshares. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Fileshares module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armfileshares.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armfileshares.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewFileSharesClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Fileshares` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/fileshares/armfileshares/ci.yml b/sdk/resourcemanager/fileshares/armfileshares/ci.yml new file mode 100644 index 000000000000..79bc40ec306c --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/fileshares/armfileshares/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/fileshares/armfileshares/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/fileshares/armfileshares' diff --git a/sdk/resourcemanager/fileshares/armfileshares/client_factory.go b/sdk/resourcemanager/fileshares/armfileshares/client_factory.go new file mode 100644 index 000000000000..f563c2c0351a --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/client_factory.go @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewFileSharesClient creates a new instance of FileSharesClient. +func (c *ClientFactory) NewFileSharesClient() *FileSharesClient { + return &FileSharesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/constants.go b/sdk/resourcemanager/fileshares/armfileshares/constants.go new file mode 100644 index 000000000000..9300a4e32878 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/constants.go @@ -0,0 +1,247 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares" + moduleVersion = "v0.1.0" +) + +// ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + // ActionTypeInternal - Actions are for internal-only APIs. + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// CheckNameAvailabilityReason - Possible reasons for a name not being available. +type CheckNameAvailabilityReason string + +const ( + // CheckNameAvailabilityReasonAlreadyExists - Name already exists. + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + // CheckNameAvailabilityReasonInvalid - Name is invalid. + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +// PossibleCheckNameAvailabilityReasonValues returns the possible values for the CheckNameAvailabilityReason const type. +func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { + return []CheckNameAvailabilityReason{ + CheckNameAvailabilityReasonAlreadyExists, + CheckNameAvailabilityReasonInvalid, + } +} + +// CreatedByType - The kind of entity that created the resource. +type CreatedByType string + +const ( + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// FileShareProvisioningState - The status of the last operation. +type FileShareProvisioningState string + +const ( + // FileShareProvisioningStateAccepted - The operation is accepted. + FileShareProvisioningStateAccepted FileShareProvisioningState = "Accepted" + // FileShareProvisioningStateCanceled - Resource creation was canceled. + FileShareProvisioningStateCanceled FileShareProvisioningState = "Canceled" + // FileShareProvisioningStateDeleting - The operation is deleting. + FileShareProvisioningStateDeleting FileShareProvisioningState = "Deleting" + // FileShareProvisioningStateFailed - Resource creation failed. + FileShareProvisioningStateFailed FileShareProvisioningState = "Failed" + // FileShareProvisioningStateProvisioning - The operation is provisioning. + FileShareProvisioningStateProvisioning FileShareProvisioningState = "Provisioning" + // FileShareProvisioningStateSucceeded - Resource has been created. + FileShareProvisioningStateSucceeded FileShareProvisioningState = "Succeeded" + // FileShareProvisioningStateUpdating - The operation is updating. + FileShareProvisioningStateUpdating FileShareProvisioningState = "Updating" +) + +// PossibleFileShareProvisioningStateValues returns the possible values for the FileShareProvisioningState const type. +func PossibleFileShareProvisioningStateValues() []FileShareProvisioningState { + return []FileShareProvisioningState{ + FileShareProvisioningStateAccepted, + FileShareProvisioningStateCanceled, + FileShareProvisioningStateDeleting, + FileShareProvisioningStateFailed, + FileShareProvisioningStateProvisioning, + FileShareProvisioningStateSucceeded, + FileShareProvisioningStateUpdating, + } +} + +// MediaTier - Media Tier enum. +type MediaTier string + +const ( + MediaTierSSD MediaTier = "SSD" +) + +// PossibleMediaTierValues returns the possible values for the MediaTier const type. +func PossibleMediaTierValues() []MediaTier { + return []MediaTier{ + MediaTierSSD, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + // OriginSystem - Indicates the operation is initiated by a system. + OriginSystem Origin = "system" + // OriginUser - Indicates the operation is initiated by a user. + OriginUser Origin = "user" + // OriginUserSystem - Indicates the operation is initiated by a user or system. + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// PrivateEndpointConnectionProvisioningState - The current provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + // PrivateEndpointConnectionProvisioningStateCreating - Connection is being created + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + // PrivateEndpointConnectionProvisioningStateDeleting - Connection is being deleted + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + // PrivateEndpointConnectionProvisioningStateFailed - Connection provisioning has failed + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + // PrivateEndpointConnectionProvisioningStateSucceeded - Connection has been provisioned + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns the possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{ + PrivateEndpointConnectionProvisioningStateCreating, + PrivateEndpointConnectionProvisioningStateDeleting, + PrivateEndpointConnectionProvisioningStateFailed, + PrivateEndpointConnectionProvisioningStateSucceeded, + } +} + +// PrivateEndpointServiceConnectionStatus - The private endpoint connection status. +type PrivateEndpointServiceConnectionStatus string + +const ( + // PrivateEndpointServiceConnectionStatusApproved - Connection approved + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + // PrivateEndpointServiceConnectionStatusPending - Connection waiting for approval or rejection + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + // PrivateEndpointServiceConnectionStatusRejected - Connection Rejected + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateEndpointServiceConnectionStatusValues returns the possible values for the PrivateEndpointServiceConnectionStatus const type. +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{ + PrivateEndpointServiceConnectionStatusApproved, + PrivateEndpointServiceConnectionStatusPending, + PrivateEndpointServiceConnectionStatusRejected, + } +} + +// Protocol - Protocol enum. +type Protocol string + +const ( + ProtocolNFS Protocol = "NFS" +) + +// PossibleProtocolValues returns the possible values for the Protocol const type. +func PossibleProtocolValues() []Protocol { + return []Protocol{ + ProtocolNFS, + } +} + +// PublicNetworkAccess - State of the public network access. +type PublicNetworkAccess string + +const ( + // PublicNetworkAccessDisabled - The public network access is disabled + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + // PublicNetworkAccessEnabled - The public network access is enabled + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{ + PublicNetworkAccessDisabled, + PublicNetworkAccessEnabled, + } +} + +// Redundancy - Redundancy enum. +type Redundancy string + +const ( + RedundancyLocal Redundancy = "Local" + RedundancyZone Redundancy = "Zone" +) + +// PossibleRedundancyValues returns the possible values for the Redundancy const type. +func PossibleRedundancyValues() []Redundancy { + return []Redundancy{ + RedundancyLocal, + RedundancyZone, + } +} + +// ShareRootSquash - Share root squash enum. +type ShareRootSquash string + +const ( + ShareRootSquashAllSquash ShareRootSquash = "AllSquash" + ShareRootSquashNoRootSquash ShareRootSquash = "NoRootSquash" + ShareRootSquashRootSquash ShareRootSquash = "RootSquash" +) + +// PossibleShareRootSquashValues returns the possible values for the ShareRootSquash const type. +func PossibleShareRootSquashValues() []ShareRootSquash { + return []ShareRootSquash{ + ShareRootSquashAllSquash, + ShareRootSquashNoRootSquash, + ShareRootSquashRootSquash, + } +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/fake/fileshares_server.go b/sdk/resourcemanager/fileshares/armfileshares/fake/fileshares_server.go new file mode 100644 index 000000000000..3485989aadb1 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/fake/fileshares_server.go @@ -0,0 +1,668 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares" + "net/http" + "net/url" + "regexp" +) + +// FileSharesServer is a fake server for instances of the armfileshares.FileSharesClient type. +type FileSharesServer struct { + // CheckNameAvailability is the fake for method FileSharesClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, location string, body armfileshares.CheckNameAvailabilityRequest, options *armfileshares.FileSharesClientCheckNameAvailabilityOptions) (resp azfake.Responder[armfileshares.FileSharesClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method FileSharesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, resourceName string, resource armfileshares.FileShare, options *armfileshares.FileSharesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armfileshares.FileSharesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdateFileShareSnapshot is the fake for method FileSharesClient.CreateOrUpdateFileShareSnapshot + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdateFileShareSnapshot func(ctx context.Context, resourceGroupName string, resourceName string, name string, resource armfileshares.FileShareSnapshot, options *armfileshares.FileSharesClientCreateOrUpdateFileShareSnapshotOptions) (resp azfake.Responder[armfileshares.FileSharesClientCreateOrUpdateFileShareSnapshotResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method FileSharesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, resourceName string, options *armfileshares.FileSharesClientBeginDeleteOptions) (resp azfake.PollerResponder[armfileshares.FileSharesClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginDeleteFileShareSnapshot is the fake for method FileSharesClient.BeginDeleteFileShareSnapshot + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteFileShareSnapshot func(ctx context.Context, resourceGroupName string, resourceName string, name string, options *armfileshares.FileSharesClientBeginDeleteFileShareSnapshotOptions) (resp azfake.PollerResponder[armfileshares.FileSharesClientDeleteFileShareSnapshotResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method FileSharesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, resourceName string, options *armfileshares.FileSharesClientGetOptions) (resp azfake.Responder[armfileshares.FileSharesClientGetResponse], errResp azfake.ErrorResponder) + + // GetFileShareSnapshot is the fake for method FileSharesClient.GetFileShareSnapshot + // HTTP status codes to indicate success: http.StatusOK + GetFileShareSnapshot func(ctx context.Context, resourceGroupName string, resourceName string, name string, options *armfileshares.FileSharesClientGetFileShareSnapshotOptions) (resp azfake.Responder[armfileshares.FileSharesClientGetFileShareSnapshotResponse], errResp azfake.ErrorResponder) + + // NewListByFileSharePager is the fake for method FileSharesClient.NewListByFileSharePager + // HTTP status codes to indicate success: http.StatusOK + NewListByFileSharePager func(resourceGroupName string, resourceName string, options *armfileshares.FileSharesClientListByFileShareOptions) (resp azfake.PagerResponder[armfileshares.FileSharesClientListByFileShareResponse]) + + // NewListByParentPager is the fake for method FileSharesClient.NewListByParentPager + // HTTP status codes to indicate success: http.StatusOK + NewListByParentPager func(resourceGroupName string, options *armfileshares.FileSharesClientListByParentOptions) (resp azfake.PagerResponder[armfileshares.FileSharesClientListByParentResponse]) + + // NewListBySubscriptionPager is the fake for method FileSharesClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armfileshares.FileSharesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armfileshares.FileSharesClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method FileSharesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, resourceName string, properties armfileshares.FileShareUpdate, options *armfileshares.FileSharesClientBeginUpdateOptions) (resp azfake.PollerResponder[armfileshares.FileSharesClientUpdateResponse], errResp azfake.ErrorResponder) + + // BeginUpdateFileShareSnapshot is the fake for method FileSharesClient.BeginUpdateFileShareSnapshot + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdateFileShareSnapshot func(ctx context.Context, resourceGroupName string, resourceName string, name string, properties armfileshares.FileShareSnapshotUpdate, options *armfileshares.FileSharesClientBeginUpdateFileShareSnapshotOptions) (resp azfake.PollerResponder[armfileshares.FileSharesClientUpdateFileShareSnapshotResponse], errResp azfake.ErrorResponder) +} + +// NewFileSharesServerTransport creates a new instance of FileSharesServerTransport with the provided implementation. +// The returned FileSharesServerTransport instance is connected to an instance of armfileshares.FileSharesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewFileSharesServerTransport(srv *FileSharesServer) *FileSharesServerTransport { + return &FileSharesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armfileshares.FileSharesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armfileshares.FileSharesClientDeleteResponse]](), + beginDeleteFileShareSnapshot: newTracker[azfake.PollerResponder[armfileshares.FileSharesClientDeleteFileShareSnapshotResponse]](), + newListByFileSharePager: newTracker[azfake.PagerResponder[armfileshares.FileSharesClientListByFileShareResponse]](), + newListByParentPager: newTracker[azfake.PagerResponder[armfileshares.FileSharesClientListByParentResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armfileshares.FileSharesClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armfileshares.FileSharesClientUpdateResponse]](), + beginUpdateFileShareSnapshot: newTracker[azfake.PollerResponder[armfileshares.FileSharesClientUpdateFileShareSnapshotResponse]](), + } +} + +// FileSharesServerTransport connects instances of armfileshares.FileSharesClient to instances of FileSharesServer. +// Don't use this type directly, use NewFileSharesServerTransport instead. +type FileSharesServerTransport struct { + srv *FileSharesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armfileshares.FileSharesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armfileshares.FileSharesClientDeleteResponse]] + beginDeleteFileShareSnapshot *tracker[azfake.PollerResponder[armfileshares.FileSharesClientDeleteFileShareSnapshotResponse]] + newListByFileSharePager *tracker[azfake.PagerResponder[armfileshares.FileSharesClientListByFileShareResponse]] + newListByParentPager *tracker[azfake.PagerResponder[armfileshares.FileSharesClientListByParentResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armfileshares.FileSharesClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armfileshares.FileSharesClientUpdateResponse]] + beginUpdateFileShareSnapshot *tracker[azfake.PollerResponder[armfileshares.FileSharesClientUpdateFileShareSnapshotResponse]] +} + +// Do implements the policy.Transporter interface for FileSharesServerTransport. +func (f *FileSharesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return f.dispatchToMethodFake(req, method) +} + +func (f *FileSharesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if fileSharesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = fileSharesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "FileSharesClient.CheckNameAvailability": + res.resp, res.err = f.dispatchCheckNameAvailability(req) + case "FileSharesClient.BeginCreateOrUpdate": + res.resp, res.err = f.dispatchBeginCreateOrUpdate(req) + case "FileSharesClient.CreateOrUpdateFileShareSnapshot": + res.resp, res.err = f.dispatchCreateOrUpdateFileShareSnapshot(req) + case "FileSharesClient.BeginDelete": + res.resp, res.err = f.dispatchBeginDelete(req) + case "FileSharesClient.BeginDeleteFileShareSnapshot": + res.resp, res.err = f.dispatchBeginDeleteFileShareSnapshot(req) + case "FileSharesClient.Get": + res.resp, res.err = f.dispatchGet(req) + case "FileSharesClient.GetFileShareSnapshot": + res.resp, res.err = f.dispatchGetFileShareSnapshot(req) + case "FileSharesClient.NewListByFileSharePager": + res.resp, res.err = f.dispatchNewListByFileSharePager(req) + case "FileSharesClient.NewListByParentPager": + res.resp, res.err = f.dispatchNewListByParentPager(req) + case "FileSharesClient.NewListBySubscriptionPager": + res.resp, res.err = f.dispatchNewListBySubscriptionPager(req) + case "FileSharesClient.BeginUpdate": + res.resp, res.err = f.dispatchBeginUpdate(req) + case "FileSharesClient.BeginUpdateFileShareSnapshot": + res.resp, res.err = f.dispatchBeginUpdateFileShareSnapshot(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (f *FileSharesServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if f.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfileshares.CheckNameAvailabilityRequest](req) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.CheckNameAvailability(req.Context(), locationParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckNameAvailabilityResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if f.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := f.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfileshares.FileShare](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, resourceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + f.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + f.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + f.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchCreateOrUpdateFileShareSnapshot(req *http.Request) (*http.Response, error) { + if f.srv.CreateOrUpdateFileShareSnapshot == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateFileShareSnapshot not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileShareSnapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfileshares.FileShareSnapshot](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.CreateOrUpdateFileShareSnapshot(req.Context(), resourceGroupNameParam, resourceNameParam, nameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).FileShareSnapshot, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if f.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := f.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginDelete(req.Context(), resourceGroupNameParam, resourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + f.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + f.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + f.beginDelete.remove(req) + } + + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchBeginDeleteFileShareSnapshot(req *http.Request) (*http.Response, error) { + if f.srv.BeginDeleteFileShareSnapshot == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteFileShareSnapshot not implemented")} + } + beginDeleteFileShareSnapshot := f.beginDeleteFileShareSnapshot.get(req) + if beginDeleteFileShareSnapshot == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileShareSnapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginDeleteFileShareSnapshot(req.Context(), resourceGroupNameParam, resourceNameParam, nameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteFileShareSnapshot = &respr + f.beginDeleteFileShareSnapshot.add(req, beginDeleteFileShareSnapshot) + } + + resp, err := server.PollerResponderNext(beginDeleteFileShareSnapshot, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + f.beginDeleteFileShareSnapshot.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDeleteFileShareSnapshot) { + f.beginDeleteFileShareSnapshot.remove(req) + } + + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if f.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).FileShare, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchGetFileShareSnapshot(req *http.Request) (*http.Response, error) { + if f.srv.GetFileShareSnapshot == nil { + return nil, &nonRetriableError{errors.New("fake for method GetFileShareSnapshot not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileShareSnapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.GetFileShareSnapshot(req.Context(), resourceGroupNameParam, resourceNameParam, nameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).FileShareSnapshot, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchNewListByFileSharePager(req *http.Request) (*http.Response, error) { + if f.srv.NewListByFileSharePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByFileSharePager not implemented")} + } + newListByFileSharePager := f.newListByFileSharePager.get(req) + if newListByFileSharePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileShareSnapshots` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + resp := f.srv.NewListByFileSharePager(resourceGroupNameParam, resourceNameParam, nil) + newListByFileSharePager = &resp + f.newListByFileSharePager.add(req, newListByFileSharePager) + server.PagerResponderInjectNextLinks(newListByFileSharePager, req, func(page *armfileshares.FileSharesClientListByFileShareResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByFileSharePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + f.newListByFileSharePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByFileSharePager) { + f.newListByFileSharePager.remove(req) + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchNewListByParentPager(req *http.Request) (*http.Response, error) { + if f.srv.NewListByParentPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByParentPager not implemented")} + } + newListByParentPager := f.newListByParentPager.get(req) + if newListByParentPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := f.srv.NewListByParentPager(resourceGroupNameParam, nil) + newListByParentPager = &resp + f.newListByParentPager.add(req, newListByParentPager) + server.PagerResponderInjectNextLinks(newListByParentPager, req, func(page *armfileshares.FileSharesClientListByParentResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByParentPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + f.newListByParentPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByParentPager) { + f.newListByParentPager.remove(req) + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if f.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := f.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := f.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + f.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armfileshares.FileSharesClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + f.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + f.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if f.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := f.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfileshares.FileShareUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginUpdate(req.Context(), resourceGroupNameParam, resourceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + f.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + f.beginUpdate.remove(req) + } + + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchBeginUpdateFileShareSnapshot(req *http.Request) (*http.Response, error) { + if f.srv.BeginUpdateFileShareSnapshot == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdateFileShareSnapshot not implemented")} + } + beginUpdateFileShareSnapshot := f.beginUpdateFileShareSnapshot.get(req) + if beginUpdateFileShareSnapshot == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.FileShares/fileShares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileShareSnapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfileshares.FileShareSnapshotUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginUpdateFileShareSnapshot(req.Context(), resourceGroupNameParam, resourceNameParam, nameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdateFileShareSnapshot = &respr + f.beginUpdateFileShareSnapshot.add(req, beginUpdateFileShareSnapshot) + } + + resp, err := server.PollerResponderNext(beginUpdateFileShareSnapshot, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginUpdateFileShareSnapshot.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdateFileShareSnapshot) { + f.beginUpdateFileShareSnapshot.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to FileSharesServerTransport +var fileSharesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/fake/internal.go b/sdk/resourcemanager/fileshares/armfileshares/fake/internal.go new file mode 100644 index 000000000000..7425b6a669e2 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/fake/internal.go @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/fake/operations_server.go b/sdk/resourcemanager/fileshares/armfileshares/fake/operations_server.go new file mode 100644 index 000000000000..de7c46ccb5b6 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/fake/operations_server.go @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares" + "net/http" +) + +// OperationsServer is a fake server for instances of the armfileshares.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armfileshares.OperationsClientListOptions) (resp azfake.PagerResponder[armfileshares.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armfileshares.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armfileshares.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armfileshares.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armfileshares.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armfileshares.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/fake/server_factory.go b/sdk/resourcemanager/fileshares/armfileshares/fake/server_factory.go new file mode 100644 index 000000000000..eb47f0d08389 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/fake/server_factory.go @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armfileshares.ClientFactory type. +type ServerFactory struct { + // FileSharesServer contains the fakes for client FileSharesClient + FileSharesServer FileSharesServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armfileshares.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armfileshares.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trFileSharesServer *FileSharesServerTransport + trOperationsServer *OperationsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "FileSharesClient": + initServer(s, &s.trFileSharesServer, func() *FileSharesServerTransport { return NewFileSharesServerTransport(&s.srv.FileSharesServer) }) + resp, err = s.trFileSharesServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/fileshares_client.go b/sdk/resourcemanager/fileshares/armfileshares/fileshares_client.go new file mode 100644 index 000000000000..ca0fc6c21088 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/fileshares_client.go @@ -0,0 +1,897 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// FileSharesClient contains the methods for the FileShares group. +// Don't use this type directly, use NewFileSharesClient() instead. +type FileSharesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewFileSharesClient creates a new instance of FileSharesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewFileSharesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FileSharesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &FileSharesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckNameAvailability - Implements local CheckNameAvailability operations +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - location - The name of the Azure region. +// - body - The CheckAvailability request +// - options - FileSharesClientCheckNameAvailabilityOptions contains the optional parameters for the FileSharesClient.CheckNameAvailability +// method. +func (client *FileSharesClient) CheckNameAvailability(ctx context.Context, location string, body CheckNameAvailabilityRequest, options *FileSharesClientCheckNameAvailabilityOptions) (FileSharesClientCheckNameAvailabilityResponse, error) { + var err error + const operationName = "FileSharesClient.CheckNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkNameAvailabilityCreateRequest(ctx, location, body, options) + if err != nil { + return FileSharesClientCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FileSharesClientCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientCheckNameAvailabilityResponse{}, err + } + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *FileSharesClient) checkNameAvailabilityCreateRequest(ctx context.Context, location string, body CheckNameAvailabilityRequest, _ *FileSharesClientCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.FileShares/locations/{location}/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *FileSharesClient) checkNameAvailabilityHandleResponse(resp *http.Response) (FileSharesClientCheckNameAvailabilityResponse, error) { + result := FileSharesClientCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { + return FileSharesClientCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// BeginCreateOrUpdate - Create or update a file share. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - resource - Resource create parameters. +// - options - FileSharesClientBeginCreateOrUpdateOptions contains the optional parameters for the FileSharesClient.BeginCreateOrUpdate +// method. +func (client *FileSharesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, resource FileShare, options *FileSharesClientBeginCreateOrUpdateOptions) (*runtime.Poller[FileSharesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSharesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FileSharesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create or update a file share. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +func (client *FileSharesClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, resource FileShare, options *FileSharesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "FileSharesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *FileSharesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, resource FileShare, _ *FileSharesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// CreateOrUpdateFileShareSnapshot - Create a FileShareSnapshot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - name - The name of the FileShareSnapshot +// - resource - Resource create parameters. +// - options - FileSharesClientCreateOrUpdateFileShareSnapshotOptions contains the optional parameters for the FileSharesClient.CreateOrUpdateFileShareSnapshot +// method. +func (client *FileSharesClient) CreateOrUpdateFileShareSnapshot(ctx context.Context, resourceGroupName string, resourceName string, name string, resource FileShareSnapshot, options *FileSharesClientCreateOrUpdateFileShareSnapshotOptions) (FileSharesClientCreateOrUpdateFileShareSnapshotResponse, error) { + var err error + const operationName = "FileSharesClient.CreateOrUpdateFileShareSnapshot" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateFileShareSnapshotCreateRequest(ctx, resourceGroupName, resourceName, name, resource, options) + if err != nil { + return FileSharesClientCreateOrUpdateFileShareSnapshotResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FileSharesClientCreateOrUpdateFileShareSnapshotResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientCreateOrUpdateFileShareSnapshotResponse{}, err + } + resp, err := client.createOrUpdateFileShareSnapshotHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateFileShareSnapshotCreateRequest creates the CreateOrUpdateFileShareSnapshot request. +func (client *FileSharesClient) createOrUpdateFileShareSnapshotCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, name string, resource FileShareSnapshot, _ *FileSharesClientCreateOrUpdateFileShareSnapshotOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}/fileShareSnapshots/{name}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateFileShareSnapshotHandleResponse handles the CreateOrUpdateFileShareSnapshot response. +func (client *FileSharesClient) createOrUpdateFileShareSnapshotHandleResponse(resp *http.Response) (FileSharesClientCreateOrUpdateFileShareSnapshotResponse, error) { + result := FileSharesClientCreateOrUpdateFileShareSnapshotResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FileShareSnapshot); err != nil { + return FileSharesClientCreateOrUpdateFileShareSnapshotResponse{}, err + } + return result, nil +} + +// BeginDelete - Delete a FileShare +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - options - FileSharesClientBeginDeleteOptions contains the optional parameters for the FileSharesClient.BeginDelete method. +func (client *FileSharesClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, options *FileSharesClientBeginDeleteOptions) (*runtime.Poller[FileSharesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSharesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FileSharesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a FileShare +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +func (client *FileSharesClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *FileSharesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "FileSharesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *FileSharesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *FileSharesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDeleteFileShareSnapshot - Delete a FileShareSnapshot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - name - The name of the FileShareSnapshot +// - options - FileSharesClientBeginDeleteFileShareSnapshotOptions contains the optional parameters for the FileSharesClient.BeginDeleteFileShareSnapshot +// method. +func (client *FileSharesClient) BeginDeleteFileShareSnapshot(ctx context.Context, resourceGroupName string, resourceName string, name string, options *FileSharesClientBeginDeleteFileShareSnapshotOptions) (*runtime.Poller[FileSharesClientDeleteFileShareSnapshotResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteFileShareSnapshot(ctx, resourceGroupName, resourceName, name, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSharesClientDeleteFileShareSnapshotResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FileSharesClientDeleteFileShareSnapshotResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteFileShareSnapshot - Delete a FileShareSnapshot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +func (client *FileSharesClient) deleteFileShareSnapshot(ctx context.Context, resourceGroupName string, resourceName string, name string, options *FileSharesClientBeginDeleteFileShareSnapshotOptions) (*http.Response, error) { + var err error + const operationName = "FileSharesClient.BeginDeleteFileShareSnapshot" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteFileShareSnapshotCreateRequest(ctx, resourceGroupName, resourceName, name, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteFileShareSnapshotCreateRequest creates the DeleteFileShareSnapshot request. +func (client *FileSharesClient) deleteFileShareSnapshotCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, name string, _ *FileSharesClientBeginDeleteFileShareSnapshotOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}/fileShareSnapshots/{name}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a FileShare +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - options - FileSharesClientGetOptions contains the optional parameters for the FileSharesClient.Get method. +func (client *FileSharesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *FileSharesClientGetOptions) (FileSharesClientGetResponse, error) { + var err error + const operationName = "FileSharesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return FileSharesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FileSharesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *FileSharesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *FileSharesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FileSharesClient) getHandleResponse(resp *http.Response) (FileSharesClientGetResponse, error) { + result := FileSharesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FileShare); err != nil { + return FileSharesClientGetResponse{}, err + } + return result, nil +} + +// GetFileShareSnapshot - Get a FileShareSnapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - name - The name of the FileShareSnapshot +// - options - FileSharesClientGetFileShareSnapshotOptions contains the optional parameters for the FileSharesClient.GetFileShareSnapshot +// method. +func (client *FileSharesClient) GetFileShareSnapshot(ctx context.Context, resourceGroupName string, resourceName string, name string, options *FileSharesClientGetFileShareSnapshotOptions) (FileSharesClientGetFileShareSnapshotResponse, error) { + var err error + const operationName = "FileSharesClient.GetFileShareSnapshot" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getFileShareSnapshotCreateRequest(ctx, resourceGroupName, resourceName, name, options) + if err != nil { + return FileSharesClientGetFileShareSnapshotResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FileSharesClientGetFileShareSnapshotResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientGetFileShareSnapshotResponse{}, err + } + resp, err := client.getFileShareSnapshotHandleResponse(httpResp) + return resp, err +} + +// getFileShareSnapshotCreateRequest creates the GetFileShareSnapshot request. +func (client *FileSharesClient) getFileShareSnapshotCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, name string, _ *FileSharesClientGetFileShareSnapshotOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}/fileShareSnapshots/{name}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getFileShareSnapshotHandleResponse handles the GetFileShareSnapshot response. +func (client *FileSharesClient) getFileShareSnapshotHandleResponse(resp *http.Response) (FileSharesClientGetFileShareSnapshotResponse, error) { + result := FileSharesClientGetFileShareSnapshotResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FileShareSnapshot); err != nil { + return FileSharesClientGetFileShareSnapshotResponse{}, err + } + return result, nil +} + +// NewListByFileSharePager - List FileShareSnapshot by FileShare. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - options - FileSharesClientListByFileShareOptions contains the optional parameters for the FileSharesClient.NewListByFileSharePager +// method. +func (client *FileSharesClient) NewListByFileSharePager(resourceGroupName string, resourceName string, options *FileSharesClientListByFileShareOptions) *runtime.Pager[FileSharesClientListByFileShareResponse] { + return runtime.NewPager(runtime.PagingHandler[FileSharesClientListByFileShareResponse]{ + More: func(page FileSharesClientListByFileShareResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FileSharesClientListByFileShareResponse) (FileSharesClientListByFileShareResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FileSharesClient.NewListByFileSharePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByFileShareCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) + if err != nil { + return FileSharesClientListByFileShareResponse{}, err + } + return client.listByFileShareHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByFileShareCreateRequest creates the ListByFileShare request. +func (client *FileSharesClient) listByFileShareCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *FileSharesClientListByFileShareOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}/fileShareSnapshots" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByFileShareHandleResponse handles the ListByFileShare response. +func (client *FileSharesClient) listByFileShareHandleResponse(resp *http.Response) (FileSharesClientListByFileShareResponse, error) { + result := FileSharesClientListByFileShareResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FileShareSnapshotListResult); err != nil { + return FileSharesClientListByFileShareResponse{}, err + } + return result, nil +} + +// NewListByParentPager - List FileShare resources by resource group +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - FileSharesClientListByParentOptions contains the optional parameters for the FileSharesClient.NewListByParentPager +// method. +func (client *FileSharesClient) NewListByParentPager(resourceGroupName string, options *FileSharesClientListByParentOptions) *runtime.Pager[FileSharesClientListByParentResponse] { + return runtime.NewPager(runtime.PagingHandler[FileSharesClientListByParentResponse]{ + More: func(page FileSharesClientListByParentResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FileSharesClientListByParentResponse) (FileSharesClientListByParentResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FileSharesClient.NewListByParentPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByParentCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return FileSharesClientListByParentResponse{}, err + } + return client.listByParentHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByParentCreateRequest creates the ListByParent request. +func (client *FileSharesClient) listByParentCreateRequest(ctx context.Context, resourceGroupName string, _ *FileSharesClientListByParentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByParentHandleResponse handles the ListByParent response. +func (client *FileSharesClient) listByParentHandleResponse(resp *http.Response) (FileSharesClientListByParentResponse, error) { + result := FileSharesClientListByParentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FileShareListResult); err != nil { + return FileSharesClientListByParentResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List FileShare resources by subscription ID +// +// Generated from API version 2024-01-01-preview +// - options - FileSharesClientListBySubscriptionOptions contains the optional parameters for the FileSharesClient.NewListBySubscriptionPager +// method. +func (client *FileSharesClient) NewListBySubscriptionPager(options *FileSharesClientListBySubscriptionOptions) *runtime.Pager[FileSharesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[FileSharesClientListBySubscriptionResponse]{ + More: func(page FileSharesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FileSharesClientListBySubscriptionResponse) (FileSharesClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FileSharesClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return FileSharesClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *FileSharesClient) listBySubscriptionCreateRequest(ctx context.Context, _ *FileSharesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.FileShares/fileShares" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *FileSharesClient) listBySubscriptionHandleResponse(resp *http.Response) (FileSharesClientListBySubscriptionResponse, error) { + result := FileSharesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FileShareListResult); err != nil { + return FileSharesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a FileShare +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - properties - The resource properties to be updated. +// - options - FileSharesClientBeginUpdateOptions contains the optional parameters for the FileSharesClient.BeginUpdate method. +func (client *FileSharesClient) BeginUpdate(ctx context.Context, resourceGroupName string, resourceName string, properties FileShareUpdate, options *FileSharesClientBeginUpdateOptions) (*runtime.Poller[FileSharesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, resourceName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSharesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FileSharesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a FileShare +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +func (client *FileSharesClient) update(ctx context.Context, resourceGroupName string, resourceName string, properties FileShareUpdate, options *FileSharesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "FileSharesClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *FileSharesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, properties FileShareUpdate, _ *FileSharesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// BeginUpdateFileShareSnapshot - Update a FileShareSnapshot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The resource name of the file share, as seen by the administrator through Azure Resource Manager. +// - name - The name of the FileShareSnapshot +// - properties - The resource properties to be updated. +// - options - FileSharesClientBeginUpdateFileShareSnapshotOptions contains the optional parameters for the FileSharesClient.BeginUpdateFileShareSnapshot +// method. +func (client *FileSharesClient) BeginUpdateFileShareSnapshot(ctx context.Context, resourceGroupName string, resourceName string, name string, properties FileShareSnapshotUpdate, options *FileSharesClientBeginUpdateFileShareSnapshotOptions) (*runtime.Poller[FileSharesClientUpdateFileShareSnapshotResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.updateFileShareSnapshot(ctx, resourceGroupName, resourceName, name, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSharesClientUpdateFileShareSnapshotResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FileSharesClientUpdateFileShareSnapshotResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// UpdateFileShareSnapshot - Update a FileShareSnapshot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-01-01-preview +func (client *FileSharesClient) updateFileShareSnapshot(ctx context.Context, resourceGroupName string, resourceName string, name string, properties FileShareSnapshotUpdate, options *FileSharesClientBeginUpdateFileShareSnapshotOptions) (*http.Response, error) { + var err error + const operationName = "FileSharesClient.BeginUpdateFileShareSnapshot" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateFileShareSnapshotCreateRequest(ctx, resourceGroupName, resourceName, name, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateFileShareSnapshotCreateRequest creates the UpdateFileShareSnapshot request. +func (client *FileSharesClient) updateFileShareSnapshotCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, name string, properties FileShareSnapshotUpdate, _ *FileSharesClientBeginUpdateFileShareSnapshotOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}/fileShareSnapshots/{name}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/fileshares_client_example_test.go b/sdk/resourcemanager/fileshares/armfileshares/fileshares_client_example_test.go new file mode 100644 index 000000000000..6935255e531a --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/fileshares_client_example_test.go @@ -0,0 +1,841 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares" + "log" +) + +// Generated from example definition: 2024-01-01-preview/FileShares_CheckNameAvailability_MaximumSet_Gen.json +func ExampleFileSharesClient_CheckNameAvailability_fileSharesCheckNameAvailabilityMaximumSetGenGeneratedByMaximumSetRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFileSharesClient().CheckNameAvailability(ctx, "westus", armfileshares.CheckNameAvailabilityRequest{ + Name: to.Ptr("vmwdhkiwetidjwivkh"), + Type: to.Ptr("akrkqjmn"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armfileshares.FileSharesClientCheckNameAvailabilityResponse{ + // CheckNameAvailabilityResponse: &armfileshares.CheckNameAvailabilityResponse{ + // NameAvailable: to.Ptr(true), + // Reason: to.Ptr(armfileshares.CheckNameAvailabilityReasonInvalid), + // Message: to.Ptr("lmqlk"), + // }, + // } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_CheckNameAvailability_MinimumSet_Gen.json +func ExampleFileSharesClient_CheckNameAvailability_fileSharesCheckNameAvailabilityMaximumSetGenGeneratedByMinimumSetRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFileSharesClient().CheckNameAvailability(ctx, "westus", armfileshares.CheckNameAvailabilityRequest{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armfileshares.FileSharesClientCheckNameAvailabilityResponse{ + // CheckNameAvailabilityResponse: &armfileshares.CheckNameAvailabilityResponse{ + // }, + // } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_CreateOrUpdate_MaximumSet_Gen.json +func ExampleFileSharesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFileSharesClient().BeginCreateOrUpdate(ctx, "rgfileshares", "testfileshare", armfileshares.FileShare{ + Properties: &armfileshares.FileShareProperties{ + MountName: to.Ptr("kyujsrfk"), + MediaTier: to.Ptr(armfileshares.MediaTierSSD), + Redundancy: to.Ptr(armfileshares.RedundancyLocal), + Protocol: to.Ptr(armfileshares.ProtocolNFS), + ProvisionedStorageGiB: to.Ptr[int32](15), + ProvisionedIOPerSec: to.Ptr[int32](29), + ProvisionedThroughputMiBPerSec: to.Ptr[int32](25), + NfsProtocolProperties: &armfileshares.NfsProtocolProperties{ + RootSquash: to.Ptr(armfileshares.ShareRootSquashNoRootSquash), + }, + PublicAccessProperties: &armfileshares.PublicAccessProperties{ + AllowedSubnets: []*string{ + to.Ptr("pvjhqlnqfiubvbfcggthlpy"), + }, + }, + PublicNetworkAccess: to.Ptr(armfileshares.PublicNetworkAccessEnabled), + }, + Tags: map[string]*string{ + "key1961": to.Ptr("p"), + }, + Location: to.Ptr("xrrekltkvmzdinob"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armfileshares.FileSharesClientCreateOrUpdateResponse{ + // FileShare: &armfileshares.FileShare{ + // Properties: &armfileshares.FileShareProperties{ + // MountName: to.Ptr("kyujsrfk"), + // HostName: to.Ptr("kivhbjhhzdiycggwbawziu"), + // MediaTier: to.Ptr(armfileshares.MediaTierSSD), + // Redundancy: to.Ptr(armfileshares.RedundancyLocal), + // Protocol: to.Ptr(armfileshares.ProtocolNFS), + // ProvisionedStorageGiB: to.Ptr[int32](15), + // ProvisionedStorageNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.149Z"); return t}()), + // ProvisionedIOPerSec: to.Ptr[int32](29), + // ProvisionedIOPerSecNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // ProvisionedThroughputMiBPerSec: to.Ptr[int32](25), + // ProvisionedThroughputNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // IncludedBurstIOPerSec: to.Ptr[int32](89085), + // MaxBurstIOPerSecCredits: to.Ptr[int64](0), + // NfsProtocolProperties: &armfileshares.NfsProtocolProperties{ + // RootSquash: to.Ptr(armfileshares.ShareRootSquashNoRootSquash), + // }, + // PublicAccessProperties: &armfileshares.PublicAccessProperties{ + // AllowedSubnets: []*string{ + // to.Ptr("pvjhqlnqfiubvbfcggthlpy"), + // }, + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armfileshares.PublicNetworkAccessEnabled), + // PrivateEndpointConnections: []*armfileshares.PrivateEndpointConnection{ + // { + // Properties: &armfileshares.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("fileshares"), + // }, + // PrivateEndpoint: &armfileshares.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), + // }, + // PrivateLinkServiceConnectionState: &armfileshares.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armfileshares.PrivateEndpointServiceConnectionStatusPending), + // Description: to.Ptr("nhata"), + // ActionsRequired: to.Ptr("seyoojnwbtmcegqbsvpsofboc"), + // }, + // ProvisioningState: to.Ptr(armfileshares.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.FileShares/fileShares/testresourcename/privateEndpointConnections/privateEndpointConnectionName"), + // Name: to.Ptr("ukgsebzwjbtporzza"), + // Type: to.Ptr("oyfdiyedpaykrg"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key1961": to.Ptr("p"), + // }, + // Location: to.Ptr("xrrekltkvmzdinob"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare"), + // Name: to.Ptr("lwvxc"), + // Type: to.Ptr("etietawcvvuzkvfrqsdlxfgavxv"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_CreateOrUpdateFileShareSnapshot_MaximumSet_Gen.json +func ExampleFileSharesClient_CreateOrUpdateFileShareSnapshot() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFileSharesClient().CreateOrUpdateFileShareSnapshot(ctx, "rgfileshares", "testfileshare", "testfilesharesnapshot", armfileshares.FileShareSnapshot{ + Properties: &armfileshares.FileShareSnapshotProperties{ + Metadata: map[string]*string{ + "key5497": to.Ptr("xxznaauato"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armfileshares.FileSharesClientCreateOrUpdateFileShareSnapshotResponse{ + // FileShareSnapshot: &armfileshares.FileShareSnapshot{ + // Properties: &armfileshares.FileShareSnapshotProperties{ + // SnapshotTime: to.Ptr("pc"), + // InitiatorID: to.Ptr("nckiqfg"), + // Metadata: map[string]*string{ + // "key5497": to.Ptr("xxznaauato"), + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare/fileShareSnapshots/testfilesharesnapshot"), + // Name: to.Ptr("nneoakpugzjbalgyieeyz"), + // Type: to.Ptr("fmqfludbm"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_Delete_MaximumSet_Gen.json +func ExampleFileSharesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFileSharesClient().BeginDelete(ctx, "rgfileshares", "testfileshare", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_DeleteFileShareSnapshot_MaximumSet_Gen.json +func ExampleFileSharesClient_BeginDeleteFileShareSnapshot() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFileSharesClient().BeginDeleteFileShareSnapshot(ctx, "rgfileshares", "testfileshare", "testfilesharesnapshot", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_Get_MaximumSet_Gen.json +func ExampleFileSharesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFileSharesClient().Get(ctx, "rgfileshares", "testfileshare", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armfileshares.FileSharesClientGetResponse{ + // FileShare: &armfileshares.FileShare{ + // Properties: &armfileshares.FileShareProperties{ + // MountName: to.Ptr("kyujsrfk"), + // HostName: to.Ptr("kivhbjhhzdiycggwbawziu"), + // MediaTier: to.Ptr(armfileshares.MediaTierSSD), + // Redundancy: to.Ptr(armfileshares.RedundancyLocal), + // Protocol: to.Ptr(armfileshares.ProtocolNFS), + // ProvisionedStorageGiB: to.Ptr[int32](15), + // ProvisionedStorageNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.149Z"); return t}()), + // ProvisionedIOPerSec: to.Ptr[int32](29), + // ProvisionedIOPerSecNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // ProvisionedThroughputMiBPerSec: to.Ptr[int32](25), + // ProvisionedThroughputNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // IncludedBurstIOPerSec: to.Ptr[int32](89085), + // MaxBurstIOPerSecCredits: to.Ptr[int64](0), + // NfsProtocolProperties: &armfileshares.NfsProtocolProperties{ + // RootSquash: to.Ptr(armfileshares.ShareRootSquashNoRootSquash), + // }, + // PublicAccessProperties: &armfileshares.PublicAccessProperties{ + // AllowedSubnets: []*string{ + // to.Ptr("pvjhqlnqfiubvbfcggthlpy"), + // }, + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armfileshares.PublicNetworkAccessEnabled), + // PrivateEndpointConnections: []*armfileshares.PrivateEndpointConnection{ + // { + // Properties: &armfileshares.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("fileshares"), + // }, + // PrivateEndpoint: &armfileshares.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), + // }, + // PrivateLinkServiceConnectionState: &armfileshares.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armfileshares.PrivateEndpointServiceConnectionStatusPending), + // Description: to.Ptr("nhata"), + // ActionsRequired: to.Ptr("seyoojnwbtmcegqbsvpsofboc"), + // }, + // ProvisioningState: to.Ptr(armfileshares.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.FileShares/fileShares/testresourcename/privateEndpointConnections/privateEndpointConnectionName"), + // Name: to.Ptr("ukgsebzwjbtporzza"), + // Type: to.Ptr("oyfdiyedpaykrg"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key1961": to.Ptr("p"), + // }, + // Location: to.Ptr("xrrekltkvmzdinob"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare"), + // Name: to.Ptr("lwvxc"), + // Type: to.Ptr("etietawcvvuzkvfrqsdlxfgavxv"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_GetFileShareSnapshot_MaximumSet_Gen.json +func ExampleFileSharesClient_GetFileShareSnapshot() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFileSharesClient().GetFileShareSnapshot(ctx, "rgfileshares", "testfileshare", "testfilesharesnapshot", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armfileshares.FileSharesClientGetFileShareSnapshotResponse{ + // FileShareSnapshot: &armfileshares.FileShareSnapshot{ + // Properties: &armfileshares.FileShareSnapshotProperties{ + // SnapshotTime: to.Ptr("pc"), + // InitiatorID: to.Ptr("nckiqfg"), + // Metadata: map[string]*string{ + // "key5497": to.Ptr("xxznaauato"), + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare/fileShareSnapshots/testfilesharesnapshot"), + // Name: to.Ptr("nneoakpugzjbalgyieeyz"), + // Type: to.Ptr("fmqfludbm"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_ListByFileShare_MaximumSet_Gen.json +func ExampleFileSharesClient_NewListByFileSharePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("09A2620A-99C9-4A63-A89E-AB06AA59A998", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFileSharesClient().NewListByFileSharePager("rgfileshares", "testfilesharesnapshot", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armfileshares.FileSharesClientListByFileShareResponse{ + // FileShareSnapshotListResult: armfileshares.FileShareSnapshotListResult{ + // Value: []*armfileshares.FileShareSnapshot{ + // { + // Properties: &armfileshares.FileShareSnapshotProperties{ + // SnapshotTime: to.Ptr("tey"), + // InitiatorID: to.Ptr("i"), + // Metadata: map[string]*string{ + // "key2374": to.Ptr("enznkeuacgnsdlcgcg"), + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare/fileShareSnapshots/testfilesharesnapshot"), + // Name: to.Ptr("fhjirzquakiktrsyqmfubedzowe"), + // Type: to.Ptr("dkksokbqykeajfh"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("smrgywfkjcxlor"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-30T15:00:13.612Z"); return t}()), + // LastModifiedBy: to.Ptr("dkduwnwucpvqd"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-30T15:00:13.612Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_ListByParent_MaximumSet_Gen.json +func ExampleFileSharesClient_NewListByParentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFileSharesClient().NewListByParentPager("rgfileshares", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armfileshares.FileSharesClientListByParentResponse{ + // FileShareListResult: armfileshares.FileShareListResult{ + // Value: []*armfileshares.FileShare{ + // { + // Properties: &armfileshares.FileShareProperties{ + // MountName: to.Ptr("kyujsrfk"), + // HostName: to.Ptr("kivhbjhhzdiycggwbawziu"), + // MediaTier: to.Ptr(armfileshares.MediaTierSSD), + // Redundancy: to.Ptr(armfileshares.RedundancyLocal), + // Protocol: to.Ptr(armfileshares.ProtocolNFS), + // ProvisionedStorageGiB: to.Ptr[int32](15), + // ProvisionedStorageNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.149Z"); return t}()), + // ProvisionedIOPerSec: to.Ptr[int32](29), + // ProvisionedIOPerSecNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // ProvisionedThroughputMiBPerSec: to.Ptr[int32](25), + // ProvisionedThroughputNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // IncludedBurstIOPerSec: to.Ptr[int32](89085), + // MaxBurstIOPerSecCredits: to.Ptr[int64](0), + // NfsProtocolProperties: &armfileshares.NfsProtocolProperties{ + // RootSquash: to.Ptr(armfileshares.ShareRootSquashNoRootSquash), + // }, + // PublicAccessProperties: &armfileshares.PublicAccessProperties{ + // AllowedSubnets: []*string{ + // to.Ptr("pvjhqlnqfiubvbfcggthlpy"), + // }, + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armfileshares.PublicNetworkAccessEnabled), + // PrivateEndpointConnections: []*armfileshares.PrivateEndpointConnection{ + // { + // Properties: &armfileshares.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("fileshares"), + // }, + // PrivateEndpoint: &armfileshares.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), + // }, + // PrivateLinkServiceConnectionState: &armfileshares.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armfileshares.PrivateEndpointServiceConnectionStatusPending), + // Description: to.Ptr("nhata"), + // ActionsRequired: to.Ptr("seyoojnwbtmcegqbsvpsofboc"), + // }, + // ProvisioningState: to.Ptr(armfileshares.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.FileShares/fileShares/testresourcename/privateEndpointConnections/privateEndpointConnectionName"), + // Name: to.Ptr("ukgsebzwjbtporzza"), + // Type: to.Ptr("oyfdiyedpaykrg"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key1961": to.Ptr("p"), + // }, + // Location: to.Ptr("xrrekltkvmzdinob"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare"), + // Name: to.Ptr("lwvxc"), + // Type: to.Ptr("etietawcvvuzkvfrqsdlxfgavxv"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_ListBySubscription_MaximumSet_Gen.json +func ExampleFileSharesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFileSharesClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armfileshares.FileSharesClientListBySubscriptionResponse{ + // FileShareListResult: armfileshares.FileShareListResult{ + // Value: []*armfileshares.FileShare{ + // { + // Properties: &armfileshares.FileShareProperties{ + // MountName: to.Ptr("kyujsrfk"), + // HostName: to.Ptr("kivhbjhhzdiycggwbawziu"), + // MediaTier: to.Ptr(armfileshares.MediaTierSSD), + // Redundancy: to.Ptr(armfileshares.RedundancyLocal), + // Protocol: to.Ptr(armfileshares.ProtocolNFS), + // ProvisionedStorageGiB: to.Ptr[int32](15), + // ProvisionedStorageNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.149Z"); return t}()), + // ProvisionedIOPerSec: to.Ptr[int32](29), + // ProvisionedIOPerSecNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // ProvisionedThroughputMiBPerSec: to.Ptr[int32](25), + // ProvisionedThroughputNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // IncludedBurstIOPerSec: to.Ptr[int32](89085), + // MaxBurstIOPerSecCredits: to.Ptr[int64](0), + // NfsProtocolProperties: &armfileshares.NfsProtocolProperties{ + // RootSquash: to.Ptr(armfileshares.ShareRootSquashNoRootSquash), + // }, + // PublicAccessProperties: &armfileshares.PublicAccessProperties{ + // AllowedSubnets: []*string{ + // to.Ptr("pvjhqlnqfiubvbfcggthlpy"), + // }, + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armfileshares.PublicNetworkAccessEnabled), + // PrivateEndpointConnections: []*armfileshares.PrivateEndpointConnection{ + // { + // Properties: &armfileshares.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("fileshares"), + // }, + // PrivateEndpoint: &armfileshares.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), + // }, + // PrivateLinkServiceConnectionState: &armfileshares.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armfileshares.PrivateEndpointServiceConnectionStatusPending), + // Description: to.Ptr("nhata"), + // ActionsRequired: to.Ptr("seyoojnwbtmcegqbsvpsofboc"), + // }, + // ProvisioningState: to.Ptr(armfileshares.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.FileShares/fileShares/testresourcename/privateEndpointConnections/privateEndpointConnectionName"), + // Name: to.Ptr("ukgsebzwjbtporzza"), + // Type: to.Ptr("oyfdiyedpaykrg"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key1961": to.Ptr("p"), + // }, + // Location: to.Ptr("xrrekltkvmzdinob"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare"), + // Name: to.Ptr("lwvxc"), + // Type: to.Ptr("etietawcvvuzkvfrqsdlxfgavxv"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_Update_MaximumSet_Gen.json +func ExampleFileSharesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFileSharesClient().BeginUpdate(ctx, "rgfileshares", "testfileshare", armfileshares.FileShareUpdate{ + Tags: map[string]*string{ + "key9986": to.Ptr("aq"), + }, + Properties: &armfileshares.FileShareUpdateProperties{ + ProvisionedStorageGiB: to.Ptr[int32](20), + ProvisionedIOPerSec: to.Ptr[int32](19), + ProvisionedThroughputMiBPerSec: to.Ptr[int32](27), + NfsProtocolProperties: &armfileshares.NfsProtocolProperties{ + RootSquash: to.Ptr(armfileshares.ShareRootSquashNoRootSquash), + }, + PublicAccessProperties: &armfileshares.PublicAccessProperties{ + AllowedSubnets: []*string{ + to.Ptr("pvjhqlnqfiubvbfcggthlpy"), + }, + }, + PublicNetworkAccess: to.Ptr(armfileshares.PublicNetworkAccessEnabled), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armfileshares.FileSharesClientUpdateResponse{ + // FileShare: &armfileshares.FileShare{ + // Properties: &armfileshares.FileShareProperties{ + // MountName: to.Ptr("kyujsrfk"), + // HostName: to.Ptr("kivhbjhhzdiycggwbawziu"), + // MediaTier: to.Ptr(armfileshares.MediaTierSSD), + // Redundancy: to.Ptr(armfileshares.RedundancyLocal), + // Protocol: to.Ptr(armfileshares.ProtocolNFS), + // ProvisionedStorageGiB: to.Ptr[int32](15), + // ProvisionedStorageNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.149Z"); return t}()), + // ProvisionedIOPerSec: to.Ptr[int32](29), + // ProvisionedIOPerSecNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // ProvisionedThroughputMiBPerSec: to.Ptr[int32](25), + // ProvisionedThroughputNextAllowedDowngrade: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.150Z"); return t}()), + // IncludedBurstIOPerSec: to.Ptr[int32](89085), + // MaxBurstIOPerSecCredits: to.Ptr[int64](0), + // NfsProtocolProperties: &armfileshares.NfsProtocolProperties{ + // RootSquash: to.Ptr(armfileshares.ShareRootSquashNoRootSquash), + // }, + // PublicAccessProperties: &armfileshares.PublicAccessProperties{ + // AllowedSubnets: []*string{ + // to.Ptr("pvjhqlnqfiubvbfcggthlpy"), + // }, + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armfileshares.PublicNetworkAccessEnabled), + // PrivateEndpointConnections: []*armfileshares.PrivateEndpointConnection{ + // { + // Properties: &armfileshares.PrivateEndpointConnectionProperties{ + // GroupIDs: []*string{ + // to.Ptr("fileshares"), + // }, + // PrivateEndpoint: &armfileshares.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), + // }, + // PrivateLinkServiceConnectionState: &armfileshares.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armfileshares.PrivateEndpointServiceConnectionStatusPending), + // Description: to.Ptr("nhata"), + // ActionsRequired: to.Ptr("seyoojnwbtmcegqbsvpsofboc"), + // }, + // ProvisioningState: to.Ptr(armfileshares.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.FileShares/fileShares/testresourcename/privateEndpointConnections/privateEndpointConnectionName"), + // Name: to.Ptr("ukgsebzwjbtporzza"), + // Type: to.Ptr("oyfdiyedpaykrg"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key1961": to.Ptr("p"), + // }, + // Location: to.Ptr("xrrekltkvmzdinob"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare"), + // Name: to.Ptr("lwvxc"), + // Type: to.Ptr("etietawcvvuzkvfrqsdlxfgavxv"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-01-01-preview/FileShares_UpdateFileShareSnapshot_MaximumSet_Gen.json +func ExampleFileSharesClient_BeginUpdateFileShareSnapshot() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("AD98EFD8-D1E9-4F38-A862-E066114E49EE", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFileSharesClient().BeginUpdateFileShareSnapshot(ctx, "rgfileshares", "testfileshare", "testfilesharesnapshot", armfileshares.FileShareSnapshotUpdate{ + Properties: &armfileshares.FileShareSnapshotUpdateProperties{ + Metadata: map[string]*string{ + "key5497": to.Ptr("xxznaauato"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armfileshares.FileSharesClientUpdateFileShareSnapshotResponse{ + // FileShareSnapshot: &armfileshares.FileShareSnapshot{ + // Properties: &armfileshares.FileShareSnapshotProperties{ + // SnapshotTime: to.Ptr("pc"), + // InitiatorID: to.Ptr("nckiqfg"), + // Metadata: map[string]*string{ + // "key5497": to.Ptr("xxznaauato"), + // }, + // ProvisioningState: to.Ptr(armfileshares.FileShareProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.FileShares/fileShares/testfileshare/fileShareSnapshots/testfilesharesnapshot"), + // Name: to.Ptr("nneoakpugzjbalgyieeyz"), + // Type: to.Ptr("fmqfludbm"), + // SystemData: &armfileshares.SystemData{ + // CreatedBy: to.Ptr("qh"), + // CreatedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.151Z"); return t}()), + // LastModifiedBy: to.Ptr("uqmcadaewfdikvhqkwl"), + // LastModifiedByType: to.Ptr(armfileshares.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-29T23:26:28.152Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/go.mod b/sdk/resourcemanager/fileshares/armfileshares/go.mod new file mode 100644 index 000000000000..954702224619 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/go.mod @@ -0,0 +1,23 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares + +go 1.23.0 + +toolchain go1.23.8 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/fileshares/armfileshares/go.sum b/sdk/resourcemanager/fileshares/armfileshares/go.sum new file mode 100644 index 000000000000..1f92486fbbcf --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/go.sum @@ -0,0 +1,33 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/fileshares/armfileshares/models.go b/sdk/resourcemanager/fileshares/armfileshares/models.go new file mode 100644 index 000000000000..91688a8b54cf --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/models.go @@ -0,0 +1,343 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +import "time" + +// CheckNameAvailabilityRequest - The check availability request body. +type CheckNameAvailabilityRequest struct { + // The name of the resource for which availability needs to be checked. + Name *string + + // The resource type. + Type *string +} + +// CheckNameAvailabilityResponse - The check availability result. +type CheckNameAvailabilityResponse struct { + // Detailed reason why the given name is not available. + Message *string + + // Indicates if the resource name is available. + NameAvailable *bool + + // The reason why the given name is not available. + Reason *CheckNameAvailabilityReason +} + +// FileShare - File share resource +type FileShare struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *FileShareProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; The resource name of the file share, as seen by the administrator through Azure Resource Manager. + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// FileShareListResult - The response of a FileShare list operation. +type FileShareListResult struct { + // REQUIRED; The FileShare items on this page + Value []*FileShare + + // The link to the next page of items + NextLink *string +} + +// FileShareProperties - File share properties +type FileShareProperties struct { + // The storage media tier of the file share. + MediaTier *MediaTier + + // The name of the file share as seen by the end user when mounting the share, such as in a URI or UNC format in their operating + // system. + MountName *string + + // Protocol settings specific NFS. + NfsProtocolProperties *NfsProtocolProperties + + // The file sharing protocol for this file share. + Protocol *Protocol + + // The provisioned IO / sec of the share. + ProvisionedIOPerSec *int32 + + // The provisioned storage size of the share in GiB (1 GiB is 1024^3 bytes or 1073741824 bytes). A component of the file share's + // bill is the provisioned storage, regardless of the amount of used storage. + ProvisionedStorageGiB *int32 + + // The provisioned throughput / sec of the share. + ProvisionedThroughputMiBPerSec *int32 + + // The set of properties for control public access. + PublicAccessProperties *PublicAccessProperties + + // Gets or sets allow or disallow public network access to azure managed file share + PublicNetworkAccess *PublicNetworkAccess + + // The chosen redundancy level of the file share. + Redundancy *Redundancy + + // READ-ONLY; The host name of the file share. + HostName *string + + // READ-ONLY; Burst IOPS are extra buffer IOPS enabling you to consume more than your provisioned IOPS for a short period + // of time, depending on the burst credits available for your share. + IncludedBurstIOPerSec *int32 + + // READ-ONLY; Max burst IOPS credits shows the maximum number of burst credits the share can have at the current IOPS provisioning + // level. + MaxBurstIOPerSecCredits *int64 + + // READ-ONLY; The list of associated private endpoint connections. + PrivateEndpointConnections []*PrivateEndpointConnection + + // READ-ONLY; A date/time value that specifies when the provisioned IOPS for the file share is permitted to be reduced. + ProvisionedIOPerSecNextAllowedDowngrade *time.Time + + // READ-ONLY; A date/time value that specifies when the provisioned storage for the file share is permitted to be reduced. + ProvisionedStorageNextAllowedDowngrade *time.Time + + // READ-ONLY; A date/time value that specifies when the provisioned throughput for the file share is permitted to be reduced. + ProvisionedThroughputNextAllowedDowngrade *time.Time + + // READ-ONLY; The status of the last operation. + ProvisioningState *FileShareProvisioningState +} + +// FileShareSnapshot resource +type FileShareSnapshot struct { + // The resource-specific properties for this resource. + Properties *FileShareSnapshotProperties + + // READ-ONLY; The name of the FileShareSnapshot + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// FileShareSnapshotListResult - The response of a FileShareSnapshot list operation. +type FileShareSnapshotListResult struct { + // REQUIRED; The FileShareSnapshot items on this page + Value []*FileShareSnapshot + + // The link to the next page of items + NextLink *string +} + +// FileShareSnapshotProperties - FileShareSnapshot properties +type FileShareSnapshotProperties struct { + // The metadata + Metadata map[string]*string + + // READ-ONLY; The initiator of the FileShareSnapshot + InitiatorID *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *FileShareProvisioningState + + // READ-ONLY; The FileShareSnapshot time in UTC in string representation + SnapshotTime *string +} + +// FileShareSnapshotUpdate - The type used for update operations of the FileShareSnapshot. +type FileShareSnapshotUpdate struct { + // The resource-specific properties for this resource. + Properties *FileShareSnapshotUpdateProperties +} + +// FileShareSnapshotUpdateProperties - The updatable properties of the FileShareSnapshot. +type FileShareSnapshotUpdateProperties struct { + // The metadata + Metadata map[string]*string +} + +// FileShareUpdate - The type used for update operations of the FileShare. +type FileShareUpdate struct { + // The resource-specific properties for this resource. + Properties *FileShareUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// FileShareUpdateProperties - The updatable properties of the FileShare. +type FileShareUpdateProperties struct { + // Protocol settings specific NFS. + NfsProtocolProperties *NfsProtocolProperties + + // The provisioned IO / sec of the share. + ProvisionedIOPerSec *int32 + + // The provisioned storage size of the share in GiB (1 GiB is 1024^3 bytes or 1073741824 bytes). A component of the file share's + // bill is the provisioned storage, regardless of the amount of used storage. + ProvisionedStorageGiB *int32 + + // The provisioned throughput / sec of the share. + ProvisionedThroughputMiBPerSec *int32 + + // The set of properties for control public access. + PublicAccessProperties *PublicAccessProperties + + // Gets or sets allow or disallow public network access to azure managed file share + PublicNetworkAccess *PublicNetworkAccess +} + +// NfsProtocolProperties - Properties specific to the NFS protocol. +type NfsProtocolProperties struct { + // Root squash defines how root users on clients are mapped to the NFS share. + RootSquash *ShareRootSquash +} + +// Operation - REST API Operation +// +// Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + // Resource Manager/control-plane operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for and operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // REQUIRED; The Operation items on this page + Value []*Operation + + // The link to the next page of items + NextLink *string +} + +// PrivateEndpoint - The private endpoint resource. +type PrivateEndpoint struct { + // READ-ONLY; The resource identifier of the private endpoint + ID *string +} + +// PrivateEndpointConnection - The private endpoint connection resource +type PrivateEndpointConnection struct { + // The private endpoint connection properties + Properties *PrivateEndpointConnectionProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PrivateEndpointConnectionProperties - Properties of the private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // REQUIRED; A collection of information about the state of the connection between service consumer and provider. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState + + // The private endpoint resource. + PrivateEndpoint *PrivateEndpoint + + // READ-ONLY; The group ids for the private endpoint resource. + GroupIDs []*string + + // READ-ONLY; The provisioning state of the private endpoint connection resource. + ProvisioningState *PrivateEndpointConnectionProvisioningState +} + +// PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer +// and provider. +type PrivateLinkServiceConnectionState struct { + // A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string + + // The reason for approval/rejection of the connection. + Description *string + + // Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + Status *PrivateEndpointServiceConnectionStatus +} + +// PublicAccessProperties - The set of properties for control public access. +type PublicAccessProperties struct { + // The allowed set of subnets when access is restricted. + AllowedSubnets []*string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/models_serde.go b/sdk/resourcemanager/fileshares/armfileshares/models_serde.go new file mode 100644 index 000000000000..c166ea2a4c68 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/models_serde.go @@ -0,0 +1,878 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. +func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityRequest. +func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponse. +func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponse. +func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShare. +func (f FileShare) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "location", f.Location) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "tags", f.Tags) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShare. +func (f *FileShare) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &f.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareListResult. +func (f FileShareListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareListResult. +func (f *FileShareListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareProperties. +func (f FileShareProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hostName", f.HostName) + populate(objectMap, "includedBurstIOPerSec", f.IncludedBurstIOPerSec) + populate(objectMap, "maxBurstIOPerSecCredits", f.MaxBurstIOPerSecCredits) + populate(objectMap, "mediaTier", f.MediaTier) + populate(objectMap, "mountName", f.MountName) + populate(objectMap, "nfsProtocolProperties", f.NfsProtocolProperties) + populate(objectMap, "privateEndpointConnections", f.PrivateEndpointConnections) + populate(objectMap, "protocol", f.Protocol) + populate(objectMap, "provisionedIOPerSec", f.ProvisionedIOPerSec) + populateDateTimeRFC3339(objectMap, "provisionedIOPerSecNextAllowedDowngrade", f.ProvisionedIOPerSecNextAllowedDowngrade) + populate(objectMap, "provisionedStorageGiB", f.ProvisionedStorageGiB) + populateDateTimeRFC3339(objectMap, "provisionedStorageNextAllowedDowngrade", f.ProvisionedStorageNextAllowedDowngrade) + populate(objectMap, "provisionedThroughputMiBPerSec", f.ProvisionedThroughputMiBPerSec) + populateDateTimeRFC3339(objectMap, "provisionedThroughputNextAllowedDowngrade", f.ProvisionedThroughputNextAllowedDowngrade) + populate(objectMap, "provisioningState", f.ProvisioningState) + populate(objectMap, "publicAccessProperties", f.PublicAccessProperties) + populate(objectMap, "publicNetworkAccess", f.PublicNetworkAccess) + populate(objectMap, "redundancy", f.Redundancy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareProperties. +func (f *FileShareProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hostName": + err = unpopulate(val, "HostName", &f.HostName) + delete(rawMsg, key) + case "includedBurstIOPerSec": + err = unpopulate(val, "IncludedBurstIOPerSec", &f.IncludedBurstIOPerSec) + delete(rawMsg, key) + case "maxBurstIOPerSecCredits": + err = unpopulate(val, "MaxBurstIOPerSecCredits", &f.MaxBurstIOPerSecCredits) + delete(rawMsg, key) + case "mediaTier": + err = unpopulate(val, "MediaTier", &f.MediaTier) + delete(rawMsg, key) + case "mountName": + err = unpopulate(val, "MountName", &f.MountName) + delete(rawMsg, key) + case "nfsProtocolProperties": + err = unpopulate(val, "NfsProtocolProperties", &f.NfsProtocolProperties) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, "PrivateEndpointConnections", &f.PrivateEndpointConnections) + delete(rawMsg, key) + case "protocol": + err = unpopulate(val, "Protocol", &f.Protocol) + delete(rawMsg, key) + case "provisionedIOPerSec": + err = unpopulate(val, "ProvisionedIOPerSec", &f.ProvisionedIOPerSec) + delete(rawMsg, key) + case "provisionedIOPerSecNextAllowedDowngrade": + err = unpopulateDateTimeRFC3339(val, "ProvisionedIOPerSecNextAllowedDowngrade", &f.ProvisionedIOPerSecNextAllowedDowngrade) + delete(rawMsg, key) + case "provisionedStorageGiB": + err = unpopulate(val, "ProvisionedStorageGiB", &f.ProvisionedStorageGiB) + delete(rawMsg, key) + case "provisionedStorageNextAllowedDowngrade": + err = unpopulateDateTimeRFC3339(val, "ProvisionedStorageNextAllowedDowngrade", &f.ProvisionedStorageNextAllowedDowngrade) + delete(rawMsg, key) + case "provisionedThroughputMiBPerSec": + err = unpopulate(val, "ProvisionedThroughputMiBPerSec", &f.ProvisionedThroughputMiBPerSec) + delete(rawMsg, key) + case "provisionedThroughputNextAllowedDowngrade": + err = unpopulateDateTimeRFC3339(val, "ProvisionedThroughputNextAllowedDowngrade", &f.ProvisionedThroughputNextAllowedDowngrade) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + case "publicAccessProperties": + err = unpopulate(val, "PublicAccessProperties", &f.PublicAccessProperties) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &f.PublicNetworkAccess) + delete(rawMsg, key) + case "redundancy": + err = unpopulate(val, "Redundancy", &f.Redundancy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareSnapshot. +func (f FileShareSnapshot) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareSnapshot. +func (f *FileShareSnapshot) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareSnapshotListResult. +func (f FileShareSnapshotListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareSnapshotListResult. +func (f *FileShareSnapshotListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareSnapshotProperties. +func (f FileShareSnapshotProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "initiatorId", f.InitiatorID) + populate(objectMap, "metadata", f.Metadata) + populate(objectMap, "provisioningState", f.ProvisioningState) + populate(objectMap, "snapshotTime", f.SnapshotTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareSnapshotProperties. +func (f *FileShareSnapshotProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "initiatorId": + err = unpopulate(val, "InitiatorID", &f.InitiatorID) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &f.Metadata) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + case "snapshotTime": + err = unpopulate(val, "SnapshotTime", &f.SnapshotTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareSnapshotUpdate. +func (f FileShareSnapshotUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", f.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareSnapshotUpdate. +func (f *FileShareSnapshotUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareSnapshotUpdateProperties. +func (f FileShareSnapshotUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "metadata", f.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareSnapshotUpdateProperties. +func (f *FileShareSnapshotUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "metadata": + err = unpopulate(val, "Metadata", &f.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareUpdate. +func (f FileShareUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "tags", f.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareUpdate. +func (f *FileShareUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileShareUpdateProperties. +func (f FileShareUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nfsProtocolProperties", f.NfsProtocolProperties) + populate(objectMap, "provisionedIOPerSec", f.ProvisionedIOPerSec) + populate(objectMap, "provisionedStorageGiB", f.ProvisionedStorageGiB) + populate(objectMap, "provisionedThroughputMiBPerSec", f.ProvisionedThroughputMiBPerSec) + populate(objectMap, "publicAccessProperties", f.PublicAccessProperties) + populate(objectMap, "publicNetworkAccess", f.PublicNetworkAccess) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareUpdateProperties. +func (f *FileShareUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nfsProtocolProperties": + err = unpopulate(val, "NfsProtocolProperties", &f.NfsProtocolProperties) + delete(rawMsg, key) + case "provisionedIOPerSec": + err = unpopulate(val, "ProvisionedIOPerSec", &f.ProvisionedIOPerSec) + delete(rawMsg, key) + case "provisionedStorageGiB": + err = unpopulate(val, "ProvisionedStorageGiB", &f.ProvisionedStorageGiB) + delete(rawMsg, key) + case "provisionedThroughputMiBPerSec": + err = unpopulate(val, "ProvisionedThroughputMiBPerSec", &f.ProvisionedThroughputMiBPerSec) + delete(rawMsg, key) + case "publicAccessProperties": + err = unpopulate(val, "PublicAccessProperties", &f.PublicAccessProperties) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &f.PublicNetworkAccess) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NfsProtocolProperties. +func (n NfsProtocolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "rootSquash", n.RootSquash) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NfsProtocolProperties. +func (n *NfsProtocolProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "rootSquash": + err = unpopulate(val, "RootSquash", &n.RootSquash) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpoint. +func (p PrivateEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpoint. +func (p *PrivateEndpoint) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnection. +func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnection. +func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. +func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupIds", p.GroupIDs) + populate(objectMap, "privateEndpoint", p.PrivateEndpoint) + populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionProperties. +func (p *PrivateEndpointConnectionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "groupIds": + err = unpopulate(val, "GroupIDs", &p.GroupIDs) + delete(rawMsg, key) + case "privateEndpoint": + err = unpopulate(val, "PrivateEndpoint", &p.PrivateEndpoint) + delete(rawMsg, key) + case "privateLinkServiceConnectionState": + err = unpopulate(val, "PrivateLinkServiceConnectionState", &p.PrivateLinkServiceConnectionState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. +func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionsRequired", p.ActionsRequired) + populate(objectMap, "description", p.Description) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkServiceConnectionState. +func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionsRequired": + err = unpopulate(val, "ActionsRequired", &p.ActionsRequired) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PublicAccessProperties. +func (p PublicAccessProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowedSubnets", p.AllowedSubnets) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PublicAccessProperties. +func (p *PublicAccessProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allowedSubnets": + err = unpopulate(val, "AllowedSubnets", &p.AllowedSubnets) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/operations_client.go b/sdk/resourcemanager/fileshares/armfileshares/operations_client.go new file mode 100644 index 000000000000..4f93a3493dc5 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/operations_client.go @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2024-01-01-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.FileShares/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/operations_client_example_test.go b/sdk/resourcemanager/fileshares/armfileshares/operations_client_example_test.go new file mode 100644 index 000000000000..111ad78e43c1 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/operations_client_example_test.go @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares" + "log" +) + +// Generated from example definition: 2024-01-01-preview/Operations_List_MaximumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMaximumSetGenGeneratedByMaximumSetRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armfileshares.OperationsClientListResponse{ + // OperationListResult: armfileshares.OperationListResult{ + // Value: []*armfileshares.Operation{ + // { + // Name: to.Ptr("gcjjmydos"), + // IsDataAction: to.Ptr(true), + // Display: &armfileshares.OperationDisplay{ + // Provider: to.Ptr("nsqnbaulllonxnirum"), + // Resource: to.Ptr("tuonwgf"), + // Operation: to.Ptr("bdintjqtti"), + // Description: to.Ptr("mqziugbyjrwaqthvh"), + // }, + // Origin: to.Ptr(armfileshares.OriginUser), + // ActionType: to.Ptr(armfileshares.ActionTypeInternal), + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-01-01-preview/Operations_List_MinimumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMaximumSetGenGeneratedByMinimumSetRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfileshares.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armfileshares.OperationsClientListResponse{ + // OperationListResult: armfileshares.OperationListResult{ + // }, + // } + } +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/options.go b/sdk/resourcemanager/fileshares/armfileshares/options.go new file mode 100644 index 000000000000..931ddf0ea47f --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/options.go @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +// FileSharesClientBeginCreateOrUpdateOptions contains the optional parameters for the FileSharesClient.BeginCreateOrUpdate +// method. +type FileSharesClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FileSharesClientBeginDeleteFileShareSnapshotOptions contains the optional parameters for the FileSharesClient.BeginDeleteFileShareSnapshot +// method. +type FileSharesClientBeginDeleteFileShareSnapshotOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FileSharesClientBeginDeleteOptions contains the optional parameters for the FileSharesClient.BeginDelete method. +type FileSharesClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FileSharesClientBeginUpdateFileShareSnapshotOptions contains the optional parameters for the FileSharesClient.BeginUpdateFileShareSnapshot +// method. +type FileSharesClientBeginUpdateFileShareSnapshotOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FileSharesClientBeginUpdateOptions contains the optional parameters for the FileSharesClient.BeginUpdate method. +type FileSharesClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FileSharesClientCheckNameAvailabilityOptions contains the optional parameters for the FileSharesClient.CheckNameAvailability +// method. +type FileSharesClientCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// FileSharesClientCreateOrUpdateFileShareSnapshotOptions contains the optional parameters for the FileSharesClient.CreateOrUpdateFileShareSnapshot +// method. +type FileSharesClientCreateOrUpdateFileShareSnapshotOptions struct { + // placeholder for future optional parameters +} + +// FileSharesClientGetFileShareSnapshotOptions contains the optional parameters for the FileSharesClient.GetFileShareSnapshot +// method. +type FileSharesClientGetFileShareSnapshotOptions struct { + // placeholder for future optional parameters +} + +// FileSharesClientGetOptions contains the optional parameters for the FileSharesClient.Get method. +type FileSharesClientGetOptions struct { + // placeholder for future optional parameters +} + +// FileSharesClientListByFileShareOptions contains the optional parameters for the FileSharesClient.NewListByFileSharePager +// method. +type FileSharesClientListByFileShareOptions struct { + // placeholder for future optional parameters +} + +// FileSharesClientListByParentOptions contains the optional parameters for the FileSharesClient.NewListByParentPager method. +type FileSharesClientListByParentOptions struct { + // placeholder for future optional parameters +} + +// FileSharesClientListBySubscriptionOptions contains the optional parameters for the FileSharesClient.NewListBySubscriptionPager +// method. +type FileSharesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/responses.go b/sdk/resourcemanager/fileshares/armfileshares/responses.go new file mode 100644 index 000000000000..a3a49d428db2 --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/responses.go @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +// FileSharesClientCheckNameAvailabilityResponse contains the response from method FileSharesClient.CheckNameAvailability. +type FileSharesClientCheckNameAvailabilityResponse struct { + // The check availability result. + CheckNameAvailabilityResponse +} + +// FileSharesClientCreateOrUpdateFileShareSnapshotResponse contains the response from method FileSharesClient.CreateOrUpdateFileShareSnapshot. +type FileSharesClientCreateOrUpdateFileShareSnapshotResponse struct { + // FileShareSnapshot resource + FileShareSnapshot +} + +// FileSharesClientCreateOrUpdateResponse contains the response from method FileSharesClient.BeginCreateOrUpdate. +type FileSharesClientCreateOrUpdateResponse struct { + // File share resource + FileShare +} + +// FileSharesClientDeleteFileShareSnapshotResponse contains the response from method FileSharesClient.BeginDeleteFileShareSnapshot. +type FileSharesClientDeleteFileShareSnapshotResponse struct { + // placeholder for future response values +} + +// FileSharesClientDeleteResponse contains the response from method FileSharesClient.BeginDelete. +type FileSharesClientDeleteResponse struct { + // placeholder for future response values +} + +// FileSharesClientGetFileShareSnapshotResponse contains the response from method FileSharesClient.GetFileShareSnapshot. +type FileSharesClientGetFileShareSnapshotResponse struct { + // FileShareSnapshot resource + FileShareSnapshot +} + +// FileSharesClientGetResponse contains the response from method FileSharesClient.Get. +type FileSharesClientGetResponse struct { + // File share resource + FileShare +} + +// FileSharesClientListByFileShareResponse contains the response from method FileSharesClient.NewListByFileSharePager. +type FileSharesClientListByFileShareResponse struct { + // The response of a FileShareSnapshot list operation. + FileShareSnapshotListResult +} + +// FileSharesClientListByParentResponse contains the response from method FileSharesClient.NewListByParentPager. +type FileSharesClientListByParentResponse struct { + // The response of a FileShare list operation. + FileShareListResult +} + +// FileSharesClientListBySubscriptionResponse contains the response from method FileSharesClient.NewListBySubscriptionPager. +type FileSharesClientListBySubscriptionResponse struct { + // The response of a FileShare list operation. + FileShareListResult +} + +// FileSharesClientUpdateFileShareSnapshotResponse contains the response from method FileSharesClient.BeginUpdateFileShareSnapshot. +type FileSharesClientUpdateFileShareSnapshotResponse struct { + // FileShareSnapshot resource + FileShareSnapshot +} + +// FileSharesClientUpdateResponse contains the response from method FileSharesClient.BeginUpdate. +type FileSharesClientUpdateResponse struct { + // File share resource + FileShare +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/time_rfc3339.go b/sdk/resourcemanager/fileshares/armfileshares/time_rfc3339.go new file mode 100644 index 000000000000..20a6ac0a802f --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/time_rfc3339.go @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armfileshares + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/fileshares/armfileshares/tsp-location.yaml b/sdk/resourcemanager/fileshares/armfileshares/tsp-location.yaml new file mode 100644 index 000000000000..d0035f67ffae --- /dev/null +++ b/sdk/resourcemanager/fileshares/armfileshares/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/fileshares/FileShares.Management +commit: 10678c182980043df9e9bb514ac859467f5ecc42 +repo: Azure/azure-rest-api-specs +additionalDirectories: