rob05c commented on a change in pull request #2247: Add an Origin API URL: https://github.com/apache/incubator-trafficcontrol/pull/2247#discussion_r190046195
########## File path: lib/go-tc/v13/origins.go ########## @@ -0,0 +1,150 @@ +package v13 + +import ( + "github.com/apache/incubator-trafficcontrol/lib/go-tc" +) + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +type OriginsResponse struct { + Response []OriginNullable `json:"response"` +} + +// OriginDetailResponse is the JSON object returned for a single origin +type OriginDetailResponse struct { + Response OriginNullable `json:"response"` + tc.Alerts +} + +type Origin struct { + Cachegroup string `json:"cachegroup" db:"cachegroup"` + CachegroupID int `json:"cachegroupId" db:"cachegroup_id"` + Coordinate string `json:"coordinate" db:"coordinate"` + CoordinateID int `json:"coordinateId" db:"coordinate_id"` + DeliveryService string `json:"deliveryService" db:"deliveryservice"` + DeliveryServiceID int `json:"deliveryServiceId" db:"deliveryservice_id"` + FQDN string `json:"fqdn" db:"fqdn"` + ID int `json:"id" db:"id"` + IP6Address string `json:"ip6Address" db:"ip6_address"` + IPAddress string `json:"ipAddress" db:"ip_address"` + IsPrimary bool `json:"isPrimary" db:"is_primary"` + LastUpdated tc.TimeNoMod `json:"lastUpdated" db:"last_updated"` + Name string `json:"name" db:"name"` + Port int `json:"port" db:"port"` + Profile string `json:"profile" db:"profile"` + ProfileID int `json:"profileId" db:"profile_id"` + Protocol string `json:"protocol" db:"protocol"` + Tenant string `json:"tenant" db:"tenant"` + TenantID int `json:"tenantId" db:"tenant_id"` +} + +type OriginNullable struct { + Cachegroup *string `json:"cachegroup" db:"cachegroup"` + CachegroupID *int `json:"cachegroupId" db:"cachegroup_id"` + Coordinate *string `json:"coordinate" db:"coordinate"` + CoordinateID *int `json:"coordinateId" db:"coordinate_id"` + DeliveryService *string `json:"deliveryService" db:"deliveryservice"` + DeliveryServiceID *int `json:"deliveryServiceId" db:"deliveryservice_id"` + FQDN *string `json:"fqdn" db:"fqdn"` + ID *int `json:"id" db:"id"` + IP6Address *string `json:"ip6Address" db:"ip6_address"` + IPAddress *string `json:"ipAddress" db:"ip_address"` + IsPrimary *bool `json:"isPrimary" db:"is_primary"` + LastUpdated *tc.TimeNoMod `json:"lastUpdated" db:"last_updated"` + Name *string `json:"name" db:"name"` + Port *int `json:"port" db:"port"` + Profile *string `json:"profile" db:"profile"` + ProfileID *int `json:"profileId" db:"profile_id"` + Protocol *string `json:"protocol" db:"protocol"` + Tenant *string `json:"tenant" db:"tenant"` + TenantID *int `json:"tenantId" db:"tenant_id"` +} + +type OriginBuilder struct { Review comment: I'm a -1 on this. I can see the convenience, but it's very non-standard. The benefit isn't worth the readability cost, for new devs to figure out. To avoid multiple lines, the Go idiom is to have a `NewOrigin()` func, that either takes values to set, or takes no parameters and initializes all the pointers. I'm guessing most usages will be loading from SQL and parsing JSON from POSTs, so it probably won't be used enough to justify the learning curve, either. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services