Hi,

On Mon, Sep 12, 2016 at 9:46 AM, Thilini Cooray <[email protected]> wrote:

> Hi Kaveesha,
>
> Shouldn't we use apiProvider.checkIfAPIExists(apiId) as the first check
> of POST /apis endpoint?
>
IMO it is good to start the duplicate check from API Identifier as it is
> the unique entry for all the APIs in APIM.
>
Then we can go for apiProvider.isDuplicateContextTemplate(body.getContext()
> ).
>
+1.
>From the functionality it won't be much different but its better to check
name and version first as it more likely the Id of the API..

Apart from that, I think we need to be bit careful when doing this with a
user with Admin permission who is capable of creating APIs on behalf of
other users..
Lets say there is an API, with name api1, version 1.0.0 and context /api1
which is created by an API creator called John.. Now as an Admin user, you
are trying to create an API with name api1, version *2.0.0* and context
/api1 but accidentally using the "provider": "admin" in the payload.. Now
APIM will trying to create the API as a different user than the original
API..
As I checked from the UI, If we create a new API version using a different
creator than that of the original API, the new API version's creator is the
original APIs creator, not the current creator who creates the new version..

Thanks!
Malintha


> WDYT?
>
> Thanks.
>
> On Mon, Sep 12, 2016 at 9:15 AM, Kaveesha Perera <[email protected]>
> wrote:
>
>> Hi,
>>
>> Currently I'm working on a client side tool to perform import and export
>> of APIs in APIM.
>>
>> I encountered conflict issues(error 409) on following instances when
>> using REST APIs to create a new API.
>> 1.when trying to re-import already published API
>> 2.when trying to import a new version of a already published API
>>
>> This is because along API post , initially it check for the context by
>> [1] and throw a conflict exception if context template of the payload and a
>> existing API alike.
>>
>> Several versions of the same API has same *context template* and it
>> should be a exceptional scenario of above mentioned procedure. To handle
>> this hope to do following modifications for apisPost REST API.
>>
>> On API post initially do check [1]. If returns true, get the
>> corresponding API name from the database and check if the API name in the
>> payload and the published API are same. If same, then retrieve all the
>> published versions of that API from the database and check those against
>> version stated in the payload. Method should throws a conflict exception
>> only if the payload holds a already published version of the API or if the
>> API name on the payload and API name in the database corresponds to same
>> context template differs.Else it will allow the normal process of creating
>> a new API.Summary of the proposed changes are shown in Fig.1.0
>>
>>
>> ​*Fig.1.0*
>>
>>
>>
>> [1] apiProvider.isDuplicateContextTemplate(body.getContext())
>>
>> If any feedback please do reply.
>>
>> Regards,
>> Kaveesha
>>
>> --
>> Kaveesha Perera
>> Intern - Software Engineering
>>
>> mobile: 0716130471
>>
>> _______________________________________________
>> Architecture mailing list
>> [email protected]
>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>
>>
>
>
> --
> Best Regards,
>
> *Thilini Cooray*
> Software Engineer
> Mobile : +94 (0) 774 570 112 <%2B94%20%280%29%20774%20570112>
> E-mail : [email protected]
>
> WSO2 Inc. www.wso2.com
> lean.enterprise.middleware
>
> _______________________________________________
> Architecture mailing list
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>


-- 
Malintha Amarasinghe
Software Engineer
*WSO2, Inc. - lean | enterprise | middleware*
http://wso2.com/

Mobile : +94 712383306
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to