Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func getRackID(site, name string) int {
- url := "https://netbox.cloud.selectel.org/api/dcim/racks/?site=" + site
- req, _ := http.NewRequest("GET", url, nil)
- //
- req.Header.Set("accept", "application/json; indent=4")
- req.Header.Set("Content-Type", "application/json")
- req.Header.Set("Authorization", "Token "+"")
- client := &http.Client{}
- resp, _ := client.Do(req)
- body, _ := ioutil.ReadAll(resp.Body)
- var res = &Response{}
- js :=json.Unmarshal(body,res)
- fmt.Print(js)
- defer resp.Body.Close()
- return 0
- type Site struct {
- Id int `json:"id"`
- Url string `json:"url"`
- Name string `json:"name"`
- Slug string `json:"slug"`
- }
- type RackGroup struct {
- Id int `json:"id"`
- Url string `json:"url"`
- Name string `json:"name"`
- Slug string `json:"slug"`
- RackCount int `json:"rack_count"`
- }
- type Tenant struct {
- Id int `json:"id"`
- Url string `json:"url"`
- Name string `json:"name"`
- Slug string `json:"slug"`
- }
- type Status struct {
- Label string `json:"label"`
- Value int `json:"value"`
- }
- type Role struct {
- Id int `json:"id"`
- Url string `json:"url"`
- Name string `json:"name"`
- Slug string `json:"slug"`
- RackCount int `json:"rack_count"`
- }
- type Type struct {
- Label string `json:"label"`
- Value int `json:"value"`
- }
- type Width struct {
- Label string `json:"label"`
- Value int `json:"value"`
- }
- type OuterUnit struct {
- Label string `json:"label"`
- Value int `json:"value"`
- }
- type Results struct {
- Id int `json:"id"`
- Name string `json:"name"`
- FacilityId string `json:"facility_id"`
- DisplayName string `json:"display_name"`
- Site Site `json:"site"`
- Group RackGroup `json:"group"`
- Tenant Tenant `json:"tenant"`
- Status Status `json:"status"`
- Role Role `json:"role"`
- Serial string `json:"serial"`
- AssetTag string `json:"asset_tag"`
- Type Type `json:"type"`
- Width Width `json:"width"`
- Uheight int `json:"u_height"`
- DescUnits bool `json:"desc_units"`
- OuterWidth int `json:"outer_width"`
- OuterDepth int `json:"outer_depth"`
- OuterUnit OuterUnit `json:"outer_unit"`
- Comments string `json:"comments"`
- Tags []string `json:"tags"`
- CustomFields map[string]string `json:"custom_fields"`
- Created string `json:"created"`
- LastUpdated string `json:"last_updated"`
- DeviceCount int `json:"device_count"`
- PowerfeedCount int `json:"powerfeed_count"`
- }
- type Response struct {
- Count int `json:"count"`
- Next string `json:"next"`
- Previous string `json:"previous"`
- Results []Results `json:"results"`
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement