How do you get a list of all developers and apps for an API in Apigee? - apigee

Say you have exposed an API Product in Apigee. You would like to get a list of all the developers and their apps that have registered for the API Product.
There is a call to return those, documented here:
http://apigee.com/docs/api/get-list-keys-apps-developers-or-companies-api-product
But the IDs it returns appear to be useless. If you try developers, for instance:
https://api.enterprise.apigee.com/v1/organizations/YOUR-ORG/apiproducts/YOUR-PRODUCT?query=list&entity=developers
you get back a list of IDs. But to find which developer a given ID relates to is impossible, as the call to get a developer:
http://apigee.com/docs/api/get-developer
only accepts an email address.
How can I get a list of all the developers and their apps registered for a given API product?

The Apps a developer has is nested in each developer:
https://api.enterprise.apigee.com/v1/o/{your org}/developers
will return a list of developers like this:
["email#domain.com", "email2#domain2.com"]
Then you have to loop through each developer to get a list of their apps:
https://api.enterprise.apigee.com/v1/o/{your org}/developers/tesla#weathersample.com
Which gives you a bunch of meta data including apps:
{
"apps" : [ "weather" ],
"companies" : [ ],
"email" : "tesla#weathersample.com",
"developerId" : "Hk5mmLw9kKIM95qF",
"firstName" : "Nikolai",
"lastName" : "Tesla",
"userName" : "Nikolai",
"organizationName" : "jokeindex",
"status" : "active",
"attributes" : [ ],
"createdAt" : 1357858239543,
"createdBy" : "noreply_admin#apigee.com",
"lastModifiedAt" : 1357858239543,
"lastModifiedBy" : "noreply_admin#apigee.com"
}
Finally, if you look at each app you can see the products associated with that developer app:
https://api.enterprise.apigee.com/v1/o/{your org}/developers/tesla#weathersample.com/apps/weather
Gets you this detail:
{
"accessType" : "read",
"appFamily" : "default",
"appId" : "030fdcea-cf97-40b1-96df-12084aea513c",
"attributes" : [ {
"name" : "Developer",
"value" : "tesla#weathersample.com"
}, {
"name" : "DisplayName",
"value" : "Weather"
}, {
"name" : "Notes",
"value" : "not yet"
}, {
"name" : "lastModifier",
"value" : ""
} ],
"callbackUrl" : "http://example.com/callback",
"createdAt" : 1363578857830,
"createdBy" : "adminui#apigee.com",
"credentials" : [ {
"apiProducts" : [ {
"apiproduct" : "weather",
"status" : "approved"
} ],
"attributes" : [ ],
"consumerKey" : "{key}",
"consumerSecret" : "{key}",
"expiresAt" : -1,
"scopes" : [ ],
"status" : "approved"
} ],
"developerId" : "Hk5mmLw9kKIM95qF",
"lastModifiedAt" : 1386042817268,
"lastModifiedBy" : "michael.bissell#apigee.com",
"name" : "weather",
"scopes" : [ ],
"status" : "approved"
}
Take a look at the Org Snapshot Tool on git if you want to interrogate the entire org with one script:
https://github.com/apigee/api-platform-samples/tree/master/tools
This will interrogate every developer and every app and put it into a nice tree structure in your file system for future reference.

Related

JFrog Artifactory AQL - Pagination mechanism

