SDKs
...
Go SDK
v1 (legacy)
Management Client
8min
note read common docid\ u qox n0barrls2ujjs1 before this importing the management client import( "gitlab com/l3178/sdk go/management client" management request "gitlab com/l3178/sdk go/management client/models/request" ) creating the client config = management client newmanagementclientconfiguration("managementkey") c = management client newmanagementclient(config) customer api ctx = context background() t run("create", func(t testing t) { 	resp = c customerapi() createcustomer(ctx, management request createcustomerrequest{ 	 email "ttt\@ttt ttt", 	 firstname "test", 	}) 	require noerror(t, resp error) 	id = resp value id }) t run("list", func(t testing t) { 	resp = c customerapi() listcustomers(ctx, management request searchcustomersrequest{ 	 email "ttt\@ttt ttt", 	}) 	assert noerror(t, resp error) 	assert equal(t, 1, resp count) }) t run("edit", func(t testing t) { 	resp = c customerapi() editcustomer(ctx, id, management request createcustomerrequest{ 	 lastname "abcd", 	}) 	assert noerror(t, resp error) }) t run("get", func(t testing t) { 	resp = c customerapi() showcustomer(ctx, id) 	assert noerror(t, resp error) 	assert equal(t, "abcd", resp value lastname) }) t run("delete", func(t testing t) { 	err = c customerapi() deletecustomer(ctx, id) 	assert noerror(t, err) }) t run("create", func(t testing t) { 	resp = c customerapi() createcustomerlabel(ctx, management request createcustomerlabelrequest{ 	 label "abcd", 	 color "efgh", 	}) 	require noerror(t, resp error) 	id = resp value id }) t run("list", func(t testing t) { 	resp = c customerapi() listcustomerlabels(ctx, management request searchrequest{}) 	assert noerror(t, resp error) 	assert equal(t, 1, resp count) }) t run("edit", func(t testing t) { 	resp = c customerapi() editcustomerlabel(ctx, id, management request createcustomerlabelrequest{ 	 color "1234", 	}) 	assert noerror(t, resp error) }) t run("get", func(t testing t) { 	resp = c customerapi() showcustomerlabel(ctx, id) 	assert noerror(t, resp error) 	assert equal(t, "1234", resp value color) }) t run("delete", func(t testing t) { 	err = c customerapi() deletecustomerlabel(ctx, id) 	assert noerror(t, err) }) t run("create", func(t testing t) { 	resp = c customerapi() createcustomeraccount(ctx, management request createcustomeraccountrequest{ 	 code "abcd", 	 name "efgh", 	}) 	require noerror(t, resp error) 	id = resp value id }) t run("list", func(t testing t) { 	resp = c customerapi() listcustomeraccounts(ctx, management request searchrequest{}) 	assert noerror(t, resp error) 	assert equal(t, 1, resp count) }) t run("edit", func(t testing t) { 	resp = c customerapi() editcustomeraccount(ctx, id, management request createcustomeraccountrequest{ 	 description "test", 	}) 	assert noerror(t, resp error) }) t run("get", func(t testing t) { 	resp = c customerapi() showcustomeraccount(ctx, id) 	assert noerror(t, resp error) 	assert equal(t, "test", resp value description) }) t run("delete", func(t testing t) { 	err = c customerapi() deletecustomeraccount(ctx, id) 	assert noerror(t, err) }) device api ctx = context background() t run("searchdevices", func(t testing t) { 	resp = c deviceapi() listdevices(ctx, management request searchdevicesrequest{ 	 license testlicenseid, 	}) 	assert noerror(t, resp error) }) t run("showdevice", func(t testing t) { 	c deviceapi() showdevice(ctx, deviceid) }) t run("resetdevice", func(t testing t) { 	c deviceapi() resetdevice(ctx, deviceid) }) t run("blacklistdevice", func(t testing t) { 	c deviceapi() blacklistdevice(ctx, deviceid) }) t run("createdevicevariable", func(t testing t) { 	resp = c deviceapi() createdevicevariable(ctx, management request createdevicevariablerequest{ 	 variable "test", 	 value "value", 	 device deviceid, 	}) 	assert noerror(t, resp error) }) t run("updatedevicevariable", func(t testing t) { 	resp = c deviceapi() updatedevicevariable(ctx, deviceid, management request updatedevicevariablerequest{ 	 variable "test", 	 value "value", 	}) 	assert noerror(t, resp error) }) t run("deletedevicevariable", func(t testing t) { 	err = c deviceapi() deletedevicevariable(ctx, deviceid) 	assert noerror(t, err) }) t run("searchdevicevariable", func(t testing t) { 	resp = c deviceapi() listdevicevariables(ctx, management request searchdevicevariablesrequest{ 	 device deviceid, 	}) 	assert noerror(t, resp error) }) t run("showdevicevariable", func(t testing t) { 	resp = c deviceapi() showdevicevariable(ctx, deviceid) 	assert noerror(t, resp error) }) license api ctx = context background() t run("disable", func(t testing t) { 	resp = c licenseapi() disablelicense(ctx, testlicenseid) 	assert noerror(t, resp error) }) t run("get", func(t testing t) { 	resp = c licenseapi() getlicense(ctx, testlicenseid) 	assert noerror(t, resp error) 	assert false(t, resp value enabled) }) t run("enable", func(t testing t) { 	resp = c licenseapi() enablelicense(ctx, testlicenseid) 	assert noerror(t, resp error) }) t run("update", func(t testing t) { 	resp = c licenseapi() updatelicense(ctx, testlicenseid, management request updatelicenserequest{ 	 maxactivations 5, 	}) 	assert noerror(t, resp error) }) t run("list", func(t testing t) { 	resp = c licenseapi() searchlicenses(ctx, management request searchlicensesrequest{}) 	assert noerror(t, resp error) 	assert equal(t, 3, resp count) }) t run("assign", func(t testing t) { 	resp = c licenseapi() assignuser(ctx, testuserlicenseid, management request assignusertolicenserequest{ 	 email "test\@abcd efgh", 	 password "abcdefgh", 	}) 	assert noerror(t, resp error) }) t run("list", func(t testing t) { 	resp = c licenseapi() listlicenseusers(ctx, management request searchusersrequest{ 	 emailcontains "test\@abcd efgh", 	}) 	assert noerror(t, resp error) 	require equal(t, 1, resp count) 	userid = resp results\[0] id }) t run("password", func(t testing t) { 	resp = c licenseapi() setuserpassword(ctx, userid, management request setpasswordrequest{ 	 password "test", 	}) 	assert noerror(t, resp error) }) t run("unassign", func(t testing t) { 	resp = c licenseapi() unassignuser(ctx, testuserlicenseid, management request unassignrequest{ 	 licenseuserid userid, 	}) 	assert noerror(t, resp error) }) t run("list", func(t testing t) { 	resp = c licenseapi() searchlicensecustomfields(ctx, management request searchlicensecustomfieldsrequest{ 	 license testlicenseid, 	}) 	require noerror(t, resp error) 	require equal(t, 1, resp count) 	id = resp results\[0] id }) t run("get", func(t testing t) { 	resp = c licenseapi() getlicensecustomfield(ctx, id) 	assert noerror(t, resp error) }) t run("update", func(t testing t) { 	resp = c licenseapi() updatelicensecustomfield(ctx, id, management request updatecustomlicensefieldrequest{ 	 value "test", 	}) 	assert noerror(t, resp error) }) order api ctx = context background() t run("searchorders", func(t testing t) { 	resp = c orderapi() searchorders(ctx, management request searchordersrequest{}) 	assert noerror(t, resp error) }) t run("getorder", func(t testing t) { 	resp = c orderapi() getorder(ctx, orderid) 	assert noerror(t, resp error) }) t run("createorder", func(t testing t) { 	resp = c orderapi() createorder(ctx, management models webhookorder{ 	 items \[]management models orderitem{ 	 { 	 productcode "code", 	 licenses \[]management models orderlicense{ 	 { 	 key "key", 	 }, 	 }, 	 }, 	 }, 	}) 	assert noerror(t, resp error) }) t run("exporttocsv", func(t testing t) { 	timestart = time now() add( 5 time hour) 	timeend = time now() 	resp = c orderapi() exporttocsv(ctx, timestart, timeend) 	assert noerror(t, resp error) }) t run("exporttocsvrange", func(t testing t) { 	var r management models range 	r = r last30() 	resp = c orderapi() exporttocsvrange(ctx, r) 	assert noerror(t, resp error) }) t run("generatelicensekeys", func(t testing t) { 	resp = c orderapi() generatelicensekeys(ctx, management request generatelicenserequest{ 	 product "product", 	 quantity 1, 	}) 	assert noerror(t, resp error) }) t run("addmanagertoorder", func(t testing t) { 	resp = c orderapi() addmanagertoorder(ctx, orderid, management request addmanagertoorderrequest{ 	 email "email", 	 password "password", 	}) 	assert noerror(t, resp error) }) product api ctx = context background() t run("list", func(t testing t) { 	resp = c productapi() listproducts(ctx, management request searchproductsrequest{}) 	assert noerror(t, resp error) 	assert equal(t, 2, resp count) }) t run("show", func(t testing t) { 	resp = c productapi() showproduct(ctx, testproductid) 	assert noerror(t, resp error) }) t run("create", func(t testing t) { 	resp = c productapi() createinstallationfile(ctx, management request createinstallationfilerequest{ 	 fulllink "link", 	 product testproductid, 	 version "v1", 	}) 	assert noerror(t, resp error) 	id = resp value id }) t run("list", func(t testing t) { 	resp2 = c productapi() listinstallationfiles(ctx, management request searchinstallationfilesrequest{ 	 product testproductid, 	}) 	assert noerror(t, resp2 error) }) t run("show", func(t testing t) { 	resp3 = c productapi() showinstallationfile(ctx, id) 	assert noerror(t, resp3 error) }) t run("create", func(t testing t) { 	resp = c productapi() createproductcustomfield(ctx, management request createproductcustomfieldrequest{ 	 name "field", 	 defaultvalue "test", 	 product testproductid, 	}) 	assert noerror(t, resp error) 	id = resp value id }) t run("show1", func(t testing t) { 	respshow = c productapi() showproductcustomfield(ctx, id) 	assert noerror(t, respshow\ error) 	assert equal(t, "test", respshow\ value defaultvalue) }) t run("update", func(t testing t) { 	respupdate = c productapi() updateproductcustomfield(ctx, id, management request updateproductcustomfieldrequest{ 	 name "field", 	 defaultvalue "abcd", 	}) 	assert noerror(t, respupdate error) }) t run("show2", func(t testing t) { 	respshow = c productapi() showproductcustomfield(ctx, id) 	assert noerror(t, respshow\ error) 	assert equal(t, "abcd", respshow\ value defaultvalue) }) t run("delete", func(t testing t) { 	err = c productapi() deleteproductcustomfield(ctx, id) 	assert noerror(t, err) }) t run("list", func(t testing t) { 	resplist = c productapi() listproductcustomfields(ctx, management request searchproductcustomfieldsrequest{ 	 product testproductid, 	}) 	assert noerror(t, resplist error) 	assert equal(t, 1, resplist count) })