// 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 armmanagednetworkfabric

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

// NetworkBootstrapDevicesClient contains the methods for the NetworkBootstrapDevices group.
// Don't use this type directly, use NewNetworkBootstrapDevicesClient() instead.
type NetworkBootstrapDevicesClient struct {
	internal       *arm.Client
	subscriptionID string
}

// NewNetworkBootstrapDevicesClient creates a new instance of NetworkBootstrapDevicesClient 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 NewNetworkBootstrapDevicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NetworkBootstrapDevicesClient, error) {
	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
	if err != nil {
		return nil, err
	}
	client := &NetworkBootstrapDevicesClient{
		subscriptionID: subscriptionID,
		internal:       cl,
	}
	return client, nil
}

// BeginCreate - Creates a Network Bootstrap Device resource
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - body - Request payload.
//   - options - NetworkBootstrapDevicesClientBeginCreateOptions contains the optional parameters for the NetworkBootstrapDevicesClient.BeginCreate
//     method.
func (client *NetworkBootstrapDevicesClient) BeginCreate(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body NetworkBootstrapDevice, options *NetworkBootstrapDevicesClientBeginCreateOptions) (*runtime.Poller[NetworkBootstrapDevicesClientCreateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.create(ctx, resourceGroupName, networkBootstrapDeviceName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkBootstrapDevicesClientCreateResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkBootstrapDevicesClientCreateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Create - Creates a Network Bootstrap Device resource
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
func (client *NetworkBootstrapDevicesClient) create(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body NetworkBootstrapDevice, options *NetworkBootstrapDevicesClientBeginCreateOptions) (*http.Response, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.BeginCreate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.createCreateRequest(ctx, resourceGroupName, networkBootstrapDeviceName, body, 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
}

// createCreateRequest creates the Create request.
func (client *NetworkBootstrapDevicesClient) createCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body NetworkBootstrapDevice, _ *NetworkBootstrapDevicesClientBeginCreateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	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
}

// BeginDelete - Deletes a Network Bootstrap Device resource.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - options - NetworkBootstrapDevicesClientBeginDeleteOptions contains the optional parameters for the NetworkBootstrapDevicesClient.BeginDelete
//     method.
func (client *NetworkBootstrapDevicesClient) BeginDelete(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientBeginDeleteOptions) (*runtime.Poller[NetworkBootstrapDevicesClientDeleteResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.deleteOperation(ctx, resourceGroupName, networkBootstrapDeviceName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkBootstrapDevicesClientDeleteResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkBootstrapDevicesClientDeleteResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Delete - Deletes a Network Bootstrap Device resource.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
func (client *NetworkBootstrapDevicesClient) deleteOperation(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientBeginDeleteOptions) (*http.Response, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.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, networkBootstrapDeviceName, 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 *NetworkBootstrapDevicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, _ *NetworkBootstrapDevicesClientBeginDeleteOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	req.Raw().URL.RawQuery = reqQP.Encode()
	return req, nil
}

// Get - Gets a Network Bootstrap Device resource details.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - options - NetworkBootstrapDevicesClientGetOptions contains the optional parameters for the NetworkBootstrapDevicesClient.Get
//     method.
func (client *NetworkBootstrapDevicesClient) Get(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientGetOptions) (NetworkBootstrapDevicesClientGetResponse, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.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, networkBootstrapDeviceName, options)
	if err != nil {
		return NetworkBootstrapDevicesClientGetResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return NetworkBootstrapDevicesClientGetResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return NetworkBootstrapDevicesClientGetResponse{}, err
	}
	resp, err := client.getHandleResponse(httpResp)
	return resp, err
}

// getCreateRequest creates the Get request.
func (client *NetworkBootstrapDevicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, _ *NetworkBootstrapDevicesClientGetOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getHandleResponse handles the Get response.
func (client *NetworkBootstrapDevicesClient) getHandleResponse(resp *http.Response) (NetworkBootstrapDevicesClientGetResponse, error) {
	result := NetworkBootstrapDevicesClientGetResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.NetworkBootstrapDevice); err != nil {
		return NetworkBootstrapDevicesClientGetResponse{}, err
	}
	return result, nil
}

// NewListByResourceGroupPager - Lists all the Network Bootstrap Device resources in a given resource group.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - options - NetworkBootstrapDevicesClientListByResourceGroupOptions contains the optional parameters for the NetworkBootstrapDevicesClient.NewListByResourceGroupPager
//     method.
func (client *NetworkBootstrapDevicesClient) NewListByResourceGroupPager(resourceGroupName string, options *NetworkBootstrapDevicesClientListByResourceGroupOptions) *runtime.Pager[NetworkBootstrapDevicesClientListByResourceGroupResponse] {
	return runtime.NewPager(runtime.PagingHandler[NetworkBootstrapDevicesClientListByResourceGroupResponse]{
		More: func(page NetworkBootstrapDevicesClientListByResourceGroupResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *NetworkBootstrapDevicesClientListByResourceGroupResponse) (NetworkBootstrapDevicesClientListByResourceGroupResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "NetworkBootstrapDevicesClient.NewListByResourceGroupPager")
			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.listByResourceGroupCreateRequest(ctx, resourceGroupName, options)
			}, nil)
			if err != nil {
				return NetworkBootstrapDevicesClientListByResourceGroupResponse{}, err
			}
			return client.listByResourceGroupHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listByResourceGroupCreateRequest creates the ListByResourceGroup request.
func (client *NetworkBootstrapDevicesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *NetworkBootstrapDevicesClientListByResourceGroupOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices"
	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", "2025-07-15")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listByResourceGroupHandleResponse handles the ListByResourceGroup response.
func (client *NetworkBootstrapDevicesClient) listByResourceGroupHandleResponse(resp *http.Response) (NetworkBootstrapDevicesClientListByResourceGroupResponse, error) {
	result := NetworkBootstrapDevicesClientListByResourceGroupResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.NetworkBootstrapDeviceListResult); err != nil {
		return NetworkBootstrapDevicesClientListByResourceGroupResponse{}, err
	}
	return result, nil
}

// NewListBySubscriptionPager - List all the Network Bootstrap Device resources in a given subscription.
//
// Generated from API version 2025-07-15
//   - options - NetworkBootstrapDevicesClientListBySubscriptionOptions contains the optional parameters for the NetworkBootstrapDevicesClient.NewListBySubscriptionPager
//     method.
func (client *NetworkBootstrapDevicesClient) NewListBySubscriptionPager(options *NetworkBootstrapDevicesClientListBySubscriptionOptions) *runtime.Pager[NetworkBootstrapDevicesClientListBySubscriptionResponse] {
	return runtime.NewPager(runtime.PagingHandler[NetworkBootstrapDevicesClientListBySubscriptionResponse]{
		More: func(page NetworkBootstrapDevicesClientListBySubscriptionResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *NetworkBootstrapDevicesClientListBySubscriptionResponse) (NetworkBootstrapDevicesClientListBySubscriptionResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "NetworkBootstrapDevicesClient.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 NetworkBootstrapDevicesClientListBySubscriptionResponse{}, err
			}
			return client.listBySubscriptionHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listBySubscriptionCreateRequest creates the ListBySubscription request.
func (client *NetworkBootstrapDevicesClient) listBySubscriptionCreateRequest(ctx context.Context, _ *NetworkBootstrapDevicesClientListBySubscriptionOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices"
	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", "2025-07-15")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listBySubscriptionHandleResponse handles the ListBySubscription response.
func (client *NetworkBootstrapDevicesClient) listBySubscriptionHandleResponse(resp *http.Response) (NetworkBootstrapDevicesClientListBySubscriptionResponse, error) {
	result := NetworkBootstrapDevicesClientListBySubscriptionResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.NetworkBootstrapDeviceListResult); err != nil {
		return NetworkBootstrapDevicesClientListBySubscriptionResponse{}, err
	}
	return result, nil
}

// BeginReboot - Reboot the Network Bootstrap Device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - options - NetworkBootstrapDevicesClientBeginRebootOptions contains the optional parameters for the NetworkBootstrapDevicesClient.BeginReboot
//     method.
func (client *NetworkBootstrapDevicesClient) BeginReboot(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientBeginRebootOptions) (*runtime.Poller[NetworkBootstrapDevicesClientRebootResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.reboot(ctx, resourceGroupName, networkBootstrapDeviceName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkBootstrapDevicesClientRebootResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkBootstrapDevicesClientRebootResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Reboot - Reboot the Network Bootstrap Device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
func (client *NetworkBootstrapDevicesClient) reboot(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientBeginRebootOptions) (*http.Response, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.BeginReboot"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.rebootCreateRequest(ctx, resourceGroupName, networkBootstrapDeviceName, 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
}

// rebootCreateRequest creates the Reboot request.
func (client *NetworkBootstrapDevicesClient) rebootCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, _ *NetworkBootstrapDevicesClientBeginRebootOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}/reboot"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// BeginRefreshConfiguration - Refreshes the configuration of Network Bootstrap Device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - options - NetworkBootstrapDevicesClientBeginRefreshConfigurationOptions contains the optional parameters for the NetworkBootstrapDevicesClient.BeginRefreshConfiguration
//     method.
func (client *NetworkBootstrapDevicesClient) BeginRefreshConfiguration(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientBeginRefreshConfigurationOptions) (*runtime.Poller[NetworkBootstrapDevicesClientRefreshConfigurationResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.refreshConfiguration(ctx, resourceGroupName, networkBootstrapDeviceName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkBootstrapDevicesClientRefreshConfigurationResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkBootstrapDevicesClientRefreshConfigurationResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// RefreshConfiguration - Refreshes the configuration of Network Bootstrap Device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
func (client *NetworkBootstrapDevicesClient) refreshConfiguration(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientBeginRefreshConfigurationOptions) (*http.Response, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.BeginRefreshConfiguration"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.refreshConfigurationCreateRequest(ctx, resourceGroupName, networkBootstrapDeviceName, 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
}

// refreshConfigurationCreateRequest creates the RefreshConfiguration request.
func (client *NetworkBootstrapDevicesClient) refreshConfigurationCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, _ *NetworkBootstrapDevicesClientBeginRefreshConfigurationOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}/refreshConfiguration"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// BeginResyncPasswords - Resync the latest passwords to the Network Bootstrap Device.
//
// Updates the Network Bootstrap Device to use the latest passwords. Does not generate new passwords. Allows network bootstrap
// devices missed during a previous password rotation to be brought back into sync.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - options - NetworkBootstrapDevicesClientBeginResyncPasswordsOptions contains the optional parameters for the NetworkBootstrapDevicesClient.BeginResyncPasswords
//     method.
func (client *NetworkBootstrapDevicesClient) BeginResyncPasswords(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientBeginResyncPasswordsOptions) (*runtime.Poller[NetworkBootstrapDevicesClientResyncPasswordsResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.resyncPasswords(ctx, resourceGroupName, networkBootstrapDeviceName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkBootstrapDevicesClientResyncPasswordsResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkBootstrapDevicesClientResyncPasswordsResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// ResyncPasswords - Resync the latest passwords to the Network Bootstrap Device.
//
// Updates the Network Bootstrap Device to use the latest passwords. Does not generate new passwords. Allows network bootstrap
// devices missed during a previous password rotation to be brought back into sync.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
func (client *NetworkBootstrapDevicesClient) resyncPasswords(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, options *NetworkBootstrapDevicesClientBeginResyncPasswordsOptions) (*http.Response, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.BeginResyncPasswords"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.resyncPasswordsCreateRequest(ctx, resourceGroupName, networkBootstrapDeviceName, 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
}

// resyncPasswordsCreateRequest creates the ResyncPasswords request.
func (client *NetworkBootstrapDevicesClient) resyncPasswordsCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, _ *NetworkBootstrapDevicesClientBeginResyncPasswordsOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}/resyncPasswords"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// BeginUpdate - Update certain properties of the Network Bootstrap Device resource.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - body - Network Bootstrap Device properties to update.
//   - options - NetworkBootstrapDevicesClientBeginUpdateOptions contains the optional parameters for the NetworkBootstrapDevicesClient.BeginUpdate
//     method.
func (client *NetworkBootstrapDevicesClient) BeginUpdate(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body NetworkBootstrapDevicePatch, options *NetworkBootstrapDevicesClientBeginUpdateOptions) (*runtime.Poller[NetworkBootstrapDevicesClientUpdateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.update(ctx, resourceGroupName, networkBootstrapDeviceName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkBootstrapDevicesClientUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkBootstrapDevicesClientUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Update - Update certain properties of the Network Bootstrap Device resource.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
func (client *NetworkBootstrapDevicesClient) update(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body NetworkBootstrapDevicePatch, options *NetworkBootstrapDevicesClientBeginUpdateOptions) (*http.Response, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.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, networkBootstrapDeviceName, body, 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 *NetworkBootstrapDevicesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body NetworkBootstrapDevicePatch, _ *NetworkBootstrapDevicesClientBeginUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	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
}

// BeginUpdateAdministrativeState - Updates the Administrative state of the Network Bootstrap Device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - body - Request payload.
//   - options - NetworkBootstrapDevicesClientBeginUpdateAdministrativeStateOptions contains the optional parameters for the NetworkBootstrapDevicesClient.BeginUpdateAdministrativeState
//     method.
func (client *NetworkBootstrapDevicesClient) BeginUpdateAdministrativeState(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body UpdateDeviceAdministrativeState, options *NetworkBootstrapDevicesClientBeginUpdateAdministrativeStateOptions) (*runtime.Poller[NetworkBootstrapDevicesClientUpdateAdministrativeStateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.updateAdministrativeState(ctx, resourceGroupName, networkBootstrapDeviceName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkBootstrapDevicesClientUpdateAdministrativeStateResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkBootstrapDevicesClientUpdateAdministrativeStateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// UpdateAdministrativeState - Updates the Administrative state of the Network Bootstrap Device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
func (client *NetworkBootstrapDevicesClient) updateAdministrativeState(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body UpdateDeviceAdministrativeState, options *NetworkBootstrapDevicesClientBeginUpdateAdministrativeStateOptions) (*http.Response, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.BeginUpdateAdministrativeState"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.updateAdministrativeStateCreateRequest(ctx, resourceGroupName, networkBootstrapDeviceName, body, 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
}

// updateAdministrativeStateCreateRequest creates the UpdateAdministrativeState request.
func (client *NetworkBootstrapDevicesClient) updateAdministrativeStateCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body UpdateDeviceAdministrativeState, _ *NetworkBootstrapDevicesClientBeginUpdateAdministrativeStateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}/updateAdministrativeState"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	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
}

// BeginUpgrade - Upgrades the version of the Network Bootstrap Device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - networkBootstrapDeviceName - Name of the Network Bootstrap Device.
//   - body - Request payload.
//   - options - NetworkBootstrapDevicesClientBeginUpgradeOptions contains the optional parameters for the NetworkBootstrapDevicesClient.BeginUpgrade
//     method.
func (client *NetworkBootstrapDevicesClient) BeginUpgrade(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body UpdateVersion, options *NetworkBootstrapDevicesClientBeginUpgradeOptions) (*runtime.Poller[NetworkBootstrapDevicesClientUpgradeResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.upgrade(ctx, resourceGroupName, networkBootstrapDeviceName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkBootstrapDevicesClientUpgradeResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkBootstrapDevicesClientUpgradeResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Upgrade - Upgrades the version of the Network Bootstrap Device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-07-15
func (client *NetworkBootstrapDevicesClient) upgrade(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body UpdateVersion, options *NetworkBootstrapDevicesClientBeginUpgradeOptions) (*http.Response, error) {
	var err error
	const operationName = "NetworkBootstrapDevicesClient.BeginUpgrade"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.upgradeCreateRequest(ctx, resourceGroupName, networkBootstrapDeviceName, body, 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
}

// upgradeCreateRequest creates the Upgrade request.
func (client *NetworkBootstrapDevicesClient) upgradeCreateRequest(ctx context.Context, resourceGroupName string, networkBootstrapDeviceName string, body UpdateVersion, _ *NetworkBootstrapDevicesClientBeginUpgradeOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkBootstrapDevices/{networkBootstrapDeviceName}/upgrade"
	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 networkBootstrapDeviceName == "" {
		return nil, errors.New("parameter networkBootstrapDeviceName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{networkBootstrapDeviceName}", url.PathEscape(networkBootstrapDeviceName))
	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", "2025-07-15")
	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
}
