)]}'
{"congress/api/datasource_model.py":[{"author":{"_account_id":8215,"name":"Tim Hinrichs","email":"timothy.l.hinrichs@gmail.com","username":"thinrich"},"change_message_id":"bf14f1bcf6724497eaa2d970bd2102bb9373477f","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"        return {\"results\": results}"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    def get_item(self, id_, params, context\u003dNone):"},{"line_number":62,"context_line":"        \"\"\"Get datasource corresponding to id_ in model.\"\"\""},{"line_number":63,"context_line":"        try:"},{"line_number":64,"context_line":"            datasource \u003d self.bus.get_datasource(id_)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a6eadb0_aac9ae5c","line":61,"updated":"2016-12-19 16:05:24.000000000","message":"Might be worth making the parameter something like \"name_or_id\" so that we remember it supports both.  Or maybe include it in the comments.  Same for delete_item.","commit_id":"32ab7c7a231fe900614be2032523afbda015b52a"},{"author":{"_account_id":18591,"name":"Eric Kao","email":"ekcs.openstack@gmail.com","username":"ekcs"},"change_message_id":"7844d6ad96b01a3b05691f9abd307c00b21d701d","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"        return {\"results\": results}"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    def get_item(self, id_, params, context\u003dNone):"},{"line_number":62,"context_line":"        \"\"\"Get datasource corresponding to id_ in model.\"\"\""},{"line_number":63,"context_line":"        try:"},{"line_number":64,"context_line":"            datasource \u003d self.bus.get_datasource(id_)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a6eadb0_ac2337bc","line":61,"in_reply_to":"1a6eadb0_667ea06b","updated":"2016-12-21 05:48:40.000000000","message":"Hmm I didn\u0027t realize policy api already takes either name or id with the same URL. I see now that you\u0027re following through on existing change.\n\nMost of this predates me so I\u0027m not sure, but looking at the API design  and the change history it seems that the original intention was to support specifying policy and datasource by ID only, but at some point we drifted into accepting either name or ID with the same URL.\nhttps://docs.google.com/document/d/14hM7-GSm3CcyohPT2Q7GalyrQRohVcx77hxEx4AO4Bk/edit#\n\nIt doesn\u0027t seem like a great thing. Aside from the standard API design objections, there are some practical problems. For example, what happens if a service interacting with Congress is referring to policy by ID:1234, but the policy is deleted, and another policy by name:\u00271234\u0027 is created. Now the service may unknowingly be referring to a different policy. Could even be a security vulnerability that can be exploited maliciously (though I guess it doesn\u0027t count in our single admin scenario).\n\nA possible alternative is to take the parameter name using the params parameter in get_item/delete_item method. But corresponding changes would need to be made to client. And there is also the issue of how the client should behave. Accepting either name or ID using the same command format in client seems more acceptable than doing the same in API for some reason, but can still have the same undesirable behaviors.\n\nWould love to hear more of what you think \u003d)\n\nWe could discuss it at meeting tmr too if you think that makes sense.","commit_id":"32ab7c7a231fe900614be2032523afbda015b52a"},{"author":{"_account_id":18591,"name":"Eric Kao","email":"ekcs.openstack@gmail.com","username":"ekcs"},"change_message_id":"b41aeffe036dff806ecb09459326b1d8fe0ba154","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"        return {\"results\": results}"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    def get_item(self, id_, params, context\u003dNone):"},{"line_number":62,"context_line":"        \"\"\"Get datasource corresponding to id_ in model.\"\"\""},{"line_number":63,"context_line":"        try:"},{"line_number":64,"context_line":"            datasource \u003d self.bus.get_datasource(id_)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a6eadb0_de1139b1","line":61,"in_reply_to":"1a6eadb0_aac9ae5c","updated":"2016-12-20 00:48:32.000000000","message":"Seems like not the best API design to use the same URL for both ID and name. At least that\u0027s what people seem to think in this thread:\nhttp://stackoverflow.com/questions/20381976/rest-api-design-getting-a-resource-through-rest-with-different-parameters-but\n\nI\u0027m certainly no API expert though.","commit_id":"32ab7c7a231fe900614be2032523afbda015b52a"},{"author":{"_account_id":8215,"name":"Tim Hinrichs","email":"timothy.l.hinrichs@gmail.com","username":"thinrich"},"change_message_id":"9aedf4ff0d4616458cfb8d174cd04416e5f0ef11","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"        return {\"results\": results}"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    def get_item(self, id_, params, context\u003dNone):"},{"line_number":62,"context_line":"        \"\"\"Get datasource corresponding to id_ in model.\"\"\""},{"line_number":63,"context_line":"        try:"},{"line_number":64,"context_line":"            datasource \u003d self.bus.get_datasource(id_)"}],"source_content_type":"text/x-python","patch_set":1,"id":"ba5201f7_bb6d7734","line":61,"in_reply_to":"1a6eadb0_ac2337bc","updated":"2017-01-01 01:21:30.000000000","message":"Historical perspective is below.  Read that first.  \n\nDoing the name-id translation in the client was problematic a while back, I think because when moving to the distributed-arch the message bus uses the name, not the UUID for sending messages.\n\nSupporting just the IDs on the client would require translations for every datasource API call (since the message bus refers to datasources via name), and every policy API call (policy engine uses names to lookup policies, not IDs if I remember right).  The policy engine code that subscribes to datasources uses the name as well.\n\nFor me, policy names have always been semantically meaningful.  So if an external system is asking for policy foo and table bar, then they should get the answer to foo:bar, even if someone has deleted the original policy and created one with the same name.  That\u0027s the same principle that applies WITHIN policy as well.  With 2 policies foo and qux, if qux refers to foo:bar, then it doesn\u0027t care about the UUID of foo--it only cares about the name.  So I\u0027d say that the ability to change out one policy for another without changing clients is a feature, not a problem.  If the client really wants to it can use the UUID instead.","commit_id":"32ab7c7a231fe900614be2032523afbda015b52a"},{"author":{"_account_id":18591,"name":"Eric Kao","email":"ekcs.openstack@gmail.com","username":"ekcs"},"change_message_id":"5aabc77a7850db4f7fec445188eb64a256e76de3","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"        return {\"results\": results}"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    def get_item(self, id_, params, context\u003dNone):"},{"line_number":62,"context_line":"        \"\"\"Get datasource corresponding to id_ in model.\"\"\""},{"line_number":63,"context_line":"        try:"},{"line_number":64,"context_line":"            datasource \u003d self.bus.get_datasource(id_)"}],"source_content_type":"text/x-python","patch_set":1,"id":"da4df55a_255ee645","line":61,"in_reply_to":"1a6eadb0_ac2337bc","updated":"2016-12-21 21:40:07.000000000","message":"To be more concrete, my suggestions are added to the API design doc under policy (analogous for datasource).\nhttps://docs.google.com/document/d/14hM7-GSm3CcyohPT2Q7GalyrQRohVcx77hxEx4AO4Bk/edit#heading\u003dh.13f2ow5ixl9a","commit_id":"32ab7c7a231fe900614be2032523afbda015b52a"},{"author":{"_account_id":11278,"name":"Anusha Ramineni","email":"anusha.ramineni@india.nec.com","username":"anusha08"},"change_message_id":"1ee837e8084620a22845bee385837d226eb8eaed","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"        return {\"results\": results}"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    def get_item(self, id_, params, context\u003dNone):"},{"line_number":62,"context_line":"        \"\"\"Get datasource corresponding to id_ in model.\"\"\""},{"line_number":63,"context_line":"        try:"},{"line_number":64,"context_line":"            datasource \u003d self.bus.get_datasource(id_)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a6eadb0_667ea06b","line":61,"in_reply_to":"1a6eadb0_de1139b1","updated":"2016-12-21 03:44:36.000000000","message":"you meant adding query params? For that don\u0027t we need to change the way we take the input? \nAnd right now all the api\u0027s accept either name or id, you mean behavior needs to be changed for all the api\u0027s?","commit_id":"32ab7c7a231fe900614be2032523afbda015b52a"},{"author":{"_account_id":8215,"name":"Tim Hinrichs","email":"timothy.l.hinrichs@gmail.com","username":"thinrich"},"change_message_id":"9aedf4ff0d4616458cfb8d174cd04416e5f0ef11","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"        return {\"results\": results}"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    def get_item(self, id_, params, context\u003dNone):"},{"line_number":62,"context_line":"        \"\"\"Get datasource corresponding to id_ in model.\"\"\""},{"line_number":63,"context_line":"        try:"},{"line_number":64,"context_line":"            datasource \u003d self.bus.get_datasource(id_)"}],"source_content_type":"text/x-python","patch_set":1,"id":"ba5201f7_7b830fcd","line":61,"in_reply_to":"da4df55a_255ee645","updated":"2017-01-01 01:21:30.000000000","message":"The reason this is an issue is that the NAME must always be a unique identifier for the datasource/policy.  We can\u0027t have 2 datasources both named \u0027nova\u0027 because then the Datalog statement \u0027nova:servers\u0027 would be ambiguous.  Consequently, originally we only had a NAME for datasources and policies (and called it the ID).  \n\nBut people were confused by IDs being human-readable names, so at some point we added a UUID as well, changed the \u0027id\u0027 field to the UUID and made the \u0027name\u0027 field the human-readable name.  Ever since there\u0027s been a back-and-forth between whether the API should support name or ID or both.\n\nThe API is definitely easier for people to use and easier to write docs for when referencing the NAME of the datasource/policy.  On the other hand newcomers don\u0027t understand that the NAME is unique and so expect the UUID instead.  The solution so far is to support both.","commit_id":"32ab7c7a231fe900614be2032523afbda015b52a"}]}
