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

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

// AppServiceCertificateOrdersClient contains the methods for the AppServiceCertificateOrders group.
// Don't use this type directly, use NewAppServiceCertificateOrdersClient() instead.
//
// Generated from API version 2024-11-01
type AppServiceCertificateOrdersClient struct {
	internal       *arm.Client
	subscriptionID string
}

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

// BeginCreateOrUpdate - Create or update a certificate purchase order.
//
// Description for Create or update a certificate purchase order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - certificateDistinguishedName - Distinguished name to use for the certificate order.
//   - options - AppServiceCertificateOrdersClientBeginCreateOrUpdateOptions contains the optional parameters for the AppServiceCertificateOrdersClient.BeginCreateOrUpdate
//     method.
func (client *AppServiceCertificateOrdersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, certificateOrderName string, certificateDistinguishedName AppServiceCertificateOrder, options *AppServiceCertificateOrdersClientBeginCreateOrUpdateOptions) (*runtime.Poller[AppServiceCertificateOrdersClientCreateOrUpdateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.createOrUpdate(ctx, resourceGroupName, certificateOrderName, certificateDistinguishedName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AppServiceCertificateOrdersClientCreateOrUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AppServiceCertificateOrdersClientCreateOrUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// CreateOrUpdate - Create or update a certificate purchase order.
//
// Description for Create or update a certificate purchase order.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *AppServiceCertificateOrdersClient) createOrUpdate(ctx context.Context, resourceGroupName string, certificateOrderName string, certificateDistinguishedName AppServiceCertificateOrder, options *AppServiceCertificateOrdersClientBeginCreateOrUpdateOptions) (*http.Response, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.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, certificateOrderName, certificateDistinguishedName, 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 *AppServiceCertificateOrdersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, certificateDistinguishedName AppServiceCertificateOrder, _ *AppServiceCertificateOrdersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	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, certificateDistinguishedName); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginCreateOrUpdateCertificate - Creates or updates a certificate and associates with key vault secret.
//
// Description for Creates or updates a certificate and associates with key vault secret.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - name - Name of the certificate.
//   - keyVaultCertificate - Key vault certificate resource Id.
//   - options - AppServiceCertificateOrdersClientBeginCreateOrUpdateCertificateOptions contains the optional parameters for the
//     AppServiceCertificateOrdersClient.BeginCreateOrUpdateCertificate method.
func (client *AppServiceCertificateOrdersClient) BeginCreateOrUpdateCertificate(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, keyVaultCertificate AppServiceCertificateResource, options *AppServiceCertificateOrdersClientBeginCreateOrUpdateCertificateOptions) (*runtime.Poller[AppServiceCertificateOrdersClientCreateOrUpdateCertificateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.createOrUpdateCertificate(ctx, resourceGroupName, certificateOrderName, name, keyVaultCertificate, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AppServiceCertificateOrdersClientCreateOrUpdateCertificateResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AppServiceCertificateOrdersClientCreateOrUpdateCertificateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// CreateOrUpdateCertificate - Creates or updates a certificate and associates with key vault secret.
//
// Description for Creates or updates a certificate and associates with key vault secret.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *AppServiceCertificateOrdersClient) createOrUpdateCertificate(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, keyVaultCertificate AppServiceCertificateResource, options *AppServiceCertificateOrdersClientBeginCreateOrUpdateCertificateOptions) (*http.Response, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.BeginCreateOrUpdateCertificate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.createOrUpdateCertificateCreateRequest(ctx, resourceGroupName, certificateOrderName, name, keyVaultCertificate, 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
}

// createOrUpdateCertificateCreateRequest creates the CreateOrUpdateCertificate request.
func (client *AppServiceCertificateOrdersClient) createOrUpdateCertificateCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, keyVaultCertificate AppServiceCertificateResource, _ *AppServiceCertificateOrdersClientBeginCreateOrUpdateCertificateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/certificates/{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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	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, keyVaultCertificate); err != nil {
		return nil, err
	}
	return req, nil
}

// Delete - Delete an existing certificate order.
//
// Description for Delete an existing certificate order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - options - AppServiceCertificateOrdersClientDeleteOptions contains the optional parameters for the AppServiceCertificateOrdersClient.Delete
//     method.
func (client *AppServiceCertificateOrdersClient) Delete(ctx context.Context, resourceGroupName string, certificateOrderName string, options *AppServiceCertificateOrdersClientDeleteOptions) (AppServiceCertificateOrdersClientDeleteResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.Delete"
	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, certificateOrderName, options)
	if err != nil {
		return AppServiceCertificateOrdersClientDeleteResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientDeleteResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientDeleteResponse{}, err
	}
	return AppServiceCertificateOrdersClientDeleteResponse{}, nil
}

// deleteCreateRequest creates the Delete request.
func (client *AppServiceCertificateOrdersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, _ *AppServiceCertificateOrdersClientDeleteOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	return req, nil
}

// DeleteCertificate - Delete the certificate associated with a certificate order.
//
// Description for Delete the certificate associated with a certificate order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - name - Name of the certificate.
//   - options - AppServiceCertificateOrdersClientDeleteCertificateOptions contains the optional parameters for the AppServiceCertificateOrdersClient.DeleteCertificate
//     method.
func (client *AppServiceCertificateOrdersClient) DeleteCertificate(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, options *AppServiceCertificateOrdersClientDeleteCertificateOptions) (AppServiceCertificateOrdersClientDeleteCertificateResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.DeleteCertificate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.deleteCertificateCreateRequest(ctx, resourceGroupName, certificateOrderName, name, options)
	if err != nil {
		return AppServiceCertificateOrdersClientDeleteCertificateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientDeleteCertificateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientDeleteCertificateResponse{}, err
	}
	return AppServiceCertificateOrdersClientDeleteCertificateResponse{}, nil
}

// deleteCertificateCreateRequest creates the DeleteCertificate request.
func (client *AppServiceCertificateOrdersClient) deleteCertificateCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, _ *AppServiceCertificateOrdersClientDeleteCertificateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/certificates/{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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	return req, nil
}

// Get - Get a certificate order.
//
// Description for Get a certificate order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - options - AppServiceCertificateOrdersClientGetOptions contains the optional parameters for the AppServiceCertificateOrdersClient.Get
//     method.
func (client *AppServiceCertificateOrdersClient) Get(ctx context.Context, resourceGroupName string, certificateOrderName string, options *AppServiceCertificateOrdersClientGetOptions) (AppServiceCertificateOrdersClientGetResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.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, certificateOrderName, options)
	if err != nil {
		return AppServiceCertificateOrdersClientGetResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientGetResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientGetResponse{}, err
	}
	resp, err := client.getHandleResponse(httpResp)
	return resp, err
}

// getCreateRequest creates the Get request.
func (client *AppServiceCertificateOrdersClient) getCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, _ *AppServiceCertificateOrdersClientGetOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

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

// GetCertificate - Get the certificate associated with a certificate order.
//
// Description for Get the certificate associated with a certificate order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - name - Name of the certificate.
//   - options - AppServiceCertificateOrdersClientGetCertificateOptions contains the optional parameters for the AppServiceCertificateOrdersClient.GetCertificate
//     method.
func (client *AppServiceCertificateOrdersClient) GetCertificate(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, options *AppServiceCertificateOrdersClientGetCertificateOptions) (AppServiceCertificateOrdersClientGetCertificateResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.GetCertificate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.getCertificateCreateRequest(ctx, resourceGroupName, certificateOrderName, name, options)
	if err != nil {
		return AppServiceCertificateOrdersClientGetCertificateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientGetCertificateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientGetCertificateResponse{}, err
	}
	resp, err := client.getCertificateHandleResponse(httpResp)
	return resp, err
}

// getCertificateCreateRequest creates the GetCertificate request.
func (client *AppServiceCertificateOrdersClient) getCertificateCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, _ *AppServiceCertificateOrdersClientGetCertificateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/certificates/{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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getCertificateHandleResponse handles the GetCertificate response.
func (client *AppServiceCertificateOrdersClient) getCertificateHandleResponse(resp *http.Response) (AppServiceCertificateOrdersClientGetCertificateResponse, error) {
	result := AppServiceCertificateOrdersClientGetCertificateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.AppServiceCertificateResource); err != nil {
		return AppServiceCertificateOrdersClientGetCertificateResponse{}, err
	}
	return result, nil
}

// NewListPager - List all certificate orders in a subscription.
//
// Description for List all certificate orders in a subscription.
//   - options - AppServiceCertificateOrdersClientListOptions contains the optional parameters for the AppServiceCertificateOrdersClient.NewListPager
//     method.
func (client *AppServiceCertificateOrdersClient) NewListPager(options *AppServiceCertificateOrdersClientListOptions) *runtime.Pager[AppServiceCertificateOrdersClientListResponse] {
	return runtime.NewPager(runtime.PagingHandler[AppServiceCertificateOrdersClientListResponse]{
		More: func(page AppServiceCertificateOrdersClientListResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *AppServiceCertificateOrdersClientListResponse) (AppServiceCertificateOrdersClientListResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AppServiceCertificateOrdersClient.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 AppServiceCertificateOrdersClientListResponse{}, err
			}
			return client.listHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listCreateRequest creates the List request.
func (client *AppServiceCertificateOrdersClient) listCreateRequest(ctx context.Context, _ *AppServiceCertificateOrdersClientListOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.CertificateRegistration/certificateOrders"
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listHandleResponse handles the List response.
func (client *AppServiceCertificateOrdersClient) listHandleResponse(resp *http.Response) (AppServiceCertificateOrdersClientListResponse, error) {
	result := AppServiceCertificateOrdersClientListResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.AppServiceCertificateOrderCollection); err != nil {
		return AppServiceCertificateOrdersClientListResponse{}, err
	}
	return result, nil
}

// NewListByResourceGroupPager - Get certificate orders in a resource group.
//
// Description for Get certificate orders in a resource group.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - options - AppServiceCertificateOrdersClientListByResourceGroupOptions contains the optional parameters for the AppServiceCertificateOrdersClient.NewListByResourceGroupPager
//     method.
func (client *AppServiceCertificateOrdersClient) NewListByResourceGroupPager(resourceGroupName string, options *AppServiceCertificateOrdersClientListByResourceGroupOptions) *runtime.Pager[AppServiceCertificateOrdersClientListByResourceGroupResponse] {
	return runtime.NewPager(runtime.PagingHandler[AppServiceCertificateOrdersClientListByResourceGroupResponse]{
		More: func(page AppServiceCertificateOrdersClientListByResourceGroupResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *AppServiceCertificateOrdersClientListByResourceGroupResponse) (AppServiceCertificateOrdersClientListByResourceGroupResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AppServiceCertificateOrdersClient.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 AppServiceCertificateOrdersClientListByResourceGroupResponse{}, err
			}
			return client.listByResourceGroupHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listByResourceGroupCreateRequest creates the ListByResourceGroup request.
func (client *AppServiceCertificateOrdersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *AppServiceCertificateOrdersClientListByResourceGroupOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders"
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

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

// NewListCertificatesPager - List all certificates associated with a certificate order.
//
// Description for List all certificates associated with a certificate order.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - options - AppServiceCertificateOrdersClientListCertificatesOptions contains the optional parameters for the AppServiceCertificateOrdersClient.NewListCertificatesPager
//     method.
func (client *AppServiceCertificateOrdersClient) NewListCertificatesPager(resourceGroupName string, certificateOrderName string, options *AppServiceCertificateOrdersClientListCertificatesOptions) *runtime.Pager[AppServiceCertificateOrdersClientListCertificatesResponse] {
	return runtime.NewPager(runtime.PagingHandler[AppServiceCertificateOrdersClientListCertificatesResponse]{
		More: func(page AppServiceCertificateOrdersClientListCertificatesResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *AppServiceCertificateOrdersClientListCertificatesResponse) (AppServiceCertificateOrdersClientListCertificatesResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AppServiceCertificateOrdersClient.NewListCertificatesPager")
			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.listCertificatesCreateRequest(ctx, resourceGroupName, certificateOrderName, options)
			}, nil)
			if err != nil {
				return AppServiceCertificateOrdersClientListCertificatesResponse{}, err
			}
			return client.listCertificatesHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listCertificatesCreateRequest creates the ListCertificates request.
func (client *AppServiceCertificateOrdersClient) listCertificatesCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, _ *AppServiceCertificateOrdersClientListCertificatesOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/certificates"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listCertificatesHandleResponse handles the ListCertificates response.
func (client *AppServiceCertificateOrdersClient) listCertificatesHandleResponse(resp *http.Response) (AppServiceCertificateOrdersClientListCertificatesResponse, error) {
	result := AppServiceCertificateOrdersClientListCertificatesResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.AppServiceCertificateCollection); err != nil {
		return AppServiceCertificateOrdersClientListCertificatesResponse{}, err
	}
	return result, nil
}

// Reissue - Reissue an existing certificate order.
//
// Description for Reissue an existing certificate order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - reissueCertificateOrderRequest - Parameters for the reissue.
//   - options - AppServiceCertificateOrdersClientReissueOptions contains the optional parameters for the AppServiceCertificateOrdersClient.Reissue
//     method.
func (client *AppServiceCertificateOrdersClient) Reissue(ctx context.Context, resourceGroupName string, certificateOrderName string, reissueCertificateOrderRequest ReissueCertificateOrderRequest, options *AppServiceCertificateOrdersClientReissueOptions) (AppServiceCertificateOrdersClientReissueResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.Reissue"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.reissueCreateRequest(ctx, resourceGroupName, certificateOrderName, reissueCertificateOrderRequest, options)
	if err != nil {
		return AppServiceCertificateOrdersClientReissueResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientReissueResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientReissueResponse{}, err
	}
	return AppServiceCertificateOrdersClientReissueResponse{}, nil
}

// reissueCreateRequest creates the Reissue request.
func (client *AppServiceCertificateOrdersClient) reissueCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, reissueCertificateOrderRequest ReissueCertificateOrderRequest, _ *AppServiceCertificateOrdersClientReissueOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/reissue"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, reissueCertificateOrderRequest); err != nil {
		return nil, err
	}
	return req, nil
}

// Renew - Renew an existing certificate order.
//
// Description for Renew an existing certificate order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - renewCertificateOrderRequest - Renew parameters
//   - options - AppServiceCertificateOrdersClientRenewOptions contains the optional parameters for the AppServiceCertificateOrdersClient.Renew
//     method.
func (client *AppServiceCertificateOrdersClient) Renew(ctx context.Context, resourceGroupName string, certificateOrderName string, renewCertificateOrderRequest RenewCertificateOrderRequest, options *AppServiceCertificateOrdersClientRenewOptions) (AppServiceCertificateOrdersClientRenewResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.Renew"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.renewCreateRequest(ctx, resourceGroupName, certificateOrderName, renewCertificateOrderRequest, options)
	if err != nil {
		return AppServiceCertificateOrdersClientRenewResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientRenewResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientRenewResponse{}, err
	}
	return AppServiceCertificateOrdersClientRenewResponse{}, nil
}

// renewCreateRequest creates the Renew request.
func (client *AppServiceCertificateOrdersClient) renewCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, renewCertificateOrderRequest RenewCertificateOrderRequest, _ *AppServiceCertificateOrdersClientRenewOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/renew"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, renewCertificateOrderRequest); err != nil {
		return nil, err
	}
	return req, nil
}

// ResendEmail - Resend certificate email.
//
// Description for Resend certificate email.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - options - AppServiceCertificateOrdersClientResendEmailOptions contains the optional parameters for the AppServiceCertificateOrdersClient.ResendEmail
//     method.
func (client *AppServiceCertificateOrdersClient) ResendEmail(ctx context.Context, resourceGroupName string, certificateOrderName string, options *AppServiceCertificateOrdersClientResendEmailOptions) (AppServiceCertificateOrdersClientResendEmailResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.ResendEmail"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.resendEmailCreateRequest(ctx, resourceGroupName, certificateOrderName, options)
	if err != nil {
		return AppServiceCertificateOrdersClientResendEmailResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientResendEmailResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientResendEmailResponse{}, err
	}
	return AppServiceCertificateOrdersClientResendEmailResponse{}, nil
}

// resendEmailCreateRequest creates the ResendEmail request.
func (client *AppServiceCertificateOrdersClient) resendEmailCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, _ *AppServiceCertificateOrdersClientResendEmailOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/resendEmail"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	return req, nil
}

// ResendRequestEmails - Resend domain verification email to customer for this certificate order
//
// Resend domain verification ownership email containing steps on how to verify a domain for a given certificate order
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - nameIdentifier - Email address
//   - options - AppServiceCertificateOrdersClientResendRequestEmailsOptions contains the optional parameters for the AppServiceCertificateOrdersClient.ResendRequestEmails
//     method.
func (client *AppServiceCertificateOrdersClient) ResendRequestEmails(ctx context.Context, resourceGroupName string, certificateOrderName string, nameIdentifier NameIdentifier, options *AppServiceCertificateOrdersClientResendRequestEmailsOptions) (AppServiceCertificateOrdersClientResendRequestEmailsResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.ResendRequestEmails"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.resendRequestEmailsCreateRequest(ctx, resourceGroupName, certificateOrderName, nameIdentifier, options)
	if err != nil {
		return AppServiceCertificateOrdersClientResendRequestEmailsResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientResendRequestEmailsResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientResendRequestEmailsResponse{}, err
	}
	return AppServiceCertificateOrdersClientResendRequestEmailsResponse{}, nil
}

// resendRequestEmailsCreateRequest creates the ResendRequestEmails request.
func (client *AppServiceCertificateOrdersClient) resendRequestEmailsCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, nameIdentifier NameIdentifier, _ *AppServiceCertificateOrdersClientResendRequestEmailsOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/resendRequestEmails"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, nameIdentifier); err != nil {
		return nil, err
	}
	return req, nil
}

// RetrieveCertificateActions - Retrieve the list of certificate actions.
//
// Description for Retrieve the list of certificate actions.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - name - Name of the certificate order..
//   - options - AppServiceCertificateOrdersClientRetrieveCertificateActionsOptions contains the optional parameters for the AppServiceCertificateOrdersClient.RetrieveCertificateActions
//     method.
func (client *AppServiceCertificateOrdersClient) RetrieveCertificateActions(ctx context.Context, resourceGroupName string, name string, options *AppServiceCertificateOrdersClientRetrieveCertificateActionsOptions) (AppServiceCertificateOrdersClientRetrieveCertificateActionsResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.RetrieveCertificateActions"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.retrieveCertificateActionsCreateRequest(ctx, resourceGroupName, name, options)
	if err != nil {
		return AppServiceCertificateOrdersClientRetrieveCertificateActionsResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientRetrieveCertificateActionsResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientRetrieveCertificateActionsResponse{}, err
	}
	resp, err := client.retrieveCertificateActionsHandleResponse(httpResp)
	return resp, err
}

// retrieveCertificateActionsCreateRequest creates the RetrieveCertificateActions request.
func (client *AppServiceCertificateOrdersClient) retrieveCertificateActionsCreateRequest(ctx context.Context, resourceGroupName string, name string, _ *AppServiceCertificateOrdersClientRetrieveCertificateActionsOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/retrieveCertificateActions"
	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 name == "" {
		return nil, errors.New("parameter name cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// retrieveCertificateActionsHandleResponse handles the RetrieveCertificateActions response.
func (client *AppServiceCertificateOrdersClient) retrieveCertificateActionsHandleResponse(resp *http.Response) (AppServiceCertificateOrdersClientRetrieveCertificateActionsResponse, error) {
	result := AppServiceCertificateOrdersClientRetrieveCertificateActionsResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.CertificateOrderActionArray); err != nil {
		return AppServiceCertificateOrdersClientRetrieveCertificateActionsResponse{}, err
	}
	return result, nil
}

// RetrieveCertificateEmailHistory - Retrieve email history.
//
// Description for Retrieve email history.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - name - Name of the certificate order..
//   - options - AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryOptions contains the optional parameters for
//     the AppServiceCertificateOrdersClient.RetrieveCertificateEmailHistory method.
func (client *AppServiceCertificateOrdersClient) RetrieveCertificateEmailHistory(ctx context.Context, resourceGroupName string, name string, options *AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryOptions) (AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.RetrieveCertificateEmailHistory"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.retrieveCertificateEmailHistoryCreateRequest(ctx, resourceGroupName, name, options)
	if err != nil {
		return AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryResponse{}, err
	}
	resp, err := client.retrieveCertificateEmailHistoryHandleResponse(httpResp)
	return resp, err
}

// retrieveCertificateEmailHistoryCreateRequest creates the RetrieveCertificateEmailHistory request.
func (client *AppServiceCertificateOrdersClient) retrieveCertificateEmailHistoryCreateRequest(ctx context.Context, resourceGroupName string, name string, _ *AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/retrieveEmailHistory"
	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 name == "" {
		return nil, errors.New("parameter name cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// retrieveCertificateEmailHistoryHandleResponse handles the RetrieveCertificateEmailHistory response.
func (client *AppServiceCertificateOrdersClient) retrieveCertificateEmailHistoryHandleResponse(resp *http.Response) (AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryResponse, error) {
	result := AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.CertificateEmailArray); err != nil {
		return AppServiceCertificateOrdersClientRetrieveCertificateEmailHistoryResponse{}, err
	}
	return result, nil
}

// RetrieveSiteSeal - This method is used to obtain the site seal information for an issued certificate.
//
// This method is used to obtain the site seal information for an issued certificate. A site seal is a graphic that the certificate
// purchaser can embed on their web site to show their visitors information about their SSL certificate. If a web site visitor
// clicks on the site seal image, a pop-up page is displayed that contains detailed information about the SSL certificate.
// The site seal token is used to link the site seal graphic image to the appropriate certificate details pop-up page display
// when a user clicks on the site seal. The site seal images are expected to be static images and hosted by the reseller,
// to minimize delays for customer page load times.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - siteSealRequest - Site seal request.
//   - options - AppServiceCertificateOrdersClientRetrieveSiteSealOptions contains the optional parameters for the AppServiceCertificateOrdersClient.RetrieveSiteSeal
//     method.
func (client *AppServiceCertificateOrdersClient) RetrieveSiteSeal(ctx context.Context, resourceGroupName string, certificateOrderName string, siteSealRequest SiteSealRequest, options *AppServiceCertificateOrdersClientRetrieveSiteSealOptions) (AppServiceCertificateOrdersClientRetrieveSiteSealResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.RetrieveSiteSeal"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.retrieveSiteSealCreateRequest(ctx, resourceGroupName, certificateOrderName, siteSealRequest, options)
	if err != nil {
		return AppServiceCertificateOrdersClientRetrieveSiteSealResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientRetrieveSiteSealResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientRetrieveSiteSealResponse{}, err
	}
	resp, err := client.retrieveSiteSealHandleResponse(httpResp)
	return resp, err
}

// retrieveSiteSealCreateRequest creates the RetrieveSiteSeal request.
func (client *AppServiceCertificateOrdersClient) retrieveSiteSealCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, siteSealRequest SiteSealRequest, _ *AppServiceCertificateOrdersClientRetrieveSiteSealOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/retrieveSiteSeal"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	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, siteSealRequest); err != nil {
		return nil, err
	}
	return req, nil
}

// retrieveSiteSealHandleResponse handles the RetrieveSiteSeal response.
func (client *AppServiceCertificateOrdersClient) retrieveSiteSealHandleResponse(resp *http.Response) (AppServiceCertificateOrdersClientRetrieveSiteSealResponse, error) {
	result := AppServiceCertificateOrdersClientRetrieveSiteSealResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SiteSeal); err != nil {
		return AppServiceCertificateOrdersClientRetrieveSiteSealResponse{}, err
	}
	return result, nil
}

// Update - Create or update a certificate purchase order.
//
// Description for Create or update a certificate purchase order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - certificateDistinguishedName - Distinguished name to use for the certificate order.
//   - options - AppServiceCertificateOrdersClientUpdateOptions contains the optional parameters for the AppServiceCertificateOrdersClient.Update
//     method.
func (client *AppServiceCertificateOrdersClient) Update(ctx context.Context, resourceGroupName string, certificateOrderName string, certificateDistinguishedName AppServiceCertificateOrderPatchResource, options *AppServiceCertificateOrdersClientUpdateOptions) (AppServiceCertificateOrdersClientUpdateResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.Update"
	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, certificateOrderName, certificateDistinguishedName, options)
	if err != nil {
		return AppServiceCertificateOrdersClientUpdateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientUpdateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientUpdateResponse{}, err
	}
	resp, err := client.updateHandleResponse(httpResp)
	return resp, err
}

// updateCreateRequest creates the Update request.
func (client *AppServiceCertificateOrdersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, certificateDistinguishedName AppServiceCertificateOrderPatchResource, _ *AppServiceCertificateOrdersClientUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	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, certificateDistinguishedName); err != nil {
		return nil, err
	}
	return req, nil
}

// updateHandleResponse handles the Update response.
func (client *AppServiceCertificateOrdersClient) updateHandleResponse(resp *http.Response) (AppServiceCertificateOrdersClientUpdateResponse, error) {
	result := AppServiceCertificateOrdersClientUpdateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.AppServiceCertificateOrder); err != nil {
		return AppServiceCertificateOrdersClientUpdateResponse{}, err
	}
	return result, nil
}

// UpdateCertificate - Creates or updates a certificate and associates with key vault secret.
//
// Description for Creates or updates a certificate and associates with key vault secret.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - name - Name of the certificate.
//   - keyVaultCertificate - Key vault certificate resource Id.
//   - options - AppServiceCertificateOrdersClientUpdateCertificateOptions contains the optional parameters for the AppServiceCertificateOrdersClient.UpdateCertificate
//     method.
func (client *AppServiceCertificateOrdersClient) UpdateCertificate(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, keyVaultCertificate AppServiceCertificatePatchResource, options *AppServiceCertificateOrdersClientUpdateCertificateOptions) (AppServiceCertificateOrdersClientUpdateCertificateResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.UpdateCertificate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.updateCertificateCreateRequest(ctx, resourceGroupName, certificateOrderName, name, keyVaultCertificate, options)
	if err != nil {
		return AppServiceCertificateOrdersClientUpdateCertificateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientUpdateCertificateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientUpdateCertificateResponse{}, err
	}
	resp, err := client.updateCertificateHandleResponse(httpResp)
	return resp, err
}

// updateCertificateCreateRequest creates the UpdateCertificate request.
func (client *AppServiceCertificateOrdersClient) updateCertificateCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, keyVaultCertificate AppServiceCertificatePatchResource, _ *AppServiceCertificateOrdersClientUpdateCertificateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/certificates/{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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	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, keyVaultCertificate); err != nil {
		return nil, err
	}
	return req, nil
}

