How do I delete empty folders(folders without any content) by using Artifactory AQL?
I have the current AQL query to find files that are older than 12w and never downloaded, which I will delete by an script.
items.find(
{
"repo":{"$eq":"libs-release-local"},
"stat.downloads":{"$eq":null},
"created":{"$before" : "12w"},
}
)
This leaves me with empty folders, how do I specify an AQL query that finds all empty folders?
From Artifactory Query Language documentation: if type is not specified in the query, the default type searched for is file.
By adding a type to the query you can control the result type: file, folder or both.
For example:
items.find(
{
"repo": {"$eq":"libs-release-local"},
"stat.downloads": {"$eq":null},
"created": {"$before" : "12w"},
"type": {"$eq":"any"}
}
)
If you are not married to the idea of using AQL, note that there is an Empty Folder Clean-up plugin by JFrog.
Related
In Cosmos DB, I have an index setting that looks like this:
"includedPaths": [
{
"path": "/PartitionKey/*"
}
]
What would be the difference if I changed the Path to only this: "/PartitionKey"?
That means indexing won't be enabled on the nested nodes in the document. The path to anything under /PartitionKey/. The character * should be used if you are planing to query on sub properties of the property for this path.
from the documentation,
the /* wildcard can be used to match any elements below the node
If you don't have nested nodes then this should be good enough. Also you need to use the ? character at the end of the index path is required to serve queries that query on this property.
/PartitionKey/?
We have a use case to download or at least list all .xml files from a folder inside a zip in Artifactory from a python script. Is it possible with REST or using AQL ? I am looking for a search query to get all xmls from a folder in zip so that I can use "archive entries download" thing from REST API to make download request for each file individually. Please help me with relevant information about the endpoint or query that I can use to achieve my task(list all xml in a folder in zip). Also please let me know of any other efficient approach to accomplish the task.
You can use an AQL query to get a list of files from a given path inside an archive.
As an example, lets take the my-archive.zip archive deployed in a repository names myrepo inside folder1 folder
The follow AQL query can be used to find all the xml files within this archive under the path level-1/level-2/level-3:
archive.entries.find( {
"archive.item.path":{"$eq":"folder1"},
"archive.item.name":{"$eq":"my-archive.zip"},
"archive.entry.path":{"$eq":"level-1/level-2/level-3"},
"archive.entry.name":{"$match":"*.xml"}
})
You can run this query using the AQL REST API method and get the following result:
{
"results" : [ {
"entry.name" : "dummy.xml",
"entry.path" : "level-1/level-2/level-3"
} ],
"range" : {
"start_pos" : 0,
"end_pos" : 1,
"total" : 1
}
}
Here is an example of calling this REST API using curl (the query itself is stored in a file called aql.json):
curl -XPOST -uadmin:password -H"content-type: text/plain" -d#aql.json http://localhost:8081/artifactory/api/search/aql
I'm using insomnia to make calls to the Artifactory API.
I have the following query, which works really well:
items.find({"repo":{"$eq":"my-repository-virt"}}, {"$and":[{"#my.fileType":{"$match": "jar"}},{"#my.otherType":{"$match": "type2"}},{"#prodVersion":{"$match": "false"}}]})
But I have a problem in that there are duplicate files in some sub-folders with the same properties/filename that I would like to exclude.
I would like to add path to this query, but I can never get any results returned.
The repository is a virtual repository that links to 3 other real repositories.
One of my colleagues can call the following query with the command line tool and get the expected results:
jfrog rt search my-repo-snapshots/myproject/subfolder/jars/*.jar
I have tried adding the path parameter to my query, I've tried removing everything except the repo and the path, like this:
items.find({"repo":{"$eq":"my-repo-snapshots"}},{"path" : "my-repo-snapshots/myproject/subfolder/jars/*.jar"})
I've tried with just the path, with variations on the path, including/excluding the repo name, using the virtual repo, the actual repo, but I always get a successful search with 0 results returned.
How can I build this query to search the virtual repo, along a certain path, and including certain properties?
EDIT:
I've also tried:
items.find({"repo":{"$eq":"my-repo-snapshots"}},{"path" : {"$match":"my-repo-snapshots/myproject/subfolder/jars/*.jar"}})
Both with the repo in the path and without, I still get 0 results.
OK I figured it out.
The path part needs to be added in with the {"$and": ...} section where the properties are included. Like so:
items.find({"repo":{"$eq":"my-repository-virt"}},
{"$and":[
{"path":{"$match":"path/to/relevant/folders/*"}},
{"#my.fileType":{"$match": "jar"}},
{"#my.otherType":{"$match": "type2"}},
{"#prodVersion":{"$match": "false"}}
]})
The easier fix would have been:
items.find({"repo":{"$eq":"my-repo-snapshots"}},{"path" : {"$eq":"my-repo-snapshots/myproject/subfolder/jars"}, {"name" : {"$match":"*.jar"}})
So the problem with your initial attempt, is that the "path" should match the folder and the "name" should match the filename
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.
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.