package netboxgo import ( "context" "net/http" "net/url" "time" "github.com/gorilla/schema" ) type ClusterTypesService service // ClusterTypes is used to list cluster types type ClusterTypes struct { Next interface{} `json:"next"` Previous interface{} `json:"previous"` Results []ClusterType `json:"results"` Count int `json:"count"` } type ClusterType struct { CustomFields struct{} `json:"custom_fields"` LastUpdated time.Time `json:"last_updated"` Display string `json:"display"` Slug string `json:"slug"` Description string `json:"description"` URL string `json:"url"` Created string `json:"created"` Name string `json:"name"` Tags []struct { URL string `json:"url"` Display string `json:"display"` Name string `json:"name"` Slug string `json:"slug"` Color string `json:"color"` ID int `json:"id"` } `json:"tags"` ID int `json:"id"` ClusterCount int `json:"cluster_count"` } // ClusterTypeFilter is used to filter out VirtualizationClusters type ClusterTypeFilter struct { // User specific filters ID string `schema:"id,omitempty"` Name string `schema:"name,omitempty"` Slug string `schema:"slug,omitempty"` Description string `schema:"description,omitempty"` Created string `schema:"created,omitempty"` CreatedGTE string `schema:"created__gte,omitempty"` CreatedLTE string `schema:"created__lte,omitempty"` LastUpdated string `schema:"last_updated,omitempty"` LastUpdatedGTE string `schema:"last_updated__gte,omitempty"` LastUpdatedLTE string `schema:"last_updated__lte,omitempty"` IDIn string `schema:"id__in,omitempty"` Q string `schema:"q,omitempty"` Tag string `schema:"tag,omitempty"` Offset int64 `schema:"offset,omitempty"` Limit int64 `schema:"limit,omitempty"` } const clusterTypesPath = virtualizationPath + "/cluster-types/" // List cluster types. ClusterTypeFilter is used to list based on filter queries. func (s *ClusterTypesService) List(ctx context.Context, f *ClusterTypeFilter) (*ClusterTypes, error) { var clusterTypes ClusterTypes var query string var req *http.Request var err error encoder := schema.NewEncoder() form := url.Values{} err = encoder.Encode(f, form) if err != nil { return &clusterTypes, err } query = form.Encode() req, err = s.client.newRequest(ctx, "GET", clusterTypesPath, query, nil) if err != nil { return &clusterTypes, err } _, err = s.client.do(req, &clusterTypes) if err != nil { return &clusterTypes, err } return &clusterTypes, nil } // Get cluster type. func (s *ClusterTypesService) Get(ctx context.Context, id string) (*ClusterTypes, error) { var clusterTypes ClusterTypes var query string var req *http.Request var err error req, err = s.client.newRequest(ctx, "GET", clusterTypesPath+id+"/", query, nil) if err != nil { return &clusterTypes, err } _, err = s.client.do(req, &clusterTypes) if err != nil { return &clusterTypes, err } return &clusterTypes, nil }