Deleting apigee permission on a role using the api - apigee

I have created a userrole and I am now unable to delete one of the permissions on it using the api. I wanted to block all access to a resource so I created it with a empty array of http verbs. This is possible using both the single and multi add permission resources like so
POST /userroles/readonly/permissions" -d '{"path" : "/resource", "permissions" : []}' -H "Content-Type:application/json"
However now that I want to delete that permission from the role I am unable to as the delete takes the http verb in the path and is mandatory, as there is no http verb in my case the call fails and I am unable to do a delete. If I had a verb then it would look like this
DELETE "/userroles/readonly/permissions/get?path=/resource"
If I call the api with no verb specified it fails with this error:
< HTTP/1.1 400 Bad Request
...
"code" : "security.QueryParamResourcePathCannotBeNull",
"message" : "Query parameter path cannot be null or empty",
"contexts" : [ ]
I dont really want to delete the role and recreate it if that can be avoided.
Any ideas? This seems like a bit of a design flaw in the permissions system.
Thanks!

in your example above there is no permission to delete.
Why do not you try to add a 'get' permission at fiest by the same POST call and then DELETE if you like. POST works even if you have already modified a resource permission.
In that case the DELETE call results in a proper delete response.
Pls do comment how it goes.
Step1
curl http://hostname/v1/organizations/myorg/userroles/role1/permissions -u "admin#org.com:***" -d '{"path" : "/resource", "permissions" : ["get"]}' -H "Content-Type:application/json" -v
Step2
curl -X DELETE "http://hostname/v1/organizations/myorg/userroles/role1/permissions/get?path=/resource" -u "admin#org.com:***" -v

Related

Automating removing user groups

I'm trying to automate removing the users groups in Artifactory for users who leave the company.
I'm retrieving their user JSON details, then modifying the JSON by deleting the groups section. So far so good. But when I upload the updated JSON the groups are not removed from that user in Artifactory.
I'm using the following command to upload the updated JSON:
curl -u <username>:<password> -XPUT "<server name>/artifactory/api/security/users/<user>" -H "Content-Type: application/json" -T user.json
I'm not getting an error when executing the command, but nothing is updated for that user.
Any ideas what I'm doing wrong here?
As per the Artifactory REST API wiki you should use a POST method to update a User's groups, so as an example - To update a user (u1) and delete his groups I would use:
curl -u<an_admin_user>:<a_password> -XPOST http://<rt_server>:<port>/artifactory/api/security/users/u1 -T /path/to/file/Update_U1_Groups.json
where the JSON file would look like:
{
"name" : "u1",
"groups" : []
}

Gitlab - How to list all merge requests for a branch from a bash shell?

I have a project with many branches and I would like to list all merge requests from a specific branch from the console.
I found the merge requests API and I also found that I need an HTTP request to do it from this issue like this:
curl --header "PRIVATE-TOKEN: XXXXXX" -X GET "https://gitlab.example.com/api/v3/projects/project_name/merge_requests?source_branch=XXXXXX"
But I haven't figured out yet how. The response is this:
{"message":"404 Project Not Found"}
Although the name of the project is correct.
project_name in your example should actually be fully namespaced project name or project ID.
eg: If your project called myproject is under a group called mygroup, the api call would be:
curl --header "PRIVATE-TOKEN: XXXXXX" -X GET "https://gitlab.example.com/api/v3/projects/mygroup%2Fmyproject/merge_requests?source_branch=XXXXXX"
If you want to use project ID instead, you can get it at https://gitlab.com/api/v4/projects/[project path URL encoded]
Ref:
HOW to check id of project in gitlab

How to change artifactory admin default password through command line

i have installed latest version of Artifactory Pro (5.8.3) on Centos7. The default admin credentials are admin/password. i want to change the password through command-line but unable to do so.
Does any one has any inputs how to do this?
Following troubleshootings i tried:
jfrog rt c rt-server-1 --url=http://domain/artifactory --user=admin --password=password ...
nothing happens , when i try to use a new password i get 401: unauthorize error
jfrog guide tells to generate security.xml and add the hash code of the new password but security.xml does not get generated even after following all their steps.
also tried to use curl commands but no use.
If any one has gone through similar issue please share your findings. let me know if you need more info.know on case
JFrog CLI currently does not support changing of a user's password. the CLI config method you were using simply lets you configure your server and credentials to be used by other CLI command later.
What you can do is use a simple curl command to invoke the change password API as described here.
specifically, in your example changing the Admin's password to "NewPassword" will be something like:
curl -X POST -u admin:password -H "Content-type: application/json" -d '{ "userName" : "admin", "oldPassword" : "password", "newPassword1" : "NewPassword", "newPassword2" : "NewPassword" }' http://yourartifactory:8081/artifactory/api/security/users/authorization/changePassword

Missing required parameter: name when using solr CREATEALIAS

I submitted a reqest to my solr cloud server with curl:
curl http://solrserver1:8983/solr/admin/collections?action=CREATEALIAS&name=bf&collections=collection1,collection2
It return a 400 error and said: Missing required parameter: name. But you see in the command line I really provided a name parameter.
I saw several post online talking about CREATEALIAS action, so I think it must be some mistake of myself. My solr server is version 4.6.1
Could anyone know what's the reason ?
Should add quotes like this:
curl "http://solrserver1:8983/solr/admin/collections?action=CREATEALIAS&name=bf&collections=collection1,collection2"
It works and return status 0
Following commands worked:
$ bin/solr create_collection -c techproducts -d _default -n techproducts -shards 2 -replicationFactor 2 -V
The output shows the rest api url
$ curl http://localhost:7574/solr/admin/collections?action=CREATE&name=techproducts&numShards=2&replicationFactor=2&maxShardsPerNode=-1&collection.configName=techproducts

Uploading a file on a URL

Can anyone help me to find out a unix command that is used to upload/download a file on/from an URL?
Particular URL in which i'm trying to upload/download is protected with an user id and password.
I guess curl serves this purpose but not aware of how to use it? Could you please give me sugegstions on this?
curl has a command line argument named -d (for data) and you can use it like this to send a file(you need to add a # before a file-name to have curl treat it as a file and not a value:
curl -X POST -d #myfilename http://example.com/upload
You can add multiple -d arguments if you need to send a FORM value along with your file. Like so:
curl -X POST -d #myfilename -d name=MyFile http://example.com/upload

Resources