I am currently trying to query Artifactory for 25 results.
So I used:
items.find({"name" : {"$match":"somefile*"}).limit(25)
But I need to get also the Total result for calculate Total results.
If there is 500 results, i want to get it also.
For Example:
500/25 = 20 pages.
You can use the search command of the JFrog CLI, with the --count option to only get the number of results.
Or, using AQL through the REST API, you can first query without limit to get the total number of results, by looking at the total count at the range field:
{
"results" : [
{
"repo" : "libs-release-local",
"path" : "org/jfrog/artifactory",
"name" : "artifactory.war",
"type" : "item type",
"size" : "75500000",
"created" : "2015-01-01T10:10;10",
"created_by" : "Jfrog",
"modified" : "2015-01-01T10:10;10",
"modified_by" : "Jfrog",
"updated" : "2015-01-01T10:10;10"
}
],
"range" : {
"start_pos" : 0,
"end_pos" : 1,
"total" : 1 // <----
}
}

How to get Kibana dashboard ID?

How can I get kibana dashboard ID? for API call to export data from the dashboard.
I searched everywhere but I can't find ID for dashboard like in example(The dashboard ID is 942dcef0-b2cd-11e8-ad8e-85441f0c2e5c.).
I'm using ELK stack 7.4.1 OSS(Community version).
You can query your .kibana index from Command Line in your Elasticsearch with something like this;
$ curl -s http://localhost:9200/.kibana/dashboard/_search?pretty
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : ".kibana",
"_type" : "dashboard",
"_id" : "New-Dashboard",
"_score" : 1.0,
"_source" : {
"title" : "New Dashboard",
"hits" : 0,
"description" : "",
"panelsJSON" : "[{\"id\":\"Visualization-VerticalBarChart\",\"type\":\"visualization\",\"panelIndex\":1,\"size_x\":3,\"size_y\":2,\"col\":1,\"row\":1}]",
"optionsJSON" : "{\"darkTheme\":false}",
"uiStateJSON" : "{}",
"version" : 1,
"timeRestore" : false,
"kibanaSavedObjectMeta" : {
"searchSourceJSON" : "{\"filter\":[{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}}}]}"
}
}
} ]
}
}
Or if you want individual ones you can include the title or the id;
curl -s 'http://localhost:9200/.kibana/dashboard/_search?pretty=1,q=_id=New-Dashboard'
You may refer https://www.elastic.co/guide/en/kibana/current/index.html for more reference
You can find the ID in the URL.
Open the dashboard in Kibana. Extract the part in the URL after <view/> and before <?>.
For http://localhost:5601/app/dashboards#/view/bd1cc200-1169-4ee3-90da-c08d7eaacab5?_g=(filters:!()... the ID is bd1cc200-1169-4ee3-90da-c08d7eaacab5.
API
Alternative you can search and find dashboards using the saved objects API in Kibana:
curl http://localhost:5601/api/saved_objects/_find?type=dashboard
(Using Kibana 7.16)

Artifactory aql: find builds of job with given property

I am trying to query which build number(s) produced artifacts from build foo with artifact property vcs.Revision=aabbccddee123456.
In Artifactory 5.1.3.
I was trying like this so far:
curl -u user:apikey -i -X POST https://artifactory.foobar.com/artifactory/api/search/aql -H "content-type:text/plain" -T query.json
query.json:
builds.find(
{
"module.artifact.item.repo":"snapshot-local",
"name":"foo",
"module.artifact.item.#vcs.Revision":"aabbccddee123456"
}
)
However, none of these 3 lines seem individually correct:
builds.find({"module.artifact.item.repo":"snapshot-local"})
returns nothing,
builds.find({"name":"foo"})
returns the same empty response,
builds.find({"module.artifact.item.#vcs.Revision":"aabbccddee123456"}) also returns this:
{
"results" : [ ],
"range" : {
"start_pos" : 0,
"end_pos" : 0,
"total" : 0
}
}
What am I doing wrong here? I do see in the webapp the builds I published with this name, and with the correct artifact properties.
Here's a working solution that will give build numbers (since giving admin rights to query builds is not a solution for us):
query.json:
items.find(
{
"repo":"snapshot-local",
"artifact.module.build.name":"foo",
"artifact.item.#vcs.Revision":"aabbccddee123456"
}
).include("artifact.module.build.number")
This returns a list of all the artifacts that were built with the relevant properties, with the build number attached, e.g:
{
"results" : [ {
"repo" : "snapshot-local",
"path" : "foo/42",
"name" : "a.out",
"type" : "file",
"size" : 123456789,
"created" : "2018-07-05T12:34:56.789+09:00",
"created_by" : "jenkins",
"modified" : "2018-07-05T12:34:56.789+09:00",
"modified_by" : "jenkins",
"updated" : "2018-07-05T12:34:56.789+09:00",
"artifacts" : [ {
"modules" : [ {
"builds" : [ {
"build.number" : "42"
} ]
} ]
} ]
},
[SNIP]
}
],
"range" : {
"start_pos" : 0,
"end_pos" : 30,
"total" : 30
}
}
I can then parse this to extract build.number.
Certain AQL queries requires a user with admin permissions.
To ensure that non-privileged users do not gain access to information without the right permissions, users without admin privileges have the following restrictions:
The primary domain in the query may only be item.
The following three fields must be included in the include directive: name, repo, and path.
In your case, you are using the build domain in the query which requires admin permissions

What is the unique ID for API Products in the Apigee Edge server API?

