| 69 | } |
| 70 | |
| 71 | func ExampleCredHub_Request() { |
| 72 | _ = func() { |
| 73 | ch, _ := credhub.New("https://example.com") |
| 74 | |
| 75 | // Get encryption key usage |
| 76 | response, err := ch.Request("GET", "/api/v1/key-usage", nil, nil, true) |
| 77 | if err != nil { |
| 78 | panic("couldn't get key usage") |
| 79 | } |
| 80 | |
| 81 | var keyUsage map[string]int |
| 82 | decoder := json.NewDecoder(response.Body) |
| 83 | err = decoder.Decode(&keyUsage) |
| 84 | if err != nil { |
| 85 | panic("couldn't parse response") |
| 86 | } |
| 87 | |
| 88 | fmt.Println("Active Key: ", keyUsage["active_key"]) |
| 89 | // Sample Output: |
| 90 | // Active Key: 1231231 |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | func Example() { |
| 95 | _ = func() { |