How to set component Maximum age field in Nexus repository 3.5 using API's - nexus

I am using the simple create script to add the script to the repo manager successfully : https://github.com/sonatype/nexus-book-examples/blob/nexus-3.x/scripting/simple-shell-example/create.sh
and passing a JSON file like this
{
"name": "apachesnapshots",
"type": "groovy",
"content": "repository.createMavenProxy('apachesnapshots-io',
'http://repository.apache.org/snapshots/', 'default' ,org.sonatype.nexus.repository.proxy.ContentMaxAge.-1)"
}
For Release repositories, it says that the Maximum component age should be -1. I am getting 1440 by default. I have figured out the parameter that i need to pass in repository.createMavenProxy() should be ContentMaxAge. But not able to figure out if it should be added at a particular position and how to set its value to -1.

You can use the Repository Manager within the API to get attributes and then change them accordingly.
To see the configuration, use a script like:
return repository.getRepositoryManager().get('my-proxy-repo').getConfiguration()
To change them, use something like:
repository.getRepositoryManager().get('my-proxy-repo').getConfiguration().getAttributes().'proxy'.'contentMaxAge' = -1
Hope it helps,
Steve

Related

Deep chained paths with compiled view model objects

Given a compiled view model hierarchy instantiated with this data:
"applications":[
{
"application_id":1,
"name":"Test Application 1",
"description":"An Application For Testing",
"settings":[
{
"name":"Application 1 Setting Key 1",
"value":"Application 1 Setting Value 1"
}
],
"projects":[
{
"project_id":1,
"name":"Test Project 1",
"description":"A project for testing 1",
"settings":[
{
"name":"Project 1 Setting Key 1",
"value":"Project 1 Setting Value 1"
}
]
}
]
}
]
I'm having difficulty tapping into the observables at levels farther down in the tree.
No problem observing changes to properties of an application:
$.observe(data.applications(), ".[]^*", ...
But how about changes to properties of a setting under an application? These are all FAILs:
$.observe(data.applications().settings(), ".[]^*", ...
$.observe(data.applications(), ".settings.[]^*", ...
$.observe(data.applications(), ".settings().[]^*", ...
I see the documentation specifically mentions parentheses will not work in chained paths like the last example so there wasn't much hope for that last one.
I seem to be able to get away with this:
$.observe(data.applications(), ".[]._settings.[]^*", ...
and if that's the only way please confirm, but the underscore makes me feel like I've tapped into underlying/protected/unofficial representation of data path. Any other way to chain compiled vm paths?
Given that applications() returns an array, as does settings(), you can't write:
$.observe(data.applications().settings(), "[]^*", ...
If you want to target a particular application, such as data.applications()[0], you could write:
$.observe(data.applications()[0].settings(), "[]^*", ...
If you want to target all the settings properties under any application, you can write:
$.observe(data.applications(), "[]._settings.[]^*", ...
You are right that _settings is supposed to be 'internal'. The intended design was indeed to let you write:
$.observe(data.applications(), "[].settings.[]^*", ...
but there is a currently a bug which prevents this from working. An upcoming update will either fix this bug, or propose a slightly different pattern. For now it would be better to stay with _settings, which will at any rate continue to work after the next update. Look out too, after the next update, for possible new documentation topics on the [].* wild cards and other related features...
BTW if you want to listen to changes after modifying the data hierarchy higher up (for example the applications() array - which you might change using the merge() feature for VMs), then you will need to put a ^ at an appropriate level in the path, to listen to any changes below that level. For example you can write
$.observe(data.applications(), "[]^_settings.[].*", ...
or
$.observe(data.applications(), "^[]._settings.[].*", ...
or
$.observe(data, "_applications^[]._settings.[].*", ...
Another option is the ** wild card - which you can use at any level to show all changes below that level:
$.observe(data.applications(), "**", ...
or
$.observe(data, "**", ...
or
$.observe(data, "_applications^[].**", ...

Using parameters in Azure Service Bus Subscription SqlFilter expression

I am using an ARM template to try and deploy a subscription to an Azure Service Bus Topic which filters messages based on the To system property. I would like to pull the value for the filter from an ARM template parameter, but I can't seem to get the template to resolve the param in the SqlExpression.
Below is the template I have been messing around with. I thought I could maybe just toggle the requiresPreprocessing switch to get it to resolve the param on deployment, but no dice. I also played with trying to escape it using double square brackets or colons as shown in the link below
https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-sql-filter#propertyname
{
"apiVersion": "2017-04-01",
"name": "[concat(parameters('mynamespace'), '/', parameters('topic'), '/', parameters('myVariable'),'/direct')]",
"type": "Microsoft.ServiceBus/namespaces/topics/subscriptions/rules",
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('mynamespace'))]",
"[resourceId('Microsoft.ServiceBus/namespaces/topics', parameters('mynamespace'), parameters('topic'))]",
"[resourceId('Microsoft.ServiceBus/namespaces/topics/subscriptions', parameters('mynamespace'), parameters('topic'), parameters('myVariable'))]"
],
"properties": {
"filterType": "SqlFilter",
"sqlFilter": {
"sqlExpression": "sys.To=[parameters('myVariable')] OR sys.To IS NULL",
"requiresPreprocessing": true
}
}
What I am getting is the string exactly as it is displayed in the sqlExpression, but I would like to get the value that the variable resolves to in a single quoted string.
This topic subscription rules may only get static values. Maybe you can try with a static value instead of [parameters('myVariable')]. This problem might because of giving dynamic value to the property sys.To.
You could use: "[concat('sys.To=',[parameters('myVariable')],' OR sys.To IS NULL')]".
You cannot use inline expressions in an ARM template I think, therefor you should make the whole thing an expression and in this case use concat to glue the parts together.
Hint: including single quotes is difficult, so a variable like this might come in handy:
"SQ": "'"

Invalid schema for REST JSON CreatePassengerNameRecord response

I am trying to test the integration for the Sabre CreatePassengerNameRecord rest API. As the first step, I tried downloading the JSON schemas for the Request and Response and tried to generate the POJOs using jsonschema2pojo. But it looks like the schema files are all pointing to dependent references using a URL http://services.sabre.com which is non existing. Hence the POJO generation is getting failed. This is happening for both the request and response. I was able to fix the request schema by changing the URL for XMLSchemaTypes.json dependency to provided URL link in documentation, but the response has a reference which is not specified anywhere (Please check the Response schema section of question ).
API Link: https://developer.sabre.com/docs/rest_apis/air/book/create_passenger_name_record/
Response Schema:
In the response, there is a reference to http://services.sabre.com/STL_Payload/v02_02 which is not existing.
File : http://files.developer.sabre.com/doc/providerdoc/STPS/create_passenger_name_record/v200/CreatePassengerNameRecord2.0.0RS.json
....
"CreatePassengerNameRecordRS" : {
"type" : "object",
"title" : "CreatePassengerNameRecordRS",
"properties" : {
"version" : {
"type" : "string",
"minLength" : 1,
"maxLength" : 255
},
"ApplicationResults" : {
"$ref" : "http://services.sabre.com/STL_Payload/v02_02#/definitions/ApplicationResults"
....
It would be great it you could provide the latest file for the STL_Payload or update the documentation to the latest working version.
The missing files were added to the documentation page.
This should allow you to move forward.
The id-s are still used as tags and not as absolute resource pointers so you still need to play with it they way you described to make the auto-generation working out of the box.
We will consider your request to convert them to resource pointers in the future.
Just one more hint: if you are using Java-API version of jsonschema2pojo please use this for config:
GenerationConfig config = new DefaultGenerationConfig() {
public String getRefFragmentPathDelimiters() {
return "#/";
}
};
You need it because the default path delimiters in jsonschema2pojo are "#/." and the "." does not work with some of the types declared in the schema like Text.Long
+1 Sabre please make JSON schema available on http://services.sabre.com as it is problematic when generating models using Quicktype. Types are not being resolved correctly.

Aggregating a list of http log paths in kibana

I have a nginx->fluentd->elasticsearch->kibana stack up and running. Trying to figure if I can do something like a "terms" panel but with a path string component from logs. Using a terms panel directly on that results in top used words from paths, e.g. for drupal it shows "node" as the most popular, which is quite useless without actual node id.
Is that something that is possible to do with elasticsearch?
Update: Here's a sample of my logs:
"path": "/node/123"
"path": "/node/456"
"path": "/user/create"
If I add a "terms" panel for "path" field, I get columns for "node", "user", "create", which make no statistical sense. What I need is a terms panel that aggregates on unique field values, not unique word parts of the field.
You need to configure Elasticsearch's mapping for setting your "path" field as a "not_analyzed" one. The default setting is "analyzed" and by default, ES parses the string fields and divide them in multiple tokens when possible, which is probably what happened in your case. See this related question.
As for how to configure Elasticsearch's mapping, I am also still digging, having a similar problem myself with multi-token strings I want to be able to sort on. It seems like there would be a put mapping API or the possibility of using config files, see here.

Filter property based searches in Artifactory

I'm looking to use the Artifactory property search
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ArtifactSearch%28QuickSearch%29
Currently this will pull json listing any artifact that matches my properties.
"results" : [
{
"uri": "http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver/lib-ver.pom"
},{
"uri": "http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver2/lib-ver2.pom"
}
]
I need to be able to filter the artifacts I get back as i'm only interested in a certain classifier. The GAVC Search has this with &c=classifier
I can do it in code if this isn't possible via the interface
Any help appreciated
Since the release of AQL in Artifactory 3.5, it's now the official and the preferred way to find artifacts.
Here's an example similar to your needs:
items.find
(
{
"$and":[
{"#license":{"$eq":"GPL"}},
{"#version":{"$match":"1.1.*"}},
{"name":{"$match":"*.jar"}}
]
}
)
To run the query in Artifactory, copy the query to a file and name it aql.query
Run the following command from the directory that contains the aql.query file
curl -X POST -uUSER:PASSWORD 'http://HOST:PORT/artifactory/api/search/aql' -Taql.query
Don't forget to replace the templates (USER, PASSWORD,HOST and PORT) to real values.
In the example
The first two criteria are used to filter items by properties.
The third criteria filters items by the artifact name (in our case the artifact name should end with .jar)
For more details on how to write AQL query are in AQL
Old answer
Currently you can't combine the property search with GAVC search.
So you have two options:
Executing one of them (whichever gives you more precise results) and then filter the JSON list on the client by a script
Writing an execution user plugin that will execute the search by using the Searches service and then filter the results on the server side.
Of course, the later is preferable.

Resources