Hi Hisan,

On Wed, Jun 10, 2020 at 9:37 PM Prasanna Dangalla <[email protected]> wrote:

>
> HI @Hisan Hunais <[email protected]> ,
>
> On Wed, Jun 10, 2020 at 9:05 PM Thilini Shanika <[email protected]> wrote:
>
>> Hi Hisan,
>>
>> Please find my inline comments.
>>
>> On Wed, Jun 10, 2020 at 2:22 PM Hisan Hunais <[email protected]> wrote:
>>
>>> Hi all,
>>>
>>> I’m currently implementing an Admin API resource to get all bot
>>> detection data.
>>>
>>> Related Issue: https://github.com/wso2/product-apim/issues/8119
>>>
>>>
>>>    - Please find the OAS definition below.
>>>
>>>   /bot-data:
>>>
>>>   #-----------------------------------------------------
>>>
>>>   # Get all bot detection data
>>>
>>>   #-----------------------------------------------------
>>>
>>>     get:
>>>
>>>       security:
>>>
>>>         - OAuth2Security:
>>>
>>>             - apim:admin
>>>
>>>             - apim:bot_data
>>>
>>>       produces:
>>>
>>>         - application/json
>>>
>>>       summary: |
>>>
>>>         Get all bot detected data
>>>
>>>       description: |
>>>
>>>         Get all bot detected data
>>>
>>>       responses:
>>>
>>>         200:
>>>
>>>           description: |
>>>
>>>             OK.
>>>
>>>             Bot detected data returned.
>>>
>>>           headers:
>>>
>>>             Content-Type:
>>>
>>>               description: |
>>>
>>>                 The content type of the body.
>>>
>>>               type: string
>>>
>>>           schema:
>>>
>>>             $ref: '#/definitions/BotDetectionDataList'
>>>
>>>         500:
>>>
>>>           description: |
>>>
>>>             Internal Server Error.
>>>
>>>             Analytics not enabled.
>>>
>>>           schema:
>>>
>>>             $ref: '#/definitions/Error'
>>>
>>>
>>>    - The relevant schemas are shown below.
>>>
>>>   #-----------------------------------------------------
>>>
>>>   # The Bot Detection Data List resource
>>>
>>>   #-----------------------------------------------------
>>>
>>>   BotDetectionDataList:
>>>
>>>     title: Bot Detection Data List
>>>
>>>     properties:
>>>
>>>       count:
>>>
>>>         type: integer
>>>
>>>         description: |
>>>
>>>           Number of Bot Detection Data returned.
>>>
>>>         example: 1
>>>
>>>       list:
>>>
>>>         type: array
>>>
>>>         items:
>>>
>>>           $ref: '#/definitions/BotDetectionData'
>>>
>>>   #-----------------------------------------------------
>>>
>>>   # The Bot Detection Data resource
>>>
>>>   #-----------------------------------------------------
>>>
>>>   BotDetectionData:
>>>
>>>     title: Bot Detection Data
>>>
>>>     properties:
>>>
>>>       currentTime:
>>>
>>>         type: integer
>>>
>>>         description: The time of detection
>>>
>>>         example: 1591734138413
>>>
>>>       messageID:
>>>
>>>         type: string
>>>
>>>         description: The message ID
>>>
>>>         example: urn:uuid:1ed6d2de-29df-4fed-a96a-46d2329dce65
>>>
>>>       apiMethod:
>>>
>>>         type: string
>>>
>>>         description: The api method
>>>
>>>         example: GET
>>>
>>>       headerSet:
>>>
>>>         type: string
>>>
>>>         description: The header set
>>>
>>>         example: [Accept=*/*, Host=localhost:8243,
>>> User-Agent=curl/7.58.0]
>>>
>>>       messageBody:
>>>
>>>         type: string
>>>
>>>         description: The content of the message body
>>>
>>>         example: <soapenv:Body xmlns:soapenv=\"
>>> http://www.w3.org/2003/05/soap-envelope\"/>
>>>
>>>       clientIp:
>>>
>>>         type: string
>>>
>>>         description: The IP of the client
>>>
>>>         example: 127.0.0.1
>>>
>>>
>>>    - The Admin API has the following resources which manages emails
>>>    related to bot data.
>>>
>>>
>>> *Purpose*
>>>
>>> *Resource*
>>>
>>> *Operation*
>>>
>>> *Parameters*
>>>
>>> *Parameter type*
>>>
>>> Get configured email list
>>>
>>> /botData/getEmailList
>>>
>>> GET
>>>
>>> tenantDomain
>>>
>>> query
>>>
>>> Add email
>>>
>>> /botData/addEmail
>>>
>>> POST
>>>
>>> Email schema containing email address
>>>
>>> body
>>>
>>> Delete email
>>>
>>> /botData/deleteEmail
>>>
>>> DELETE
>>>
>>> Uuid
>>>
>>> query
>>>
>>> AFAIK, the tenant domain(in /botData/getEmailList resource) should be
>> obtained from the logged-in user and we do don't have to explicitly provide
>> a tenant domain. @Bhathiya Jayasekara <[email protected]> Is there a use
>> case of retrieving the email list of other tenants as well? Unless we can
>> remove the tenant domain query parameter.
>>
>
> Yes we can remove the tenant Domain.
>
>>
>>>    - In my opinion, these resources should be revamped as follows.
>>>
>>> Description
>>>
>>> Resource
>>>
>>> Revamped Resource
>>>
>>> Operation
>>>
>>> Get configured email list
>>>
>>> /botData/getEmailList
>>>
>>> /bot-data/emails
>>>
>>> GET
>>>
>>> Add email
>>>
>>> /botData/addEmail
>>>
>>> /bot-data/emails
>>>
>>> POST
>>>
>>> Delete email
>>>
>>> /botData/deleteEmail
>>>
>>> /bot-data/emails/{uuid}
>>>
>>> DELETE
>>>
>>> I think we need to use these as follows.
>
> When you are getting emails it will be returning a collection.
> Hence /bot-data/emails resource is fine.
> But when you are adding you will be adding a single email at a time. Hence
> it should be /bot-data/*email* (in singular). Same applies with delete as
> well like /bot-data/*email*/{uuid}
>
What you have defined is correct. Use the plural nouns that you have
already defined. What I said previously (using singular) will not adhere to
the rest API conventions. Sorry about the confusion.

>
> Further, the above three APIs are to subscribe/unsubscribe user for email
>> notifications and to retrieve all the email subscriptions. Hence, isn't it
>> better to imply this via the resource naming as well?
>> ie:
>> POST GET /bot-data/alert-subscriptions
>> DELETE /bot-data/alert-subscriptions/{uuid}
>>
> For this DELETE resource  too it would be better of we can use in singular
> as /bot-data/alert-subscription/{uuid}
>
Same applies to here.

Thanks
Prasanna

>
> Thanks
> Prasanna
>
>>
>>
>>
>>> Your feedback regarding this is highly appreciated.
>>>
>>> Thank you!
>>> --
>>>
>>> *Hisan Hunais* | Software Engineer | WSO2 Inc.
>>> (m) +94768526186 | (e) [email protected]
>>>
>>> [image: https://wso2.com/signature] <https://wso2.com/signature>
>>>
>>
>>
>> --
>> Thilini Shanika
>> Technical Lead
>> WSO2, Inc.; http://wso2.com
>> 20, Palmgrove Avenue, Colombo 3
>> Mobile: +94710892258
>>
>>
>>
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to