mitchell852 commented on issue #2592: Dangling Federations and Federation Structure URL: https://github.com/apache/trafficcontrol/issues/2592#issuecomment-408431864 I don't know the best answer here. IMO, this is the result of poor API design when federations were originally implemented. For example, what would you expect GET /api/federations to return? I would expect it to return the contents of the federation table but that is not the case. From what I can tell it returns "federation resolvers for federations assigned to the current user" or something. https://github.com/apache/trafficcontrol/blob/master/traffic_ops/app/lib/API/Federation.pm#L178 When I added the federation functionality to TP, i needed the following functionality in the API: 1. get federations 2. create a federation 3. update/delete a federation 4. assign a federation to delivery service(s) 5. assign a federation to user(s) 6. create a federation resolver 7. assign federation resolvers to a federation so i wanted to create the following api endpoints: 1. GET /api/1.3/federations 2. POST /api/1.3/federations 3. PUT/DELETE /api/1.3/federations/:id 4. POST /api/1.3/federations/11/deliveryservices 5. POST /api/1.3/federations/11/users 6. POST /api/1.3/federation_resolvers 7. POST /api/1.3/federations/11/federation_resolvers but unfortunately 1 and 2 were already taken so i had to get creative so i settled on: 1. GET /api/1.3/cdns/:name/federations 2. POST /api/1.3/cdns/:name/federations and for consistency i decided to make 3. PUT/DELETE /api/1.3/cdns/:name/federations/:fedId because in my brain at that time i figured all federations were linked to a cdn via the ds linked to the federation but in hindsight i see the flaw in that thinking because as you've pointed out if you fail to link a federation to a ds, then you have no way of retrieving the "dangling" federation because neither of these will work: - GET /api/1.3/federations <-- doesn't even return federations - GET /api/1.3/cdns/:name/federations So what to do? I like your idea of adding a new, optional field to the request json provided to POST /api/1.3/cdns/:name/federations. The field is something like: dsIds: [ 1, 2, 3 ] and make sure it's added to the documentation. unfortunately we can't make that field required without revving the api version and i'm not exactly sure what kind of effort that would entail
---------------------------------------------------------------- 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