Add cohorts example

Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com>
This commit is contained in:
0x6f736f646f
2022-02-23 10:58:59 +03:00
parent 7392289c01
commit a5cfebbb9d
+47 -2
View File
@@ -35,8 +35,12 @@ func main() {
Platform: "nRF52",
}
cohort := mem.Cohort{
Name: "demo5",
Slug: "demo5",
Name: "Example cohort",
Slug: "example-cohort",
}
updatedcohort := mem.Cohort{
Name: "Updated Example cohort",
Slug: "updated-cohort",
}
response1, err := memfault.CreateCohort(project, cohort)
if err != nil {
@@ -59,4 +63,45 @@ func main() {
}
fmt.Print(string(b))
}
response6, err := memfault.ListDevicesINCohorts(project, cohort)
if err != nil {
fmt.Println(err)
} else {
b, err := json.MarshalIndent(response6, "", " ")
if err != nil {
fmt.Println(err)
}
fmt.Print(string(b))
}
response3, err := memfault.RetrieveCohorts(project, cohort)
if err != nil {
fmt.Println(err)
} else {
b, err := json.MarshalIndent(response3, "", " ")
if err != nil {
fmt.Println(err)
}
fmt.Print(string(b))
}
response4, err := memfault.UpdateCohorts(project, updatedcohort, "example-cohort")
if err != nil {
fmt.Println(err)
} else {
b, err := json.MarshalIndent(response4, "", " ")
if err != nil {
fmt.Println(err)
}
fmt.Print(string(b))
}
response5, err := memfault.DeleteCohorts(project, updatedcohort)
if err != nil {
fmt.Println(err)
} else {
fmt.Print(string(response5))
}
}