Hi, As per my understanding here what you are trying to achieve is to avoid api duplication when creating new api's. So I would suggest you to implement a validation method and keep it as an util where this could be used in several operations(eg: copy api/update api etc with slight changes)
Validation method should be consist of following constraints: 1) Check if the api provide/name/version is unique if true, 2) Check it the context is duplicated only within same api-name/provider api's. (you could do this easily with a simple sql dml statement) 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 > > -- *Lahiru Cooray* Software Engineer WSO2, Inc.;http://wso2.com/ lean.enterprise.middleware Mobile: +94 715 654154
_______________________________________________ Architecture mailing list [email protected] https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