I am using the REST API for the Apigee Edge server, and am getting the details of the API products for my organization:
https://api.enterprise.apigee.com/v1/organizations/chrisnovak/apiproducts/PremiumWeatherAPI
Here is the response:
{
"apiResources" : [ ],
"approvalType" : "auto",
"attributes" : [ {
"name" : "description",
"value" : "Premium API Product to expose the weather API to developers"
}, {
"name" : "access",
"value" : "public"
}, {
"name" : "developer.quota.limit",
"value" : "10000"
}, {
"name" : "developer.quota.interval",
"value" : "1"
}, {
"name" : "developer.quota.timeunit",
"value" : "month"
} ],
"createdAt" : 1351796304109,
"createdBy" : "noreply_admin#apigee.com",
"description" : "",
"displayName" : "Weather API",
"environments" : [ "test", "prod" ],
"lastModifiedAt" : 1386812022110,
"lastModifiedBy" : "cnovak#apigee.com",
"name" : "PremiumWeatherAPI",
"proxies" : [ "weather" ],
"quota" : "10000",
"quotaInterval" : "1",
"quotaTimeUnit" : "month",
"scopes" : [ "READ" ]
}
However, I do not see a unique key in the response, and do not see any Apigee API reference documentation for API products around what the unique key is.
My questions are:
What is the unique ID for the API products in the system?
If there is not a unique ID, what happens if the API product is renamed? I need to be able to associate API products with documentation in an external system, and if the name changes, I will no longer be able to associate that documentation with that API product.
Chris,
The unique ID is the name field. It is generated from the display name the first time you save the product. That never changes. Any later changes to the name change the displayName field but not the name.
The 'Name' field is the unique field here. if you change the display name it will not affect the name field, so you can go ahead and use the name field in your documentation.
Name field is unique here.
You can test it by changing the name field and doing a POST for apiproducts.
It will create an apiproduct with the same display name but different name field.
Then if you are using the same name field and editing just display name and trying to POST for apiproducts it will give error as below:
-bash-4.1$ POST /o/weatherapi/apiproducts -H "Accept: text/xml" -H "Content-Type: text/xml" -d #st.xml
Test
keymanagement.service.apiproduct_already_exists
ApiProduct with name yahoo1 already exists
-bash-4.1$

Rule-based node creation: commerce product + product display node set

I'm trying to bind a Commerce product type to my own custom type node (serving as a display node). The goal is to enter new data in as few places as possible. I'm therefore exploring a rule-based creation of one type upon creation of the other. Seems like both directions are working. Of the two though, I prefer automatic creation of a Commerce Product upon user creation of Custom Type node, which will then serve as a product display.
I was wondering if anyone has been through this choice and could recommend this. Also, is the commerce_product_display_manager module necessary?
Commerce Product Display Manager is not necessary, I've gotten this to work and I've never used that module.
I went for the route of automatically creating a Node after saving the Product.
Below is my Rules export for this:
{ "rules_create_product_display" : {
"LABEL" : "Create Product Display",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "entity" ],
"ON" : [ "commerce_product_insert" ],
"IF" : [
{ "data_is" : { "data" : [ "commerce-product:type" ], "value" : "**PRODUCT_TYPE**" } }
],
"DO" : [
{ "entity_create" : {
"USING" : {
"type" : "node",
"param_type" : "**NODE_TYPE**",
"param_title" : "[commerce-product:title]",
"param_author" : [ "commerce-product:creator" ]
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "data_set" : {
"data" : [ "entity-created:**PRODUCT_REFERENCE**" ],
"value" : [ "commerce-product" ]
}
}
]
}
}
You'll need to substitute your own values for:
PRODUCT_TYPE (product type that has been created)
NODE_TYPE (node type being created)
PRODUCT_REFERENCE (field that will reference the created product)
Sorry I can't dedicate more time to a better answer now, let me know if you'd like me to elaborate on the process of creating the above using the GUI
The above example was useful but here is a more specific one:
{ "rules_create_product_display_on_product_creation" : {
"LABEL" : "Create Product Display on Product creation",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "entity" ],
"ON" : [ "commerce_product_insert" ],
"IF" : [
{ "entity_is_of_type" : { "entity" : [ "commerce-product" ], "type" : "commerce_product" } }
],
"DO" : [
{ "entity_create" : {
"USING" : {
"type" : "node",
"param_type" : "product_display",
"param_title" : "[commerce-product:title]",
"param_author" : [ "commerce-product:creator" ]
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "data_set" : {
"data" : [ "entity-created:field-product:0" ],
"value" : [ "commerce-product" ]
}
}
]
}
}
The only problem I had was with the second action ("data_set")- it was important to select "entity-created:field-product:0", not the "entity-created:field-product" to make it work because we want to assign specific product and not a list of products.
This example is using the standard product display node type (product_display) but you can change it with the one you are using. Also have in mind that this is working only for one product type - for every product type a separated rule should be created. You may create also a rule for deleting the product display node when deleting the product.
This rule is useful only when you have connection one product-one product display. If you need to add more products per product display (colors, images with different prices) then you have to use Commerce Bulk Product Creation module.

Resources