<div dir="ltr">On Thu, Dec 19, 2013 at 11:29 AM, Daniel Jenkins <span dir="ltr"><<a href="mailto:dan.jenkins88@gmail.com" target="_blank">dan.jenkins88@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I've added comments below, please forgive me if I've missed something in previous discussions about the ARI, not had a chance to keep up with it all for a little while<br>
<div class="gmail_extra">
<br><div class="gmail_quote"><div class="im">On Wed, Dec 18, 2013 at 10:25 PM, Jonathan Rose <span dir="ltr"><<a href="mailto:jrose@digium.com" target="_blank">jrose@digium.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr"><div>ARI Mailboxes resource</div><div><br></div><div>I'm currently starting on some basic implementation of the mailboxes</div><div>resource described at</div><div><a href="https://wiki.asterisk.org/wiki/display/AST/Blinky+Lights+API" target="_blank">https://wiki.asterisk.org/wiki/display/AST/Blinky+Lights+API</a></div>


<div><br></div><div>Data Model:</div><div><br></div><div>name: string        name of the mailbox</div><div>new_messages: int   count of messages that have not been marked as old</div><div>old_messages: int   count of messages that have been marked as old</div>


<div><br></div><div>As such, I'm currently writing stub functions for the following commands</div><div><br></div><div>Method   URL                        Return type  </div><div>GET      /mailboxes                 list(mailbox)</div>


<div>POST     /mailboxes                 mailbox</div><div>GET      /mailboxes/{mailboxName}   void</div><div>PUT      /mailboxes/{mailboxName}   void</div><div>DELETE   /mailboxes/{mailboxName}   void</div><div><br></div>


<div>GET /mailboxes</div><div>List all mailboxes in Asterisk</div></div></blockquote><div><br></div></div><div>Is this purely returning a list of mailbox ids/names or mailbox objects with a subset of data in compared to  /mailboxes/{mailboxName}?  I can see why I'd want to list all mailboxes and how many messages are in each one.</div>
</div></div></div></div></blockquote><div><br></div><div>Well, it will be returning the list of mailbox objects, and since a mailbox object contains the state of the mailbox, the count of old and new messages should be contained within that. Functionally, it will be like with the existing deviceState objects. You can get them individually with mailboxes/{mailboxName} if you know the name of the mailbox... if you get them with GET /mailboxes instead of /mailboxes/mailboxName, you'll get the full list instead... which will output them in the usual descriptive format... which I'm guessing would looks something like:</div>
<div><span style="color:rgb(0,0,0);font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)"><br>
</span></div><div><span style="color:rgb(0,0,0);font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">[
  {
</span><span style="color:rgb(0,0,0);font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">    "</span><span class="" style="margin:0px;padding:0px;border:0px;font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;vertical-align:baseline;color:rgb(0,0,0);white-space:pre;background-color:rgb(252,246,219)">name</span><span style="color:rgb(0,0,0);font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">": </span><span class="" style="margin:0px;padding:0px;border:0px;font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;vertical-align:baseline;color:rgb(0,0,0);white-space:pre;background-color:rgb(252,246,219)"><span class="" style="margin:0px;padding:0px;border:0px;font-family:inherit;font-size:inherit;font-style:inherit;font-variant:inherit;line-height:inherit;vertical-align:baseline;color:rgb(136,0,0)">"alice",</span></span></div>
<div><span class="" style="margin:0px;padding:0px;border:0px;font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;vertical-align:baseline;white-space:pre;background-color:rgb(252,246,219)">    "new_messages": 5,</span></div>
<div><span class="" style="margin:0px;padding:0px;border:0px;font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;vertical-align:baseline;white-space:pre;background-color:rgb(252,246,219)">    "old_messages": 3
  },</span></div><div><span style="font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">  {</span></div>
<div><span style="font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">    "name": "bob",</span></div>
<div><span style="font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">    "new_messages": 4,</span></div>
<div><span style="font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">    "old_messages": 0</span></div>
<div><span style="font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">  }
]</span><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra">
<div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>POST /mailboxes</div><div>

Create an empty mailbox</div><div>query parameters:</div><div>  mailboxName - name for the mailbox</div></div></blockquote><div><br></div></div><div>Would this not possibly return an error if the name already existed? Is the name mandatory or optional? If optional, would it just create a randomly named mailbox? I don't see why you'd want to do this but... </div>
</div></div></div></div></blockquote><div><br></div><div>Absolutely it could return an error. Conflicts with existing named mailboxes are a possible reason. Also internal problems such as memory allocation failures. But since I wrote this, I've noticed that deviceStates currently handles this in a slightly different way.  Instead of having an explicit POST function, the PUT doubles as the method for creating objects if a PUT is used with a name that doesn't exist, so this function is probably not actually going to exist in the final implementation.  That also means that name conflicts wouldn't be an issue for creation since it'll just edit the mailbox it's pointed at.  On the other hand, pointing to a mailbox that is owned by something other than Stasis will result in a failure as well since Stasis applications shouldn't be allowed to manipulate non Stasis mailboxes. I'm currently following the same model as deviceStates, so name will be mandatory for the PUT function unless someone feels strongly that we should be able to assign a name if none is given.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra">
<div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>