// updateCertificateHandleResponse handles the UpdateCertificate response.
func (client *AppServiceCertificateOrdersClient) updateCertificateHandleResponse(resp *http.Response) (AppServiceCertificateOrdersClientUpdateCertificateResponse, error) {
	result := AppServiceCertificateOrdersClientUpdateCertificateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.AppServiceCertificateResource); err != nil {
		return AppServiceCertificateOrdersClientUpdateCertificateResponse{}, err
	}
	return result, nil
}

// ValidatePurchaseInformation - Validate information for a certificate order.
//
// Description for Validate information for a certificate order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - appServiceCertificateOrder - The request body
//   - options - AppServiceCertificateOrdersClientValidatePurchaseInformationOptions contains the optional parameters for the
//     AppServiceCertificateOrdersClient.ValidatePurchaseInformation method.
func (client *AppServiceCertificateOrdersClient) ValidatePurchaseInformation(ctx context.Context, appServiceCertificateOrder AppServiceCertificateOrder, options *AppServiceCertificateOrdersClientValidatePurchaseInformationOptions) (AppServiceCertificateOrdersClientValidatePurchaseInformationResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.ValidatePurchaseInformation"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.validatePurchaseInformationCreateRequest(ctx, appServiceCertificateOrder, options)
	if err != nil {
		return AppServiceCertificateOrdersClientValidatePurchaseInformationResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientValidatePurchaseInformationResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientValidatePurchaseInformationResponse{}, err
	}
	return AppServiceCertificateOrdersClientValidatePurchaseInformationResponse{}, nil
}

