rawlinp commented on a change in pull request #6014:
URL: https://github.com/apache/trafficcontrol/pull/6014#discussion_r670536479



##########
File path: traffic_ops/traffic_ops_golang/cdn/queue.go
##########
@@ -56,22 +73,76 @@ func Queue(w http.ResponseWriter, r *http.Request) {
                api.HandleErr(w, r, inf.Tx.Tx, http.StatusNotFound, nil, nil)
                return
        }
+
+       // get type ID
+       if typeName != "" {
+               typeID, ok, err = dbhelpers.GetTypeIDByName(typeName, inf.Tx.Tx)
+               if err != nil {
+                       api.HandleErr(w, r, inf.Tx.Tx, 
http.StatusInternalServerError, nil, errors.New("error getting type ID from 
name: "+err.Error()))
+                       return
+               }
+               if !ok {
+                       api.HandleErr(w, r, inf.Tx.Tx, http.StatusNotFound, 
errors.New("no type ID found with that name"), nil)
+                       return
+               }
+               inf.Params["typeID"] = strconv.Itoa(typeID)

Review comment:
       Rather than mutating `inf.Params` by adding and deleting from it, we 
should probably just initialize a new map and use that instead. If the user 
passed in unsupported query params, we wouldn't want to pass them into the 
query builder.

##########
File path: lib/go-tc/servers.go
##########
@@ -1192,3 +1192,13 @@ type ServerQueueUpdate struct {
        ServerID util.JSONIntStr `json:"serverId"`
        Action   string          `json:"action"`
 }
+
+// ServerGenericQueueUpdateResponse encodes the response data for the POST
+// queue_updates endpoint.
+type ServerGenericQueueUpdateResponse struct {
+       Action    string `json:"action"`
+       CDNID     int    `json:"cdnID"`
+       TypeID    int    `json:"typeID,omitempty"`
+       ProfileID int    `json:"profileID,omitempty"`
+       Alerts
+}

Review comment:
       I don't think we need to change the response, but it might be useful to 
have the TypeID and/or ProfileID in the changelog message (if they're used).

##########
File path: traffic_ops/v4-client/server_update_status.go
##########
@@ -49,6 +49,32 @@ func (to *Session) SetServerQueueUpdate(serverID int, 
queueUpdate bool, opts Req
        return resp, reqInf, err
 }
 
+// SetServerQueueUpdatesByType set the "updPending" field of a list of servers 
identified by
+// 'cdnName' and 'typeName' to the value of 'queueUpdate'
+func (to *Session) SetServerQueueUpdatesByType(typeName string, cdnID int, 
queueUpdate bool, opts RequestOptions) (tc.ServerGenericQueueUpdateResponse, 
toclientlib.ReqInf, error) {
+       req := tc.ServerQueueUpdateRequest{Action: 
queueUpdateActions[queueUpdate]}
+       var resp tc.ServerGenericQueueUpdateResponse
+       if opts.QueryParameters == nil {
+               opts.QueryParameters = url.Values{}
+       }
+       path := fmt.Sprintf("/cdns/%d/queue_update?type=%s", cdnID, typeName)
+       reqInf, err := to.post(path, opts, req, &resp)
+       return resp, reqInf, err
+}
+
+// SetServerQueueUpdatesByProfile set the "updPending" field of a list of 
servers identified by
+// 'cdnName' and 'profileName' to the value of 'queueUpdate'
+func (to *Session) SetServerQueueUpdatesByProfile(profileName string, cdnID 
int, queueUpdate bool, opts RequestOptions) 
(tc.ServerGenericQueueUpdateResponse, toclientlib.ReqInf, error) {
+       req := tc.ServerQueueUpdateRequest{Action: 
queueUpdateActions[queueUpdate]}
+       var resp tc.ServerGenericQueueUpdateResponse
+       if opts.QueryParameters == nil {
+               opts.QueryParameters = url.Values{}
+       }
+       path := fmt.Sprintf("/cdns/%d/queue_update?profile=%s", cdnID, 
profileName)
+       reqInf, err := to.post(path, opts, req, &resp)
+       return resp, reqInf, err
+}
+

Review comment:
       So instead of having specific methods for each supported query 
parameter, we've decided to basically just have one _main_ method which users 
can simply pass the query parameters in using `opts RequestOptions`. So we 
should probably just add one `QueueUpdatesForCDN` method (in cdn.go) which we 
can pass query parameters to in order to queue by type or profile.

##########
File path: traffic_portal/app/src/common/modules/form/type/form.type.tpl.html
##########
@@ -29,6 +29,16 @@
             <button class="btn btn-primary" title="View Cache Groups" 
ng-show="type.useInTable == 'cachegroup'" ng-click="viewCacheGroups()">View 
Cache Groups</button>
             <button class="btn btn-primary" title="View Static DNS Entries" 
ng-show="type.useInTable == 'staticdnsentry'" 
ng-click="viewStaticDnsEntries()">View Static DNS Entries</button>
         </div>
+        <div class="btn-group pull-right" role="group" uib-dropdown 
is-open="more.isopen">
+            <button name="moreBtn" type="button" class="btn btn-default 
dropdown-toggle pull-right" uib-dropdown-toggle aria-haspopup="true" 
aria-expanded="false">
+                More&nbsp;
+                <span class="caret"></span>
+            </button>
+            <ul class="dropdown-menu-right dropdown-menu pull-right" 
uib-dropdown-menu>
+                <li role="menuitem"><button class="menu-item-button" 
type="button" ng-show="type.useInTable == 'server'" 
ng-click="queueUpdatesByType()">Queue Server Updates By type</button></li>
+                <li role="menuitem"><button class="menu-item-button" 
type="button" ng-show="type.useInTable == 'server'" 
ng-click="queueUpdatesByType()">Clear Server Updates By Type</button></li>

Review comment:
       I think this is meant to use `clearUpdatesByType()`, right?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to