From a5cfebbb9db1ce7e23e4ff4a193f46e3312d6f0c Mon Sep 17 00:00:00 2001 From: 0x6f736f646f Date: Wed, 23 Feb 2022 10:58:59 +0300 Subject: [PATCH] Add cohorts example Signed-off-by: 0x6f736f646f --- example/cohorts/cohorts.go | 49 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/example/cohorts/cohorts.go b/example/cohorts/cohorts.go index 0083dc2..b990302 100644 --- a/example/cohorts/cohorts.go +++ b/example/cohorts/cohorts.go @@ -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)) + } + }