Commit 25193b79 authored by supermikii's avatar supermikii
Browse files

update demo 3 put ams return 502

parent d7d5a192
Loading
Loading
Loading
Loading
+27 −27
Original line number Diff line number Diff line
@@ -887,41 +887,41 @@ func amsSendService(appInstanceId string, device string) (string, error) {
// Add a device in ams resource
// Return ams id for update ams
func amsAddDevice(amsId string, registerationBody ams.RegistrationInfo, device string) (ams.RegistrationInfo, error) {
	// var associateId ams.AssociateId
	// associateId.Type_ = 1
	// associateId.Value = device
	var associateId ams.AssociateId
	associateId.Type_ = 1
	associateId.Value = device

	// registerationBody.DeviceInformation = append(registerationBody.DeviceInformation, ams.RegistrationInfoDeviceInformation{
	// 	AssociateId:             &associateId,
	// 	AppMobilityServiceLevel: 3,
	// })
	registerationBody.DeviceInformation = append(registerationBody.DeviceInformation, ams.RegistrationInfoDeviceInformation{
		AssociateId:             &associateId,
		AppMobilityServiceLevel: 3,
	})

	// static registeration body

	associateId := ams.AssociateId{
		Type_: 1,
		Value: "10.2",
	}
	// associateId := ams.AssociateId{
	// 	Type_: 1,
	// 	Value: "10.2",
	// }

	var devices []ams.RegistrationInfoDeviceInformation
	terminalDevice := ams.RegistrationInfoDeviceInformation{
		AssociateId:             &associateId,
		AppMobilityServiceLevel: 1,
		ContextTransferState:    0,
	}
	devices = append(devices, terminalDevice)
	// var devices []ams.RegistrationInfoDeviceInformation
	// terminalDevice := ams.RegistrationInfoDeviceInformation{
	// 	AssociateId:             &associateId,
	// 	AppMobilityServiceLevel: 1,
	// 	ContextTransferState:    0,
	// }
	// devices = append(devices, terminalDevice)

	serviceConsumerId := ams.RegistrationInfoServiceConsumerId{
		AppInstanceId: instanceName,
	}
	// serviceConsumerId := ams.RegistrationInfoServiceConsumerId{
	// 	AppInstanceId: instanceName,
	// }

	body := ams.RegistrationInfo{
		AppMobilityServiceId: amsId,
		DeviceInformation:    devices,
		ServiceConsumerId:    &serviceConsumerId,
	}
	// body := ams.RegistrationInfo{
	// 	AppMobilityServiceId: amsId,
	// 	DeviceInformation:    devices,
	// 	ServiceConsumerId:    &serviceConsumerId,
	// }

	registerationInfo, resp, err := amsClient.AmsiApi.AppMobilityServiceByIdPUT(context.TODO(), body, amsId)
	registerationInfo, resp, err := amsClient.AmsiApi.AppMobilityServiceByIdPUT(context.TODO(), registerationBody, amsId)
	if err != nil {
		log.Error("resp status", resp, err)
		return registerationBody, err