// 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"
)

// InformationalOperationsClient contains the methods for the InformationalOperations group.
// Don't use this type directly, use NewInformationalOperationsClient() instead.
//
// Generated from API version 2026-06-01
type InformationalOperationsClient struct {
	internal       *arm.Client
	subscriptionID string
}

// NewInformationalOperationsClient creates a new instance of InformationalOperationsClient with the specified values.
//   - subscriptionID - The ID of the target subscription. The value must be an UUID.
//   - credential - used to authorize requests. Usually a credential from azidentity.
//   - options - Contains optional client configuration. Pass nil to accept the default values.
func NewInformationalOperationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*InformationalOperationsClient, error) {
	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
	if err != nil {
		return nil, err
	}
	client := &InformationalOperationsClient{
		subscriptionID: subscriptionID,
		internal:       cl,
	}
	return client, nil
}

// GetLimits - Get file shares limits.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The name of the Azure region.
//   - options - InformationalOperationsClientGetLimitsOptions contains the optional parameters for the InformationalOperationsClient.GetLimits
//     method.
func (client *InformationalOperationsClient) GetLimits(ctx context.Context, location string, options *InformationalOperationsClientGetLimitsOptions) (InformationalOperationsClientGetLimitsResponse, error) {
	var err error
	const operationName = "InformationalOperationsClient.GetLimits"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.getLimitsCreateRequest(ctx, location, options)
	if err != nil {
		return InformationalOperationsClientGetLimitsResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return InformationalOperationsClientGetLimitsResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return InformationalOperationsClientGetLimitsResponse{}, err
	}
	resp, err := client.getLimitsHandleResponse(httpResp)
	return resp, err
}

// getLimitsCreateRequest creates the GetLimits request.
func (client *InformationalOperationsClient) getLimitsCreateRequest(ctx context.Context, location string, _ *InformationalOperationsClientGetLimitsOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.FileShares/locations/{location}/getLimits"
	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", version20260601)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getLimitsHandleResponse handles the GetLimits response.
func (client *InformationalOperationsClient) getLimitsHandleResponse(resp *http.Response) (InformationalOperationsClientGetLimitsResponse, error) {
	result := InformationalOperationsClientGetLimitsResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.FileShareLimitsResponse); err != nil {
		return InformationalOperationsClientGetLimitsResponse{}, err
	}
	return result, nil
}

// GetProvisioningRecommendation - Get file shares provisioning parameters recommendation.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The name of the Azure region.
//   - body - The request body
//   - options - InformationalOperationsClientGetProvisioningRecommendationOptions contains the optional parameters for the InformationalOperationsClient.GetProvisioningRecommendation
//     method.
func (client *InformationalOperationsClient) GetProvisioningRecommendation(ctx context.Context, location string, body FileShareProvisioningRecommendationRequest, options *InformationalOperationsClientGetProvisioningRecommendationOptions) (InformationalOperationsClientGetProvisioningRecommendationResponse, error) {
	var err error
	const operationName = "InformationalOperationsClient.GetProvisioningRecommendation"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.getProvisioningRecommendationCreateRequest(ctx, location, body, options)
	if err != nil {
		return InformationalOperationsClientGetProvisioningRecommendationResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return InformationalOperationsClientGetProvisioningRecommendationResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return InformationalOperationsClientGetProvisioningRecommendationResponse{}, err
	}
	resp, err := client.getProvisioningRecommendationHandleResponse(httpResp)
	return resp, err
}

// getProvisioningRecommendationCreateRequest creates the GetProvisioningRecommendation request.
func (client *InformationalOperationsClient) getProvisioningRecommendationCreateRequest(ctx context.Context, location string, body FileShareProvisioningRecommendationRequest, _ *InformationalOperationsClientGetProvisioningRecommendationOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.FileShares/locations/{location}/getProvisioningRecommendation"
	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", version20260601)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	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
}

// getProvisioningRecommendationHandleResponse handles the GetProvisioningRecommendation response.
func (client *InformationalOperationsClient) getProvisioningRecommendationHandleResponse(resp *http.Response) (InformationalOperationsClientGetProvisioningRecommendationResponse, error) {
	result := InformationalOperationsClientGetProvisioningRecommendationResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.FileShareProvisioningRecommendationResponse); err != nil {
		return InformationalOperationsClientGetProvisioningRecommendationResponse{}, err
	}
	return result, nil
}

// GetUsageData - Get file shares usage data.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The name of the Azure region.
//   - options - InformationalOperationsClientGetUsageDataOptions contains the optional parameters for the InformationalOperationsClient.GetUsageData
//     method.
func (client *InformationalOperationsClient) GetUsageData(ctx context.Context, location string, options *InformationalOperationsClientGetUsageDataOptions) (InformationalOperationsClientGetUsageDataResponse, error) {
	var err error
	const operationName = "InformationalOperationsClient.GetUsageData"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.getUsageDataCreateRequest(ctx, location, options)
	if err != nil {
		return InformationalOperationsClientGetUsageDataResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return InformationalOperationsClientGetUsageDataResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return InformationalOperationsClientGetUsageDataResponse{}, err
	}
	resp, err := client.getUsageDataHandleResponse(httpResp)
	return resp, err
}

// getUsageDataCreateRequest creates the GetUsageData request.
func (client *InformationalOperationsClient) getUsageDataCreateRequest(ctx context.Context, location string, _ *InformationalOperationsClientGetUsageDataOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.FileShares/locations/{location}/getUsageData"
	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", version20260601)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getUsageDataHandleResponse handles the GetUsageData response.
func (client *InformationalOperationsClient) getUsageDataHandleResponse(resp *http.Response) (InformationalOperationsClientGetUsageDataResponse, error) {
	result := InformationalOperationsClientGetUsageDataResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.FileShareUsageDataResponse); err != nil {
		return InformationalOperationsClientGetUsageDataResponse{}, err
	}
	return result, nil
}