<br></div><div>GET /mailboxes/{mailboxName}</div><div>Get the current state of a mailbox</div><div>path parameters:</div><div>  mailboxName - name of the mailbox</div><div>error responses:</div><div>  404 - Mailbox not found </div>

</div></blockquote><div><br></div></div><div>What kind of response would a mailbox look like? An Object with what parameters in?</div></div></div></div></div></blockquote><div><br></div><div>As above, it would be a JSON blob which was described by the object model that I put near the beginning of the email.  More specifically, it would look like this:</div>
<div><br></div><div>{</div><div><span style="font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">  "name": "bob",</span></div>
<div><span style="font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">  "new_messages": 4,</span></div>
<div><span style="font-family:'Anonymous Pro',Menlo,Consolas,'Bitstream Vera Sans Mono','Courier New',monospace;font-size:13px;line-height:20.734375px;white-space:pre;background-color:rgb(252,246,219)">  "old_messages": 0</span></div>
<div><font face="Anonymous Pro, Menlo, Consolas, Bitstream Vera Sans Mono, Courier New, monospace"><span style="line-height:20.734375px;white-space:pre">}</span></font></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr"><div> </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">


<div><br></div><div>PUT /mailboxes/{mailboxName}</div><div>Change the state of a mailbox</div><div>path parameters:</div><div>  mailboxName - name of the mailbox to be modified</div><div>query parameters:</div><div>  new_messages - count of new messages in the mailbox</div>


<div>  old_messages - count of old messages in the mailbox</div><div>error responses:</div><div>  404 - Mailbox not found</div><div>  409 - Mailbox not in a stasis application</div></div></blockquote><div><br></div></div>
<div>
Something about this seems wrong to me but I can't put my finger on it, a mailbox only has messages and so messages shouldn't need to be in the name of params as it's self documenting as such. I can't access the wiki to get access to other route's documentation right now so I'm not sure if this is in keeping with the rest of the ARI or not.</div>

<div><br></div><div>Are both of these parameters required? If there are X number of messages in the mailbox and only 2 are new then old messages is X-2; or am I missing something? If they are both required then will there be validation to say that old + new must equal the total number of messages in the mailbox?</div>
</div></div></div></div></blockquote><div><br></div><div>Ok, so again, basing this off of the DeviceState model that already exists, PUT will be able to both create and modify mailboxes.  The name of the mailbox here is a path parameter, so listing it in the parameters is just for the sake of documenting that particular value. It's not a separate variable that needs to be specified by the message or anything. I'm unsure if the message count variables should be required.  After all, if the mailbox already exists and you only specify one, we could simply assume that the other value should stay the same.  Likewise, if the mailbox is being created, unspecified values could simply be assumed as 0. I don't believe there will necessarily be any relationship between new and old messages and the mailbox object doesn't track a total, it simply tracks old and new separately and those can be taken and added together to deduce the total.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote">
<div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>DELETE /mailboxes/{mailboxName}</div>


<div>Delete an existing mailbox</div><div>path parameters:</div><div>  mailboxName -name of the mailbox to be deleted</div><div>error responses:</div><div>  404 - Mailbox not found</div><div>  409 - Mailbox not in a stasis application</div>

</div></blockquote><div><br></div></div><div>Are there any other reasons why a mailbox couldn't be deleted? What if it was being written to at that moment?</div></div></div></div></div></blockquote><div><br></div><div>
I imagine if it was being written to at the time of the DELETE request, the response would simply be delayed until the mailbox could successfully be acquired and deleted. Presently, these are the only documented error responses for the DELETE method on Device States as well, so I don't anticipate any additional possibilities currently.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote">
<div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div></div><div>Events:</div><div>MailboxStateChanged</div><div>  The contents of a mailbox have changed</div><div>  mailbox - name of the mailbox that was changed</div></div></blockquote><div><br></div></div>
<div>
Would it only give you the fact it changed? Or would it detail the change itself?</div></div></div></div></div></blockquote><div><br></div><div>Presumably based on that documentation the change would not be detailed beyond the simple fact that the specific mailbox changed and at that point it would be up to the consumer to retrieve the mailbox and examine the new values and determine what to do with them.</div>
<div><br></div></div>-- <br><div dir="ltr">Jonathan R. Rose<br>Digium, Inc. | Software Engineer<br>445 Jan Davis Drive NW - Huntsville, AL 35806 - US<br>direct +1 256 428 6139 <br><br>Check us out at: <a href="http://digium.com" target="_blank">http://digium.com</a> & <a href="http://asterisk.org" target="_blank">http://asterisk.org</a><br>
<br></div>
</div></div>