package test

import (
	"context"
	"fmt"
	"testing"

	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/audit"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8ci"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/qospolicy"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/secgroup"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stpolicy"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/trunk"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vgpu"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/adrspools"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/defsecpolicies"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/hypervisors"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/routers"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/secpolicies"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/secpolicies/rule"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/segments"

	account_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account"
	audit_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/audit"
	bservice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/bservice"
	compute_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/compute"
	disks_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
	extnet_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/extnet"
	flipgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/flipgroup"
	grid_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/grid"
	image_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
	k8ci_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8ci"
	k8s_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s"
	lb_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/lb"
	node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
	pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
	qospolicy_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/qospolicy"
	rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
	secgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup"
	sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
	stpolicy_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stpolicy"
	tasks_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/tasks"
	trunk_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/trunk"
	vins_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins"
	zone_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"

	extnet_sdn "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/extnet"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/flips"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/netobjgroups"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/version"
)

// TestGetListCloudAPI tests platforms responses vs. json tags of golang structures in cloudapi get/list methods
func TestGetListCloudAPI(t *testing.T) {
	var bytes []byte
	var err error
	client, err := getClient()
	if err != nil {
		t.Fatalf("Cannot get client: %v", err)
	}

	// Account
	// List
	bytes, err = client.CloudAPI().Account().ListRaw(context.Background(), account.ListRequest{})
	if err != nil {
		t.Error(err)
	}

	getResult("Account list", bytes, account.ListAccounts{}, t)
	// Get
	listAcc, _ := client.CloudAPI().Account().List(context.Background(), account.ListRequest{})
	if len(listAcc.Data) > 0 {
		id := listAcc.Data[0].ID
		bytes, err = client.CloudAPI().Account().GetRaw(context.Background(), account.GetRequest{AccountID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Account get", bytes, account.RecordAccount{}, t)
	} else {
		t.Errorf("Can not test Account get because account list is empty")
	}

	// Audit
	// List
	bytes, err = client.CloudAPI().Audit().ListRaw(context.Background(), audit.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Audit list", bytes, audit.ListAudits{}, t)
	// Get
	listAudits, _ := client.CloudAPI().Audit().List(context.Background(), audit.ListRequest{})
	if len(listAudits.Data) > 0 {
		id := listAudits.Data[0].GUID
		bytes, err = client.CloudAPI().Audit().GetRaw(context.Background(), audit.GetRequest{AuditGuid: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Audit get", bytes, audit.RecordAudit{}, t)
	} else {
		t.Errorf("Can not test Audit get because Audit list is empty")
	}

	// Bservice
	// List
	bytes, err = client.CloudAPI().BService().ListRaw(context.Background(), bservice.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Bservice list", bytes, bservice.ListBasicServices{}, t)
	// Get
	listBServ, _ := client.CloudAPI().BService().List(context.Background(), bservice.ListRequest{})
	if len(listBServ.Data) > 0 {
		id := listBServ.Data[0].ID
		bytes, err = client.CloudAPI().BService().GetRaw(context.Background(), bservice.GetRequest{ServiceID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Bservice get", bytes, bservice.RecordBasicService{}, t)
	} else {
		t.Errorf("Can not test Bservice get because bservice list is empty")
	}

	// Compute
	// List
	bytes, err = client.CloudAPI().Compute().ListRaw(context.Background(), compute.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Compute list", bytes, compute.ListComputes{}, t)
	// Get
	listComp, _ := client.CloudAPI().Compute().List(context.Background(), compute.ListRequest{})
	if listComp != nil && len(listComp.Data) > 0 {
		id := listComp.Data[0].ID
		bytes, err = client.CloudAPI().Compute().GetRaw(context.Background(), compute.GetRequest{ComputeID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Compute get", bytes, compute.RecordCompute{}, t)
		// GetCPUAlignmentProfile
		bytes, err = client.CloudAPI().Compute().GetCPUAlignmentProfileRaw(context.Background(), compute.GetCPUAlignmentProfileRequest{ComputeID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Compute get_cpu_alignment_profile", bytes, compute.CPUAlignmentProfile{}, t)
	} else {
		t.Errorf("Can not test Compute get because compute list is empty")
	}

	// Disk
	// List
	bytes, err = client.CloudAPI().Disks().ListRaw(context.Background(), disks.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Disk list", bytes, disks.ListDisks{}, t)
	// Get
	listDisk, _ := client.CloudAPI().Disks().List(context.Background(), disks.ListRequest{})
	if len(listDisk.Data) > 0 {
		id := listDisk.Data[0].ID
		bytes, err = client.CloudAPI().Disks().GetRaw(context.Background(), disks.GetRequest{DiskID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Disk get", bytes, disks.RecordDisk{}, t)
	} else {
		t.Errorf("Can not test Disk get because disk list is empty")
	}

	// ExtNet
	// List
	bytes, err = client.CloudAPI().ExtNet().ListRaw(context.Background(), extnet.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("ExtNet list", bytes, extnet.ListExtNets{}, t)
	// Get
	listExtNet, _ := client.CloudAPI().ExtNet().List(context.Background(), extnet.ListRequest{})
	if len(listExtNet.Data) > 0 {
		id := listExtNet.Data[0].ID
		bytes, err = client.CloudAPI().ExtNet().GetRaw(context.Background(), extnet.GetRequest{NetID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("ExtNet get", bytes, extnet.RecordExtNet{}, t)
	} else {
		t.Errorf("Can not test ExtNet get because listExtNet list is empty")
	}

	// FLIPGroup
	// List
	bytes, err = client.CloudAPI().FLIPGroup().ListRaw(context.Background(), flipgroup.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("FLIPGroup list", bytes, flipgroup.ListFLIPGroups{}, t)
	// Get
	listFG, _ := client.CloudAPI().FLIPGroup().List(context.Background(), flipgroup.ListRequest{})
	if len(listFG.Data) > 0 {
		id := listFG.Data[0].ID
		bytes, err = client.CloudAPI().FLIPGroup().GetRaw(context.Background(), flipgroup.GetRequest{FLIPGroupID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("FLIPGroup get", bytes, flipgroup.RecordFLIPGroup{}, t)
	} else {
		t.Errorf("Can not test FLIPGroup get because flipgroup list is empty")
	}

	// Image
	// List
	bytes, err = client.CloudAPI().Image().ListRaw(context.Background(), image.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Image list", bytes, image.ListImages{}, t)
	// Get
	listImg, _ := client.CloudAPI().Image().List(context.Background(), image.ListRequest{})
	if len(listImg.Data) > 0 {
		id := listImg.Data[0].ID
		bytes, err = client.CloudAPI().Image().GetRaw(context.Background(), image.GetRequest{ImageID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Image get", bytes, image.RecordImage{}, t)
	} else {
		t.Errorf("Can not test Image get because Image list is empty")
	}

	// K8CI
	// List
	bytes, err = client.CloudAPI().K8CI().ListRaw(context.Background(), k8ci.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("K8CI list", bytes, k8ci.ListK8CI{}, t)
	// Get
	listk8ci, _ := client.CloudAPI().K8CI().List(context.Background(), k8ci.ListRequest{})
	if len(listk8ci.Data) > 0 {
		id := listk8ci.Data[0].ID
		bytes, err = client.CloudAPI().K8CI().GetRaw(context.Background(), k8ci.GetRequest{K8CIID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("K8CI get", bytes, k8ci.RecordK8CI{}, t)
	} else {
		t.Errorf("Can not test K8CI get because K8CI list is empty")
	}

	// K8S
	// List
	bytes, err = client.CloudAPI().K8S().ListRaw(context.Background(), k8s.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("K8S list", bytes, k8s.ListK8SClusters{}, t)
	// Get
	listk8s, _ := client.CloudAPI().K8S().List(context.Background(), k8s.ListRequest{})
	if len(listk8s.Data) > 0 {
		id := listk8s.Data[0].ID
		bytes, err = client.CloudAPI().K8S().GetRaw(context.Background(), k8s.GetRequest{K8SID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("K8S get", bytes, k8s.RecordK8S{}, t)
	} else {
		t.Errorf("Can not test K8S get because K8S list is empty")
	}

	// LB
	// List
	bytes, err = client.CloudAPI().LB().ListRaw(context.Background(), lb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("LB list", bytes, lb.ListLB{}, t)
	// Get
	listLB, _ := client.CloudAPI().LB().List(context.Background(), lb.ListRequest{})
	if len(listLB.Data) > 0 {
		id := listLB.Data[0].ID
		bytes, err = client.CloudAPI().LB().GetRaw(context.Background(), lb.GetRequest{LBID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("LB get", bytes, lb.RecordLB{}, t)
	} else {
		t.Errorf("Can not test LB get because LB list is empty")
	}

	// Locations
	// List
	bytes, err = client.CloudAPI().Locations().ListRaw(context.Background(), locations.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Locations list", bytes, locations.ListLocations{}, t)

	// QoS policy
	// List
	bytes, err = client.CloudAPI().QoSPolicy().ListRaw(context.Background(), qospolicy.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("QoS policy list", bytes, qospolicy.ListQoSPolicies{}, t)
	// Get
	listQosPolicies, _ := client.CloudAPI().QoSPolicy().List(context.Background(), qospolicy.ListRequest{})
	if len(listQosPolicies.Data) > 0 {
		id := listQosPolicies.Data[0].ID
		bytes, err = client.CloudAPI().QoSPolicy().GetRaw(context.Background(), qospolicy.GetRequest{QoSPolicyID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("QoS policy get", bytes, qospolicy.RecordQoSPolicy{}, t)
	} else {
		t.Errorf("Can not test QoS policy get because QoS policy list is empty")
	}

	// RG
	// List
	bytes, err = client.CloudAPI().RG().ListRaw(context.Background(), rg.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("RG list", bytes, rg.ListResourceGroups{}, t)
	// Get
	listRG, _ := client.CloudAPI().RG().List(context.Background(), rg.ListRequest{})
	if len(listRG.Data) > 0 {
		id := listRG.Data[0].ID
		bytes, err = client.CloudAPI().RG().GetRaw(context.Background(), rg.GetRequest{RGID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("RG get", bytes, rg.RecordResourceGroup{}, t)
	} else {
		t.Errorf("Can not test RG get because RG list is empty")
	}

	// SEP
	// List available sep and pools
	bytes, err = client.CloudAPI().SEP().ListAvailableSEPAndPoolsRaw(context.Background(), sep.ListAvailableSEPAndPoolsRequest{AccountID: 1})
	if err != nil {
		t.Error(err)
	}
	getResult("SEP list", bytes, sep.ListAvailableSEP{}, t)

	// Storage policy
	// List
	bytes, err = client.CloudAPI().StPolicy().ListRaw(context.Background(), stpolicy.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Storage policy list", bytes, stpolicy.ListStoragePolicies{}, t)
	// Get
	listStoragePolicies, _ := client.CloudAPI().StPolicy().List(context.Background(), stpolicy.ListRequest{})
	if len(listStoragePolicies.Data) > 0 {
		id := listStoragePolicies.Data[0].ID
		bytes, err = client.CloudAPI().StPolicy().GetRaw(context.Background(), stpolicy.GetRequest{StoragePolicyID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Storage policy get", bytes, stpolicy.InfoStoragePolicy{}, t)
	} else {
		t.Errorf("Can not test Storage policy get because Storage policy list is empty")
	}

	// Security group
	// List
	bytes, err = client.CloudAPI().SecurityGroup().ListRaw(context.Background(), secgroup.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Security group list", bytes, secgroup.ListSecurityGroups{}, t)
	// Get
	listSecurityGroups, _ := client.CloudAPI().SecurityGroup().List(context.Background(), secgroup.ListRequest{})
	if len(listSecurityGroups.Data) > 0 {
		id := listSecurityGroups.Data[0].ID
		bytes, err = client.CloudAPI().SecurityGroup().GetRaw(context.Background(), secgroup.GetRequest{SecurityGroupID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Security group get", bytes, secgroup.RecordSecurityGroup{}, t)
	} else {
		t.Errorf("Can not test Security group get because Security group list is empty")
	}

	// Tasks
	// List
	bytes, err = client.CloudAPI().Tasks().ListRaw(context.Background(), tasks.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Tasks list", bytes, tasks.ListTasks{}, t)
	// Get
	listTasks, _ := client.CloudAPI().Tasks().List(context.Background(), tasks.ListRequest{})
	if len(listTasks.Data) > 0 {
		id := listTasks.Data[0].AuditID
		bytes, err = client.CloudAPI().Tasks().GetRaw(context.Background(), tasks.GetRequest{AuditID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Tasks get", bytes, tasks.RecordAsyncTask{}, t)
	} else {
		t.Errorf("Can not test Tasks get because Tasks list is empty")
	}

	// Trunk
	// List
	bytes, err = client.CloudAPI().Trunk().ListRaw(context.Background(), trunk.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Trunk list", bytes, trunk.ListTrunks{}, t)
	// Get
	listTrunk, _ := client.CloudAPI().Trunk().List(context.Background(), trunk.ListRequest{})
	if len(listTrunk.Data) > 0 {
		id := listTrunk.Data[0].ID
		bytes, err = client.CloudAPI().Trunk().GetRaw(context.Background(), trunk.GetRequest{TrunkID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Trunk get", bytes, trunk.ItemTrunk{}, t)
	} else {
		t.Errorf("Can not test Trunk get because Trunk list is empty")
	}

	// VINS
	// List
	bytes, err = client.CloudAPI().VINS().ListRaw(context.Background(), vins.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("VINS list", bytes, vins.ListVINS{}, t)
	// Get
	listVINS, _ := client.CloudAPI().VINS().List(context.Background(), vins.ListRequest{})
	if len(listVINS.Data) > 0 {
		id := listVINS.Data[0].ID
		bytes, err = client.CloudAPI().VINS().GetRaw(context.Background(), vins.GetRequest{VINSID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("VINS get", bytes, vins.RecordVINS{}, t)
	} else {
		t.Errorf("Can not test VINS get because VINS list is empty")
	}

	// VGPU
	// List
	bytes, err = client.CloudAPI().VGPU().ListRaw(context.Background(), vgpu.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("VGPU list", bytes, vgpu.ListVGPU{}, t)

	// Zone
	// List
	bytes, err = client.CloudAPI().Zone().ListRaw(context.Background(), zone.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Zone list", bytes, zone.ListZones{}, t)
	// Get
	ListZones, _ := client.CloudAPI().Zone().List(context.Background(), zone.ListRequest{})
	if len(ListZones.Data) > 0 {
		id := ListZones.Data[0].ID
		bytes, err = client.CloudAPI().Zone().GetRaw(context.Background(), zone.GetRequest{ID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Zone get", bytes, zone.RecordZone{}, t)
	} else {
		t.Errorf("Can not test Zone get because Zones list is empty")
	}
}

// WARNING: not working correctly due to inclusions of tagless structures in cloudbroker
// TestGetListCloudbroker tests platforms responses vs. json tags of golang structures in cloudbroker get/list methods
func TestGetListCloudbroker(t *testing.T) {
	var bytes []byte
	var err error
	client, err := getClient()
	if err != nil {
		t.Fatalf("Cannot get client: %v", err)
	}

	const logFileName = "test_get_list_cloudbroker.log"
	// Account
	// List
	bytes, err = client.CloudBroker().Account().ListRaw(context.Background(), account_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Account list", bytes, account_cb.ListAccounts{}, t)
	// Get
	listAcc, _ := client.CloudBroker().Account().List(context.Background(), account_cb.ListRequest{})
	if len(listAcc.Data) > 0 {
		id := listAcc.Data[0].ID
		bytes, err = client.CloudBroker().Account().GetRaw(context.Background(), account_cb.GetRequest{AccountID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Account get", bytes, account_cb.RecordAccount{}, t)
	} else {
		t.Errorf("Can not test Account get because account list is empty")
	}

	// Audit
	// List
	bytes, err = client.CloudBroker().Audit().ListRaw(context.Background(), audit_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Audit list", bytes, audit_cb.ListAudits{}, t)
	// Get
	listAudits, _ := client.CloudBroker().Audit().List(context.Background(), audit_cb.ListRequest{})
	if len(listAudits.Data) > 0 {
		id := listAudits.Data[0].GUID
		bytes, err = client.CloudBroker().Audit().GetRaw(context.Background(), audit_cb.GetRequest{AuditGuid: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Audit get", bytes, audit_cb.RecordAudit{}, t)
	} else {
		t.Errorf("Can not test Audit get because Audit list is empty")
	}

	// Bservice
	// List
	bytes, err = client.CloudBroker().BService().ListRaw(context.Background(), bservice_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Bservice list", bytes, bservice_cb.ListBasicServices{}, t)
	// Get
	listBServ, _ := client.CloudBroker().BService().List(context.Background(), bservice_cb.ListRequest{})
	if len(listBServ.Data) > 0 {
		id := listBServ.Data[0].ID
		bytes, err = client.CloudBroker().BService().GetRaw(context.Background(), bservice_cb.GetRequest{ServiceID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Bservice get", bytes, bservice_cb.RecordBasicService{}, t)
	} else {
		t.Errorf("Can not test Bservice get because bservice list is empty")
	}

	// Compute
	// List
	bytes, err = client.CloudBroker().Compute().ListRaw(context.Background(), compute_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Compute list", bytes, compute_cb.ListComputes{}, t)
	// Get
	listComp, _ := client.CloudBroker().Compute().List(context.Background(), compute_cb.ListRequest{})
	if len(listComp.Data) > 0 {
		id := listComp.Data[0].ID
		bytes, err = client.CloudBroker().Compute().GetRaw(context.Background(), compute_cb.GetRequest{ComputeID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Compute get", bytes, compute_cb.RecordCompute{}, t)
		// GetCPUAlignmentProfile
		bytes, err = client.CloudBroker().Compute().GetCPUAlignmentProfileRaw(context.Background(), compute_cb.GetCPUAlignmentProfileRequest{ComputeID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Compute get_cpu_alignment_profile", bytes, compute_cb.CPUAlignmentProfile{}, t)
	} else {
		t.Errorf("Can not test Compute get because compute list is empty")
	}

	// Disk
	// List
	bytes, err = client.CloudBroker().Disks().ListRaw(context.Background(), disks_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Disk list", bytes, disks_cb.ListDisks{}, t)
	// Get
	listDisk, _ := client.CloudBroker().Disks().List(context.Background(), disks_cb.ListRequest{})
	if len(listDisk.Data) > 0 {
		id := listDisk.Data[0].ID
		bytes, err = client.CloudBroker().Disks().GetRaw(context.Background(), disks_cb.GetRequest{DiskID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Disk get", bytes, disks_cb.RecordDisk{}, t)
	} else {
		t.Errorf("Can not test Disk get because disk list is empty")
	}

	// ExtNet
	// List
	bytes, err = client.CloudBroker().ExtNet().ListRaw(context.Background(), extnet_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("ExtNet list", bytes, extnet_cb.ListExtNet{}, t)
	// Get
	listExtNet, _ := client.CloudBroker().ExtNet().List(context.Background(), extnet_cb.ListRequest{})
	if len(listExtNet.Data) > 0 {
		id := listExtNet.Data[0].ID
		bytes, err = client.CloudBroker().ExtNet().GetRaw(context.Background(), extnet_cb.GetRequest{NetID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("ExtNet get", bytes, extnet_cb.RecordExtNet{}, t)
	} else {
		t.Errorf("Can not test ExtNet get because listExtNet list is empty")
	}

	// FLIPGroup
	// List
	bytes, err = client.CloudBroker().FLIPGroup().ListRaw(context.Background(), flipgroup_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("FLIPGroup list", bytes, flipgroup_cb.ListFLIPGroups{}, t)
	// Get
	listFG, _ := client.CloudBroker().FLIPGroup().List(context.Background(), flipgroup_cb.ListRequest{})
	if len(listFG.Data) > 0 {
		id := listFG.Data[0].ID
		bytes, err = client.CloudBroker().FLIPGroup().GetRaw(context.Background(), flipgroup_cb.GetRequest{FLIPGroupID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("FLIPGroup get", bytes, flipgroup_cb.RecordFLIPGroup{}, t)
	} else {
		t.Errorf("Can not test FLIPGroup get because flipgroup list is empty")
	}

	// Grid
	// List
	bytes, err = client.CloudBroker().Grid().ListRaw(context.Background(), grid_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Grid list", bytes, grid_cb.ListGrids{}, t)
	// Get
	listGrid, _ := client.CloudBroker().Grid().List(context.Background(), grid_cb.ListRequest{})
	if len(listGrid.Data) > 0 {
		id := listGrid.Data[0].ID
		bytes, err = client.CloudBroker().Grid().GetRaw(context.Background(), grid_cb.GetRequest{GID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Grid get", bytes, grid_cb.RecordGrid{}, t)
	} else {
		t.Errorf("Can not test Grid get because Grid list is empty")
	}

	// Image
	//// List
	bytes, err = client.CloudBroker().Image().ListRaw(context.Background(), image_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Image list", bytes, image_cb.ListImages{}, t)
	// Get
	listImg, _ := client.CloudBroker().Image().List(context.Background(), image_cb.ListRequest{})
	if len(listImg.Data) > 0 {
		id := listImg.Data[0].ID
		bytes, err = client.CloudBroker().Image().GetRaw(context.Background(), image_cb.GetRequest{ImageID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Image get", bytes, image_cb.RecordImage{}, t)
	} else {
		t.Errorf("Can not test Image get because Image list is empty")
	}

	// K8CI
	// List
	bytes, err = client.CloudBroker().K8CI().ListRaw(context.Background(), k8ci_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("K8CI list", bytes, k8ci_cb.ListK8CI{}, t)
	// Get
	listk8ci, _ := client.CloudBroker().K8CI().List(context.Background(), k8ci_cb.ListRequest{})
	if len(listk8ci.Data) > 0 {
		id := listk8ci.Data[0].ID
		bytes, err = client.CloudBroker().K8CI().GetRaw(context.Background(), k8ci_cb.GetRequest{K8CIID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("K8CI get", bytes, k8ci_cb.RecordK8CI{}, t)
	} else {
		t.Errorf("Can not test K8CI get because K8CI list is empty")
	}

	// K8S
	// List
	bytes, err = client.CloudBroker().K8S().ListRaw(context.Background(), k8s_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("K8S list", bytes, k8s_cb.ListK8S{}, t)
	// Get
	listk8s, _ := client.CloudBroker().K8S().List(context.Background(), k8s_cb.ListRequest{})
	if len(listk8s.Data) > 0 {
		id := listk8s.Data[0].ID
		bytes, err = client.CloudBroker().K8S().GetRaw(context.Background(), k8s_cb.GetRequest{K8SID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("K8S get", bytes, k8s_cb.RecordK8S{}, t)
	} else {
		t.Errorf("Can not test K8S get because K8S list is empty")
	}

	// LB
	// List
	bytes, err = client.CloudBroker().LB().ListRaw(context.Background(), lb_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("LB list", bytes, lb_cb.ListLB{}, t)
	// Get
	listLB, _ := client.CloudBroker().LB().List(context.Background(), lb_cb.ListRequest{})
	if len(listLB.Data) > 0 {
		id := listLB.Data[0].ID
		bytes, err = client.CloudBroker().LB().GetRaw(context.Background(), lb_cb.GetRequest{LBID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("LB get", bytes, lb_cb.RecordLB{}, t)
	} else {
		t.Errorf("Can not test LB get because LB list is empty")
	}

	// Node
	// List
	bytes, err = client.CloudBroker().Node().ListRaw(context.Background(), node_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Node list", bytes, node_cb.ListNodes{}, t)
	// Get
	listNode, _ := client.CloudBroker().Node().List(context.Background(), node_cb.ListRequest{})
	if listNode != nil && len(listNode.Data) > 0 {
		id := listNode.Data[0].ID
		bytes, err = client.CloudBroker().Node().GetRaw(context.Background(), node_cb.GetRequest{NID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Node get", bytes, node_cb.RecordNode{}, t)
		// GetNetworkInfo
		bytes, err = client.CloudBroker().Node().GetNetworkInfoRaw(context.Background(), node_cb.GetNetworkInfoRequest{NodeID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Node get_network_info", bytes, node_cb.RecordNodeNetworkInfo{}, t)
	} else {
		t.Errorf("Can not test Node get because node list is empty")
	}

	// Node GetPCIDevices
	if listNode != nil && len(listNode.Data) > 0 {
		id := listNode.Data[0].ID
		bytes, err = client.CloudBroker().Node().GetPCIDevicesRaw(context.Background(), node_cb.GetPCIDevicesRequest{NodeID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Node PCI devices list", bytes, node_cb.ListPCIDevices{}, t)
	} else {
		t.Errorf("Can not test Node GetPCIDevices because node list is empty")
	}

	// Pcidevice
	// List
	bytes, err = client.CloudBroker().PCIDevice().ListRaw(context.Background(), pcidevice_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Pcidevice list", bytes, pcidevice_cb.ListPCIDevices{}, t)

	// QoS policy
	// List
	bytes, err = client.CloudBroker().QoSPolicy().ListRaw(context.Background(), qospolicy_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("QoS policy list", bytes, qospolicy_cb.ListQoSPolicies{}, t)
	// Get
	listQosPolicies, _ := client.CloudBroker().QoSPolicy().List(context.Background(), qospolicy_cb.ListRequest{})
	if len(listQosPolicies.Data) > 0 {
		id := listQosPolicies.Data[0].ID
		bytes, err = client.CloudBroker().QoSPolicy().GetRaw(context.Background(), qospolicy_cb.GetRequest{QoSPolicyID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("QoS policy get", bytes, qospolicy_cb.RecordQoSPolicy{}, t)
	} else {
		t.Errorf("Can not test QoS policy get because QoS policy list is empty")
	}

	// RG
	// List
	bytes, err = client.CloudBroker().RG().ListRaw(context.Background(), rg_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("RG list", bytes, rg_cb.ListRG{}, t)
	// Get
	listRG, _ := client.CloudBroker().RG().List(context.Background(), rg_cb.ListRequest{})
	if len(listRG.Data) > 0 {
		id := listRG.Data[0].ID
		bytes, err = client.CloudBroker().RG().GetRaw(context.Background(), rg_cb.GetRequest{RGID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("RG get", bytes, rg_cb.RecordRG{}, t)
	} else {
		t.Errorf("Can not test RG get because RG list is empty")
	}

	// Security group
	// List
	bytes, err = client.CloudBroker().SecurityGroup().ListRaw(context.Background(), secgroup_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Security group list", bytes, secgroup_cb.ListSecurityGroups{}, t)
	// Get
	listSecurityGroups, _ := client.CloudBroker().SecurityGroup().List(context.Background(), secgroup_cb.ListRequest{})
	if len(listSecurityGroups.Data) > 0 {
		id := listSecurityGroups.Data[0].ID
		bytes, err = client.CloudBroker().SecurityGroup().GetRaw(context.Background(), secgroup_cb.GetRequest{SecurityGroupID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Security group get", bytes, secgroup_cb.RecordSecurityGroup{}, t)
	} else {
		t.Errorf("Can not test Security group get because Security group list is empty")
	}

	// SEP
	// List
	bytes, err = client.CloudBroker().SEP().ListRaw(context.Background(), sep_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("SEP list", bytes, sep_cb.ListSEP{}, t)
	// Get
	listSEP, _ := client.CloudBroker().SEP().List(context.Background(), sep_cb.ListRequest{})
	if len(listSEP.Data) > 0 {
		id := listSEP.Data[0].ID
		bytes, err = client.CloudBroker().SEP().GetRaw(context.Background(), sep_cb.GetRequest{SEPID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("SEP get", bytes, sep_cb.RecordSEP{}, t)
	} else {
		t.Errorf("Can not test SEP get because SEP list is empty")
	}

	bytes, err = client.CloudBroker().SEP().ListAvailableSEPAndPoolsRaw(context.Background(), sep_cb.ListAvailableSEPAndPoolsRequest{AccountID: 1})
	if err != nil {
		t.Error(err)
	}
	getResult("SEP and pools list", bytes, sep_cb.ListAvailableSEP{}, t)

	// Storage policy
	// List
	bytes, err = client.CloudBroker().StPolicy().ListRaw(context.Background(), stpolicy_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Storage policy list", bytes, stpolicy_cb.ListStoragePolicies{}, t)
	// Get
	listStoragePolicies, _ := client.CloudBroker().StPolicy().List(context.Background(), stpolicy_cb.ListRequest{})
	if len(listStoragePolicies.Data) > 0 {
		id := listStoragePolicies.Data[0].ID
		bytes, err = client.CloudBroker().StPolicy().GetRaw(context.Background(), stpolicy_cb.GetRequest{StoragePolicyID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Storage policy get", bytes, stpolicy_cb.InfoStoragePolicy{}, t)
	} else {
		t.Errorf("Can not test Storage policy get because Storage policy list is empty")
	}

	// Tasks
	// List
	bytes, err = client.CloudBroker().Tasks().ListRaw(context.Background(), tasks_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Tasks list", bytes, tasks_cb.ListTasks{}, t)

	// Trunk
	// List
	bytes, err = client.CloudBroker().Trunk().ListRaw(context.Background(), trunk_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Trunk list", bytes, trunk_cb.ListTrunks{}, t)
	// Get
	listTrunks, _ := client.CloudBroker().Trunk().List(context.Background(), trunk_cb.ListRequest{})
	if len(listTrunks.Data) > 0 {
		id := listTrunks.Data[0].ID
		bytes, err = client.CloudBroker().Trunk().GetRaw(context.Background(), trunk_cb.GetRequest{TrunkID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Trunk get", bytes, trunk_cb.ItemTrunk{}, t)
	} else {
		t.Errorf("Can not test Trunk get because Trunk list is empty")
	}

	// VINS
	// List
	bytes, err = client.CloudBroker().VINS().ListRaw(context.Background(), vins_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("VINS list", bytes, vins_cb.ListVINS{}, t)
	// Get
	listVINS, _ := client.CloudBroker().VINS().List(context.Background(), vins_cb.ListRequest{})
	if len(listVINS.Data) > 0 {
		id := listVINS.Data[0].ID
		bytes, err = client.CloudBroker().VINS().GetRaw(context.Background(), vins_cb.GetRequest{VINSID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("VINS get", bytes, vins_cb.RecordVINS{}, t)
	} else {
		t.Errorf("Can not test VINS get because VINS list is empty")
	}

	// Zone
	// List
	bytes, err = client.CloudBroker().Zone().ListRaw(context.Background(), zone_cb.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Zone list", bytes, zone.ListZones{}, t)
	// Get
	ListZones, _ := client.CloudBroker().Zone().List(context.Background(), zone_cb.ListRequest{})
	if len(ListZones.Data) > 0 {
		id := ListZones.Data[0].ID
		bytes, err = client.CloudBroker().Zone().GetRaw(context.Background(), zone_cb.GetRequest{ID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Zone get", bytes, zone_cb.RecordZone{}, t)

		// GetCPUAlignmentProfile
		bytes, err = client.CloudBroker().Zone().GetCPUAlignmentProfileRaw(context.Background(), zone_cb.GetCPUAlignmentProfileRequest{ZoneID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Zone get_cpu_alignment_profile", bytes, []zone_cb.CpuAlignmentProfile{}, t)
	} else {
		t.Errorf("Can not test Zone get because Zones list is empty")
	}

	// ListCPUAlignmentProfile
	bytes, err = client.CloudBroker().Zone().ListCPUAlignmentProfileRaw(context.Background(), zone_cb.ListCPUAlignmentProfileRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Zone list_cpu_alignment_profile", bytes, zone_cb.ListCPUAlignmentProfiles{}, t)
}

// TestGetListSDNAPI tests platforms responses vs. json tags of golang structures in cloudapi get/list methods
func TestGetListSDNAPI(t *testing.T) {
	var bytes []byte
	var err error
	client, err := getClient()
	if err != nil {
		t.Fatalf("Cannot get client: %v", err)
	}

	// AccessGroups
	// List
	bytes, err = client.SDN().AccessGroups().ListRaw(context.Background(), acsgroups.ListGroupsRequest{})
	if err != nil {
		t.Error(err)
	}

	getResult("access groups list", bytes, acsgroups.AccessGroup{}, t)

	// Users AccessGroups
	// list
	listGroups, _ := client.SDN().AccessGroups().List(context.Background(), acsgroups.ListGroupsRequest{})
	if len(listGroups.AccessGroups) > 0 {
		id := listGroups.AccessGroups[0].ID
		bytes, err = client.SDN().AccessGroups().UserListRaw(context.Background(), acsgroups.UsersListRequest{AccessGroupID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("access groups users list", bytes, acsgroups.User{}, t)
	} else {
		t.Errorf("Can not test users get because acs groups list is empty")
	}

	// DefaultSecurityPolicies
	// List
	bytes, err = client.SDN().DefaultSecurityPolicies().ListRaw(context.Background(), defsecpolicies.ListRequest{})
	if err != nil {
		t.Error(err)
	}

	getResult("default security policies list", bytes, defsecpolicies.SecurityPoliciesList{}, t)

	// Address Pools
	// List
	bytes, err = client.SDN().AddressPools().ListRaw(context.Background(), adrspools.ListAddressPoolsRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Address pools list", bytes, adrspools.AddressPoolsList{}, t)
	// Get
	listStoragePolicies, _ := client.SDN().AddressPools().List(context.Background(), adrspools.ListAddressPoolsRequest{})
	if len(listStoragePolicies.Pools) > 0 {
		id := listStoragePolicies.Pools[0].ID
		bytes, err = client.SDN().AddressPools().GetRaw(context.Background(), adrspools.GetRequest{ID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Address pools get", bytes, adrspools.NetworkAddressPool{}, t)
	} else {
		t.Errorf("Can not test address pools get because list is empty")
	}

	// Security policies
	// List
	bytes, err = client.SDN().SecurityPolicies().ListRaw(context.Background(), secpolicies.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Security policies list", bytes, secpolicies.SecurityPolicyList{}, t)
	// Get
	listPolicies, _ := client.SDN().SecurityPolicies().List(context.Background(), secpolicies.ListRequest{})
	if len(listPolicies) > 0 {
		id := listPolicies[0].ID
		bytes, err = client.SDN().SecurityPolicies().GetRaw(context.Background(), secpolicies.GetRequest{ID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Security policies get", bytes, secpolicies.SecurityPolicySummary{}, t)
	} else {
		t.Errorf("Can not test security policies get because list is empty")
	}

	// rule List
	bytes, err = client.SDN().SecurityPolicies().Rule().ListRaw(context.Background(), rule.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Security policy rule list", bytes, rule.SecurityRulesList{}, t)
	// Get
	listRules, _ := client.SDN().SecurityPolicies().Rule().List(context.Background(), rule.ListRequest{})
	if len(listRules) > 0 {
		id := listRules[0].ID
		securityPolicyID := listRules[0].SecurityPolicyID
		bytes, err = client.SDN().SecurityPolicies().Rule().GetRaw(context.Background(), rule.GetRequest{
			SecurityPolicyID: securityPolicyID,
			SecurityRuleID:   id})
		if err != nil {
			t.Error(err)
		}
		getResult("Security policy rule get", bytes, rule.SecurityRule{}, t)
	} else {
		t.Errorf("Can not test the security policy rules get because list is empty")
	}

	// ExtNet
	// List
	bytes, err = client.SDN().ExtNet().ListRaw(context.Background(), extnet_sdn.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("ExtNet list", bytes, extnet_sdn.ListExtNet{}, t)
	// Get
	listExtNet, _ := client.SDN().ExtNet().List(context.Background(), extnet_sdn.ListRequest{})
	if len(listExtNet) > 0 {
		id := listExtNet[0].ID
		bytes, err = client.SDN().ExtNet().GetRaw(context.Background(), extnet_sdn.GetRequest{ExtNetID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("ExtNet get", bytes, extnet_sdn.ExternalNetworkResponse{}, t)
	} else {
		t.Errorf("Can not test ExtNet get because listExtNet list is empty")
	}

	// Network object groups
	// List
	bytes, err = client.SDN().NetworkObjectGroups().ListRaw(context.Background(), netobjgroups.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("NetObjGroup list", bytes, netobjgroups.NetObjGroupList{}, t)
	// Get
	listNetObjGroups, _ := client.SDN().NetworkObjectGroups().List(context.Background(), netobjgroups.ListRequest{})
	if len(listNetObjGroups.Objects) > 0 {
		id := listNetObjGroups.Objects[0].ID
		bytes, err = client.SDN().NetworkObjectGroups().GetRaw(context.Background(), netobjgroups.GetRequest{NetObjGroupID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("NetObjGroup get", bytes, netobjgroups.RecordNetObjGroup{}, t)
	} else {
		t.Errorf("Can not test NetObjGroup get because listNetObjGroups list is empty")
	}

	// Segment
	// List
	bytes, err = client.SDN().Segments().ListRaw(context.Background(), segments.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Segments list", bytes, segments.ListSegment{}, t)
	// Get
	listSegments, _ := client.SDN().Segments().List(context.Background(), segments.ListRequest{})
	if len(listSegments) > 0 {
		id := listSegments[0].ID
		bytes, err = client.SDN().Segments().GetRaw(context.Background(), segments.GetRequest{SegmentID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Segments get", bytes, adrspools.NetworkAddressPool{}, t)
	} else {
		t.Errorf("Can not test segments get because list is empty")
	}

	// Hypervisors
	// List
	bytes, err = client.SDN().Hypervisors().ListRaw(context.Background(), hypervisors.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Hypervisors list", bytes, hypervisors.HypervisorsList{}, t)
	// Get
	listHypervisors, _ := client.SDN().Hypervisors().List(context.Background(), hypervisors.ListRequest{})
	if len(listHypervisors) > 0 {
		id := listHypervisors[0].Name
		bytes, err = client.SDN().Hypervisors().GetRaw(context.Background(), hypervisors.GetRequest{Name: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Hypervisors get", bytes, hypervisors.RecordHypervisor{}, t)
	} else {
		t.Errorf("Can not test Hypervisors get because listHypervisors list is empty")
	}

	// FloatingIPs
	// List
	bytes, err = client.SDN().FloatingIPs().ListRaw(context.Background(), flips.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("FloatingIPs list", bytes, flips.FloatingIPsList{}, t)
	// Get
	listFloatingIPs, _ := client.SDN().FloatingIPs().List(context.Background(), flips.ListRequest{})
	if len(listFloatingIPs.Objects) > 0 {
		id := listFloatingIPs.Objects[0].ID
		bytes, err = client.SDN().FloatingIPs().GetRaw(context.Background(), flips.GetRequest{FloatingIPID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("FloatingIPs get", bytes, flips.RecordFloatingIP{}, t)
	} else {
		t.Errorf("Can not test FloatingIPs get because listFloatingIPs list is empty")
	}

	// logical ports
	// List
	bytes, err = client.SDN().LogicalPorts().ListRaw(context.Background(), logicalports.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Logical ports list", bytes, logicalports.LogicalPortsList{}, t)
	// Get
	listLP, _ := client.SDN().LogicalPorts().List(context.Background(), logicalports.ListRequest{})
	if len(listLP.Ports) > 0 {
		id := listStoragePolicies.Pools[0].ID
		bytes, err = client.SDN().LogicalPorts().GetRaw(context.Background(), logicalports.GetRequest{ID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Logical port get", bytes, logicalports.LogicalPort{}, t)
	} else {
		t.Errorf("Can not test logical ports get because list is empty")
	}

	// Routers
	// List
	bytes, err = client.SDN().Routers().ListRaw(context.Background(), routers.ListRequest{})
	if err != nil {
		t.Error(err)
	}
	getResult("Routers list", bytes, routers.RoutersList{}, t)
	// Get
	routerList, _ := client.SDN().Routers().List(context.Background(), routers.ListRequest{})
	if len(routerList) > 0 {
		id := routerList[0].ID
		bytes, err = client.SDN().Routers().GetRaw(context.Background(), routers.GetRequest{ID: id})
		if err != nil {
			t.Error(err)
		}
		getResult("Router get", bytes, routers.RoutersModel{}, t)
	} else {
		t.Errorf("Can not test routers get because routerList list is empty")
	}

	// Version
	bytes, err = client.SDN().Version().GetRaw(context.Background())
	if err != nil {
		t.Error(err)
	}
	getResult("Version get", bytes, version.RecordVersion{}, t)
}

// TestRequestsCloudAPI tests platform requests vs. golang request structures in sdk for cloudapi requests
func TestRequestsCloudAPI(t *testing.T) {
	bytes := getBytesFromJSON("input.json", t)
	getErrorsFromJSON(bytes, t, "cloudapi")
}

// TestRequestsCloudbroker tests platform requests vs. golang request structures in sdk for cloudbroker requests
func TestRequestsCloudbroker(t *testing.T) {
	bytes := getBytesFromJSON("input.json", t)
	getErrorsFromJSON(bytes, t, "cloudbroker")
}

func TestRequestsSDN(t *testing.T) {
	bytes := getBytesFromJSON("input.json", t)
	getErrorsFromJSON(bytes, t, "sdn")
}

// TestGetAllPaths tests if platform has any handlers that golang sdk doesn't. In this case, list of missing handlers is provided.
// Note that DEPRECATED_GROUPS stores list of groups that are considered deprecated. You can add additional grops to DEPRECATED_GROUPS if required.
func TestGetAllPaths(t *testing.T) {
	bytes := getBytesFromJSON("input.json", t)
	jsonUrls, err := getUrlsFromBytes(bytes)
	if err != nil {
		t.Error(err)
	}

	decortUrls := readUrlFromDir("../../pkg", len(jsonUrls))

	missingUrls := getMissingDecortUrls(jsonUrls, decortUrls)
	if len(missingUrls) > 0 {
		errorText := fmt.Sprintf("Below API handlers (%d in total) need to be added to decort-sdk:\n", len(missingUrls))
		for _, r := range missingUrls {
			errorText += fmt.Sprintln(r)
		}
		t.Errorf("\n%s\n", errorText)
	}

	deprecatedUrls := getDeprecatedDecortUrls(jsonUrls, decortUrls)
	if len(deprecatedUrls) > 0 {
		errorText := fmt.Sprintf("Below API handlers (%d in total) need to be delete to decort-sdk:\n", len(deprecatedUrls))
		for _, r := range deprecatedUrls {
			errorText += fmt.Sprintln(r)
		}
		t.Errorf("\n%s\n", errorText)
	}

	caTestUrls := getRequestsMapCloudAPI()
	cbTestUrls := getRequestsMapCloudbroker()
	sdnTestUrls := getRequestsMapSDN()

	urlsInTest := make([]string, len(caTestUrls)+len(cbTestUrls)+len(sdnTestUrls))

	i := 0
	for k := range caTestUrls {
		urlsInTest[i] = k
		i++
	}
	for k := range cbTestUrls {
		urlsInTest[i] = k
		i++
	}
	for k := range sdnTestUrls {
		urlsInTest[i] = k
		i++
	}

	missingUrls = getMissingDecortUrls(jsonUrls, urlsInTest)
	if len(missingUrls) > 0 {
		errorText := fmt.Sprintf("Below API handlers (%d in total) need to be added to request map:\n", len(missingUrls))
		for _, r := range missingUrls {
			errorText += fmt.Sprintln(r)
		}
		t.Errorf("\n%s\n", errorText)
	}

	deprecatedUrls = getDeprecatedDecortUrls(jsonUrls, urlsInTest)
	if len(deprecatedUrls) > 0 {
		errorText := fmt.Sprintf("Below API handlers (%d in total) need to be delete to request map:\n", len(deprecatedUrls))
		for _, r := range deprecatedUrls {
			errorText += fmt.Sprintln(r)
		}
		t.Errorf("\n%s\n", errorText)
	}

}