// validatePurchaseInformationCreateRequest creates the ValidatePurchaseInformation request.
func (client *AppServiceCertificateOrdersClient) validatePurchaseInformationCreateRequest(ctx context.Context, appServiceCertificateOrder AppServiceCertificateOrder, _ *AppServiceCertificateOrdersClientValidatePurchaseInformationOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation"
	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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, appServiceCertificateOrder); err != nil {
		return nil, err
	}
	return req, nil
}

// VerifyDomainOwnership - Verify domain ownership for this certificate order.
//
// Description for Verify domain ownership for this certificate order.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - certificateOrderName - Name of the certificate order..
//   - options - AppServiceCertificateOrdersClientVerifyDomainOwnershipOptions contains the optional parameters for the AppServiceCertificateOrdersClient.VerifyDomainOwnership
//     method.
func (client *AppServiceCertificateOrdersClient) VerifyDomainOwnership(ctx context.Context, resourceGroupName string, certificateOrderName string, options *AppServiceCertificateOrdersClientVerifyDomainOwnershipOptions) (AppServiceCertificateOrdersClientVerifyDomainOwnershipResponse, error) {
	var err error
	const operationName = "AppServiceCertificateOrdersClient.VerifyDomainOwnership"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.verifyDomainOwnershipCreateRequest(ctx, resourceGroupName, certificateOrderName, options)
	if err != nil {
		return AppServiceCertificateOrdersClientVerifyDomainOwnershipResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return AppServiceCertificateOrdersClientVerifyDomainOwnershipResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return AppServiceCertificateOrdersClientVerifyDomainOwnershipResponse{}, err
	}
	return AppServiceCertificateOrdersClientVerifyDomainOwnershipResponse{}, nil
}

// verifyDomainOwnershipCreateRequest creates the VerifyDomainOwnership request.
func (client *AppServiceCertificateOrdersClient) verifyDomainOwnershipCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, _ *AppServiceCertificateOrdersClientVerifyDomainOwnershipOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/verifyDomainOwnership"
	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 certificateOrderName == "" {
		return nil, errors.New("parameter certificateOrderName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{certificateOrderName}", url.PathEscape(certificateOrderName))
	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", version20241101)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	return req, nil
}
