-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcp_code.go
117 lines (90 loc) · 2.1 KB
/
cp_code.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package main
import (
"fmt"
common "github.com/apiheat/akamai-cli-common"
edgegrid "github.com/apiheat/go-edgegrid"
"github.com/urfave/cli"
)
/*
listContracts
*/
func cmdListContracts(c *cli.Context) error {
return listContracts(c)
}
func listContracts(c *cli.Context) error {
// List all network lists
contracts, _, err := apiClient.Property.ListPropertyContracts()
if err != nil {
fmt.Println(err)
}
common.OutputJSON(contracts)
return nil
}
/*
listGroups
*/
func cmdListGroups(c *cli.Context) error {
return listGroups(c)
}
func listGroups(c *cli.Context) error {
// List all network lists
groups, _, err := apiClient.Property.ListPropertyGroups()
if err != nil {
fmt.Println(err)
}
common.OutputJSON(groups)
return nil
}
/*
listProducts
*/
func cmdListProducts(c *cli.Context) error {
return listProducts(c)
}
func listProducts(c *cli.Context) error {
common.VerifyArgumentByName(c, "contractID")
products, _, err := apiClient.Property.ListPropertyProducts(c.String("contractID"))
if err != nil {
fmt.Println(err)
}
common.OutputJSON(products)
return nil
}
/*
listCPcodes
*/
func cmdListCPcodes(c *cli.Context) error {
return listCPcodes(c)
}
func listCPcodes(c *cli.Context) error {
common.VerifyArgumentByName(c, "contractID")
common.VerifyArgumentByName(c, "groupID")
cpcodes, _, err := apiClient.Property.ListPropertyCPCodes(c.String("contractID"), c.String("groupID"))
if err != nil {
fmt.Println(err)
}
common.OutputJSON(cpcodes)
return nil
}
/*
createCPcode
*/
func cmdCreateCPcode(c *cli.Context) error {
return createCPcode(c)
}
func createCPcode(c *cli.Context) error {
common.VerifyArgumentByName(c, "contractID")
common.VerifyArgumentByName(c, "groupID")
common.VerifyArgumentByName(c, "CPcodeName")
common.VerifyArgumentByName(c, "ProductID")
newCPcode := &edgegrid.PropertyCPCodeNew{
CpcodeName: c.String("CPcodeName"),
ProductID: c.String("ProductID"),
}
resp, err := apiClient.Property.NewPropertyCPcode(newCPcode, c.String("contractID"), c.String("groupID"))
if err != nil {
fmt.Println(err)
}
common.OutputJSON(resp.Body)
return nil
}