You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: device_client.go
    path of file: ./repos/openyurt/pkg/yurtiotdock/clients/edgex-foundry/v3
    
    the code of the file until where you have to start completion: /*
Copyright 2023 The OpenYurt Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v3

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"net/http"
	"net/http/cookiejar"
	"strings"
	"time"

	"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos"
	"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/common"
	edgex_resp "github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/responses"
	"github.com/go-resty/resty/v2"
	"golang.org/x/net/pu
    
func (efc *EdgexDeviceClient) UpdatePropertyState(ctx context.Context, propertyName string, d *iotv1alpha1.Device, options clients.UpdateOptions) error {
	// Get the actual device name
	acturalDeviceName := getEdgeXName(d)

	dps := d.Spec.DeviceProperties[propertyName]
	parameterName := dps.Name
	if dps.PutURL == "" {
		putCmd, err := efc.getPropertyPut(acturalDeviceName, dps.Name)
		if err != nil {
			return err
		}
		dps.PutURL = fmt.Sprintf("%s%s", putCmd.Url, putCmd.Path)
		if len(putCmd.Parameters) == 1 {
			parameterName = putCmd.Parameters[0].ResourceName
		}
	}
	// set the device property to desired state
	bodyMap := make(map[string]string)
	bodyMap[parameterName] = dps.DesiredValue
	body, _ := json.Marshal(bodyMap)
	klog.V(5).Infof("setting the property to desired value", "propertyName", parameterName, "desiredValue", string(body))
	rep, err := efc.R().
		SetHeader("Content-Type", "application/json").
		SetBody(body).
		Put(dps.PutURL)
	if err != nil {
		return err
	} else if rep.StatusCode() != http.StatusOK {
		return fmt.Errorf("could not set property: %s, get response: %s", dps.Name, string(rep.Body()))
	} else if rep.Body() != nil {
		// If the parameters are illegal, such as out of range, the 200 status code is also returned, but the description appears in the body
		a := string(rep.Body())
		if strings.Contains(a, "execWriteCmd") {
			return fmt.Errorf("could not set property: %s, get response: %s", dps.Name, string(rep.Body()))
		}
	}
	return nil
}