Manage Asset on Anypoint Exchange

Author: Jeetan Madan

Preface

In an API Design Cycle on Anypoint Platform, API RAML specs have been designed using the API Designer, and published to organization exchange.

However when the API Artifact is deleted from the Design Center, an asset still exists on the exchange, and has to be removed with Mulesoft provided exchange API [‘https://anypoint.mulesoft.com/exchange/api/v1/assets’]

 

Get the Access Token for your Organization

 

curl -d "username=<<username>>&password=<<password>>" https://anypoint.mulesoft.com/accounts/login

 

Response:

{

  "access_token": "returned_token",

  "token_type": "bearer",

  "redirectUrl": "/home/"

}

 

Retrieve the Organization Id using the Access Token

 

curl -H "Authorization: Bearer <<accesstoken>>" https://anypoint.mulesoft.com/accounts/api/me

 

Response

 

{ "user": { "id": "4f18ae80-edee-4b05-8487-1154c5bf7b5b", "createdAt": "2020-02-12T05:02:27.661Z", "updatedAt": "2020-02-26T06:13:06.915Z", "organizationId": "<<OrgID>>", "firstName": "<<firstname>>", "lastName": "<<lastname>>", "email": "<<email>>, "phoneNumber": "<<phonenumber>>", "idprovider_id": "mulesoft", "username": "<<username>>", "enabled": true, "deleted": false, "lastLogin": "2020-02-26T06:13:00.000Z", "type": "host", "organizationPreferences": {}, "organization": { "name": "Apisero", "id": "<<orgid>>", "createdAt": "2020-02-12T05:02:27.661Z", "updatedAt": "2020-02-12T05:02:27.661Z", "ownerId": "4f18ae80-edee-4b05-8487-1154c5bf7b5b", "clientId": "89b6972ef647420681fc27a033c6f5fc", "idprovider_id": "mulesoft", "isFederated": false, "parentOrganizationIds": [], "subOrganizationIds": [], "tenantOrganizationIds": [], "domain": "apisero-346", "isMaster": true, "subscription": { "category": "Developer", "type": "Trial", "expiration": "2020-03-13T05:02:28.372Z" }, "properties": {}, "entitlements": { "createEnvironments": true, "globalDeployment": false, "createSubOrgs": true, "hybrid": { "enabled": true }, "hybridInsight": true, "hybridAutoDiscoverProperties": true, "vCoresProduction": { "assigned": 0, "reassigned": 0 }, "vCoresSandbox": { "assigned": 1, "reassigned": 0 }, "vCoresDesign": { "assigned": 1, "reassigned": 0 }, "staticIps": { "assigned": 0, "reassigned": 0 }, "vpcs": { "assigned": 0, "reassigned": 0 }, "vpns": { "assigned": 0, "reassigned": 0 }, "workerLoggingOverride": { "enabled": false }, "mqMessages": { "base": 0, "addOn": 0 }, "mqRequests": { "base": 0, "addOn": 0 }, "objectStoreRequestUnits": { "base": 0, "addOn": 0 }, "objectStoreKeys": { "base": 0, "addOn": 0 }, "mqAdvancedFeatures": { "enabled": false }, "gateways": { "assigned": 0 }, "designCenter": { "mozart": true, "api": true, "apiVisual": false, "apiExample": false }, "partnersProduction": { "assigned": 0 }, "partnersSandbox": { "assigned": 0 }, "tradingPartnersProduction": { "assigned": 0 }, "tradingPartnersSandbox": { "assigned": 0 }, "loadBalancer": { "assigned": 0, "reassigned": 0 }, "externalIdentity": true, "autoscaling": false, "armAlerts": true, "apis": { "enabled": true }, "apiMonitoring": { "schedules": 0 }, "apiCommunityManager": { "enabled": false }, "monitoringCenter": { "productSKU": 0 }, "crowd": { "hideApiManagerDesigner": true, "hideFormerApiPlatform": true, "environments": true }, "cam": { "enabled": false }, "exchange2": { "enabled": false }, "crowdSelfServiceMigration": { "enabled": false }, "kpiDashboard": { "enabled": false }, "pcf": false, "appViz": false, "runtimeFabric": false, "anypointSecurityTokenization": { "enabled": false }, "anypointSecurityEdgePolicies": { "enabled": false }, "runtimeFabricCloud": { "enabled": false }, "serviceMesh": { "enabled": false }, "messaging": { "assigned": 0 }, "workerClouds": { "assigned": 0, "reassigned": 0 } } }, "properties": {}, "memberOfOrganizations": [ { "parentName": null, "parentId": null, "domain": "apisero-346", "name": "Apisero", "id": "<<orgid>>", "createdAt": "2020-02-12T05:02:27.661Z", "updatedAt": "2020-02-12T05:02:27.661Z", "ownerId": "4f18ae80-edee-4b05-8487-1154c5bf7b5b", "clientId": "89b6972ef647420681fc27a033c6f5fc", "idprovider_id": "mulesoft", "isFederated": false, "parentOrganizationIds": [], "subOrganizationIds": [], "tenantOrganizationIds": [], "isMaster": true, "subscription": { "category": "Developer", "type": "Trial", "expiration": "2020-03-13T05:02:28.372Z" } } ], "contributorOfOrganizations": [ { "parentName": null, "parentId": null, "domain": "apisero-346", "name": "Apisero", "id": "206007b8-5f33-417d-91b9-5002543d2c81", "createdAt": "2020-02-12T05:02:27.661Z", "updatedAt": "2020-02-12T05:02:27.661Z", "ownerId": "4f18ae80-edee-4b05-8487-1154c5bf7b5b", "clientId": "89b6972ef647420681fc27a033c6f5fc", "idprovider_id": "mulesoft", "isFederated": false, "parentOrganizationIds": [], "subOrganizationIds": [], "tenantOrganizationIds": [], "isMaster": true, "subscription": { "category": "Developer", "type": "Trial", "expiration": "2020-03-13T05:02:28.372Z" } } ] } }

 

Get the Lists of Assets from Exchange for the organization associated with the username.

 

curl -v -X GET -H "Authorization: bearer <<accesstoken>>" -H "Content-Type: application/json" "https://anypoint.mulesoft.com/exchange/api/v1/assets?organizationId=<<orgID>>"

 

[{"groupId":"206007b8-5f33-417d-91b9-5002543d2c81","assetId":"206007b8-5f33-417d-91b9-5002543d2c81","version":"1.0.0","description":"","versionGroup":"1.0.0","productAPIVersion":"","isPublic":false,"name":"testAPI","type":"custom","isSnapshot":false,"status":"published","assetLink":"","createdAt":"2020-02-26T05:30:05.712Z","runtimeVersion":"","attributes":[],"labels":[],"categories":[],"customFields":[],"tags":[],"files":[],"rating":0,"numberOfRates":0,"createdBy":{"id":"4f18ae80-edee-4b05-8487-1154c5bf7b5b","userName":"jmadaanapisero","firstName":"Jeetan","lastName":"Madaan"},"organization":{"id":"206007b8-5f33-417d-91b9-5002543d2c81","name":"Apisero","parentOrganizationIds":[],"subOrganizationIds":[],"tenantOrganizationIds":[],"isMaster":true,"domain":"apisero-346"},"id":"206007b8-5f33-417d-91b9-5002543d2c81/206007b8-5f33-417d-91b9-5002543d2c81/1.0.0","icon":null,"modifiedAt":"2020-02-26T05:30:05.712Z"},{"groupId":"206007b8-5f33-417d-91b9-5002543d2c81","assetId":"diywt3-1","version":"1.0.0","description":"","versionGroup":"v1","productAPIVersion":"v1","isPublic":false,"name":"accounts-api","type":"rest-api","isSnapshot":false,"status":"published","assetLink":"","createdAt":"2020-02-25T09:30:51.869Z","runtimeVersion":"","attributes":[{"value":"raml","tagType":"attribute","key":null},{"value":"rest","tagType":"attribute","key":null},{"value":"api","tagType":"attribute","key":null},{"value":"v1","tagType":"attribute","key":"product-api-version"},{"value":"836c01e9-4c7d-4848-a091-f47e15705465","tagType":"attribute","key":"project-id"},{"value":"master","tagType":"attribute","key":"branch-id"},{"value":"dfccab0688ef8b73e744076f9c18fde54c2ff72c","tagType":"attribute","key":"commit-id"},{"value":"raml","tagType":"attribute","key":"original-format"}],"labels":[],"categories":[],"customFields":[],"tags":[{"value":"raml","key":null},{"value":"rest","key":null},{"value":"api","key":null},{"value":"v1","key":"product-api-version"},{"value":"836c01e9-4c7d-4848-a091-f47e15705465","key":"project-id"},{"value":"master","key":"branch-id"},{"value":"dfccab0688ef8b73e744076f9c18fde54c2ff72c","key":"commit-id"},{"value":"raml","key":"original-format"}],"files":[{"classifier":"raml","packaging":"zip","externalLink":"https://exchange2-asset-manager-kprod.s3.amazonaws.com/206007b8-5f33-417d-91b9-5002543d2c81/bb970eee63a6838943e8b782b2c74e85d0729540bc6ff001519e5b8e74944735.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJTBQMSKYL2HXJA4A%2F20200226%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200226T062406Z&X-Amz-Expires=86400&X-Amz-Signature=00b380bba2225dd68150e503c43696b5c587c5c8049e3328dd389f4db551881f&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Ddiywt3-1-1.0.0-raml.zip","md5":"ab8bfb12115099ad56b00c7dffdc76c3","sha1":"d6d36e515aec8a111fad3308fa4675ef30807fd7","createdDate":"2020-02-25T09:30:50.937Z","mainFile":"accounts-api.raml","isGenerated":false},{"classifier":"fat-raml","packaging":"zip","externalLink":"https://exchange2-asset-manager-kprod.s3.amazonaws.com/206007b8-5f33-417d-91b9-5002543d2c81/d8ce714f80924bb4a14afffbc6668916208a5ff9187bc226fb4216781abd0fe5.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJTBQMSKYL2HXJA4A%2F20200226%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200226T062406Z&X-Amz-Expires=86400&X-Amz-Signature=215fd78931213695349252be65125b9a5e758e5579506276717b5a67dd98ec4e&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Ddiywt3-1-1.0.0-raml.zip","md5":"6711bd44de8cb279cf9b8bb1b4c8e79a","sha1":"338ade8991382754bcd5b44a67b56d569d5ed37b","createdDate":"2020-02-25T09:30:51.463Z","mainFile":"accounts-api.raml","isGenerated":false},{"classifier":"oas","packaging":"zip","externalLink":"https://exchange2-asset-manager-kprod.s3.amazonaws.com/206007b8-5f33-417d-91b9-5002543d2c81/7ec5d5e6df0e5985bb86846a7e084f9b96b8deb6405ce7eba119e9f7d6dd9df0.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJTBQMSKYL2HXJA4A%2F20200226%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200226T062406Z&X-Amz-Expires=86400&X-Amz-Signature=d31f7093455480bd031d2cb6c00f67069edbaa62517838acdebcf17da6d39de5&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Ddiywt3-1-1.0.0-oas.zip","md5":"5223bec112f6eeed19970350194c198f","sha1":"74b060390534ec86a4c36066fc0e07c3f171b456","createdDate":"2020-02-25T09:30:51.761Z","mainFile":"api.json","isGenerated":true}],"rating":0,"numberOfRates":0,"createdBy":{"id":"4f18ae80-edee-4b05-8487-1154c5bf7b5b","userName":"jmadaanapisero","firstName":"Jeetan","lastName":"Madaan"},"organization":{"id":"206007b8-5f33-417d-91b9-5002543d2c81","name":"Apisero","parentOrganizationIds":[],"subOrganizationIds":[],"tenantOrganizationIds":[],"isMaster":true,"domain":"apisero-346"},"id":"206007b8-5f33-417d-91b9-5002543d2c81/diywt3-1/1.0.0","icon":null,"modifiedAt":"2020-02-25T09:30:51.869Z"},{"groupId":"206007b8-5f33-417d-91b9-5002543d2c81","assetId":"american-flights-api","version":"1.0.2","description":"The American Flights API is a system API for operations on the american table in the training database.\nSupported operations\nGet all flights\nGet a flight with a specific ID\nAdd a flight","versionGroup":"v1","productAPIVersion":"v1","isPublic":true,"name":"American Flights API","type":"rest-api","isSnapshot":false,"status":"published","assetLink":"","createdAt":"2020-02-19T04:38:32.134Z","runtimeVersion":"","attributes":[{"value":"raml","tagType":"attribute","key":null},{"value":"rest","tagType":"attribute","key":null},{"value":"api","tagType":"attribute","key":null},{"value":"v1","tagType":"attribute","key":"product-api-version"},{"value":"9f6ec405-6558-48c1-963e-b889c170551b","tagType":"attribute","key":"project-id"},{"value":"master","tagType":"attribute","key":"branch-id"},{"value":"4310e48b732d80e666f7bb27a29e2597b8c7f6a2","tagType":"attribute","key":"commit-id"},{"value":"raml","tagType":"attribute","key":"original-format"}],"labels":[],"categories":[],"customFields":[],"tags":[{"value":"raml","key":null},{"value":"rest","key":null},{"value":"api","key":null},{"value":"v1","key":"product-api-version"},{"value":"9f6ec405-6558-48c1-963e-b889c170551b","key":"project-id"},{"value":"master","key":"branch-id"},{"value":"4310e48b732d80e666f7bb27a29e2597b8c7f6a2","key":"commit-id"},{"value":"raml","key":"original-format"}],"files":[{"classifier":"raml","packaging":"zip","externalLink":"https://exchange2-asset-manager-kprod.s3.amazonaws.com/206007b8-5f33-417d-91b9-5002543d2c81/1ccd77006e2fc06586630628940ec062e4b4fb8797d588ba2f83f0885afcc224.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJTBQMSKYL2HXJA4A%2F20200226%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200226T062406Z&X-Amz-Expires=86400&X-Amz-Signature=fc362777e3d040ac1e10c1d19bc7bf73e1bba332c0cf9432c987a9b0020d1b31&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Damerican-flights-api-1.0.2-raml.zip","md5":"dfabc99dbde8a943717d64e217c7cab4","sha1":"5261097ca7a5373a9718143bfe44be2abeab30ce","createdDate":"2020-02-19T04:38:31.419Z","mainFile":"american-flights-api.raml","isGenerated":false},{"classifier":"fat-raml","packaging":"zip","externalLink":"https://exchange2-asset-manager-kprod.s3.amazonaws.com/206007b8-5f33-417d-91b9-5002543d2c81/bacd5f1101f2567f6945a9af454910ae2b13d43003c9898dc072d9d747170b59.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJTBQMSKYL2HXJA4A%2F20200226%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200226T062406Z&X-Amz-Expires=86400&X-Amz-Signature=febdb3911f48f51673291863fb2562cdbe17b8236d5c2336e599871426d611d3&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Damerican-flights-api-1.0.2-raml.zip","md5":"724f73192431027c7355f49bf07e4775","sha1":"31187c4dde6d3bba78b343ad81db3ae03cfb0565","createdDate":"2020-02-19T04:38:31.69Z","mainFile":"american-flights-api.raml","isGenerated":false},{"classifier":"oas","packaging":"zip","externalLink":"https://exchange2-asset-manager-kprod.s3.amazonaws.com/206007b8-5f33-417d-91b9-5002543d2c81/75337265fd154db8acbf062d8a81b79c905fa7e1fd35272c9909f630a860ede0.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJTBQMSKYL2HXJA4A%2F20200226%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200226T062406Z&X-Amz-Expires=86400&X-Amz-Signature=f1ade99d6f00de4805e5bcfe17f22aa01bcb9774c34abc645118a0ec0c422fff&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Damerican-flights-api-1.0.2-oas.zip","md5":"7b7114db7aa0260db32df3a81739a885","sha1":"9056ec20ef87b728e168733a880fcbac0098624f","createdDate":"2020-02-19T04:38:31.949Z","mainFile":"api.json","isGenerated":true}],"rating":0,"numberOfRates":0,"createdBy":{"id":"4f18ae80-edee-4b05-8487-1154c5bf7b5b","userName":"jmadaanapisero","firstName":"Jeetan","lastName":"Madaan"},"organization":{"id":"206007b8-5f33-417d-91b9-5002543d2c81","name":"Apisero","parentOrganizationIds":[],"subOrganizationIds":[],"tenantOrganizationIds":[],"isMaster":true,"domain":"apisero-346"},"id":"206007b8-5f33-417d-91b9-5002543d2c81/american-flights-api/1.0.2","icon":null,"modifiedAt":"2020-02-19T04:38:32.134Z"}]

 

Remove an Asset from the Exchange

 

curl -v -X DELETE -H "Authorization: bearer <AUTH_TOKEN>" -H "Content-Type: application/json" -H "X-Delete-Type: hard-delete" "https://anypoint.mulesoft.com/exchange/api/v1/organizations/<ORGANIZATION_ID>/assets/<ASSET_ID>/<ARTIFACT_NAME>/<ARTIFACT_VERSION>""

 

Below screenshot lists the testAPI asset which we want to remove from the exchange.

 

We still have to use the OrgID for AssetID in the curl command to delete the asset from the exchange.

 

curl -v -X DELETE -H "Authorization: bearer <<accesstoken>>" -H "Content-Type: application/json" -H "X-Delete-Type: hard-delete" "https://anypoint.mulesoft.com/exchange/api/v1/organizations/206007b8-5f33-417d-91b9-5002543d2c81/assets/206007b8-5f33-417d-91b9-5002543d2c81/exchange-asset-remove-poc/1.0.0"

 

Remove an Asset from the Design Center / Or Publish it back to Exchange.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.