Changing a zone name with PDNS v1 API - powerdns

I have PowerDNS Authoritative Server 4.1.0-rc1 set up on server. I'm trying to change a zone domain name.
curl -X PUT \
http://<MY_IP>:<MY_PORT>/api/v1/servers/localhost/zones/<MY_DOMAIN>. \
-H 'content-type: application/json' \
-H 'x-api-key: <MY_KEY>' \
-d '{
"kind": "Master",
"name": "<NEW_NAME>."
}'
A kind is being changed to Master, however name stays the same.
A document at https://doc.powerdns.com/authoritative/http-api/endpoint-zones.html says
PUT /api/v1/servers/:server_id/zones/:zone_id Modifies basic zone data
(metadata).
Changing name renames the zone, as expected.

I have contacted Pdns team and it looks like they do not support updating name and are going to remove it from 4.1 documentation.

Related

Testing AWS API Gateway with cURL

I do have a simple AWS API Gateway implementation protected by an AWS_IAM Authorization.
I just want to test from command line via cURL :
curl --location --request GET 'https://<API_ID>.execute-api.eu-west-1.amazonaws.com/stage?type=type&category=category&lc=lc&passprhase=passprhase&product=product'
--header 'Authorization: AWS4-HMAC-SHA256 Credential=<AWS_ACCESS_KEY>/20200127/eu-west-1/execute-api/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=<AWS_SECRET_ACCESS_KEY>' --header 'Content-Type: application/json' \
--data-raw '{"query":"","variables":{}}'
but keep getting the follow error :
Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header.
Can someone advice what am I doing wrong ?
AWS V4 signature authentication is supported in curl starting from version 7.75, so you should be able to call your AWS resource this way:
curl --location --request GET 'https://$API-ID.execute-api.eu-west-1.amazonaws.com/stage?type=type&category=category&lc=lc&passprhase=passprhase&product=product' \
--header 'Content-Type: application/json' \
--user $ACCESS_KEY:$SECRET_KEY \
--aws-sigv4 "aws:amz" \
--data-raw '{"query":"","variables":{}}'
Note that you may need to add in the --aws-sigv4 value your region and service.
For example: --aws-sigv4 "aws:amz:eu-west-2:execute-api"
You can find more documentation here: https://curl.se/libcurl/c/CURLOPT_AWS_SIGV4.html
And the documentation for the CLI option here: https://curl.se/docs/manpage.html#--aws-sigv4
AWS_IAM authorization uses Sigv4 and its calculation process requires values certain headers - Date being one of them. You are passing x-amz-date as a part of the "SignedHeaders" field, but not actually passing it with the other headers.
One way to create the right curl command to invoke an API with AWS_IAM would be to use Postman application. Add in the API URL and select "AWS Signature" under Authorization tab. You can then select the "Code" option and get the full curl command which would look something like this -
curl -X POST \
https://$API-ID.execute-api.$AWS_REGION.amazonaws.com/$STAGE/$RESOURCE \
-H 'authorization: AWS4-HMAC-SHA256 Credential=$ACCESS_KEY/20200128/$AWS_REGION/execute-api/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=$SIGNATURE_VALUE' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'host: API-ID.execute-api.$AWS_REGION.amazonaws.com' \
-H 'postman-token: 15f9498e-95b7-f22b-eed9-016cdea07424' \
-H 'x-amz-date: $DATE_STAMP'
Create a Canonical Request for Signature Version 4
I could suggest to use awscurl which is much easier.
To install awscurl click here. For documentation you can refer here.
Example to call apigateway to call lambda for POST query is below.
awscurl --service execute-api -X POST -d '{ "alias" : "xyx", "type" : "LDAP" }' https://.execute-api.us-west-2.amazonaws.com/Prod/user/groups/get --region us-west-2 --access_key ACCESS_KEY --secret_key mfBl0YJRsXDue4C5F5B6rz1eUpQpA8uC24RtSnsg --security_token SECURITY_TOKEN

Using CURL to upload to Dropbox and overwrite a file

I'm a small time admin and would say entry level to Linux. I am trying to use CURL to upload to Dropbox a small backup sqlitedb and have had success for the first upload, however, I am trying to accomplish uploading a file to Dropbox every 30 minutes and overwriting the current file in DROPBOX with the new file from my Linux server (as a jerry-rigged offsite backup of my Teamspeak database)
This is the code I have so far :
curl -X PUT https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer <dropbox code here>" \
--header "Dropbox-API-Arg: {\"path\": \"/home/ec2-user/ts3server.sqlitedb.bz2\"}" \
--header "Content-Type: application/octet-stream" \
--data-binary ts3server.sqlitedb.bz2
After running that code once, it doesn't OVERRIDE the current file in my Dropbox account with the updated file. Any help is appreciated
you need to use mode with parameter overwrite. The default is add.
Add - Do not overwrite an existing file if there is a conflict. The autorename strategy is to append a number to the file name. For
example, "document.txt" might become "document (2).txt".
overwrite - Always overwrite the existing file. The autorename strategy is the same as it is for add.
Reference: /upload
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer " \
--header "Dropbox-API-Arg: {\"path\": \"/Homework/math/Matrices.txt\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary #local_file.txt

can't create server-admin in couchdb

I'm following the couchdb security documentation (http://docs.couchdb.org/en/1.6.1/intro/security.html) to try to create a server-admin using cURL: curl -X PUT $HOST/_config/admins/anna -d '"secret"'
When I do this, I get an error:
{"error":"not_found","reason":"Database does not exist."}
I'm on v2.0 so I don't known if something has changed since the 1.6 version of the documentation. I can create server-admins just fine using fauxton. Any ideas?
To anybody else running into this issue, it's an easy answer: in couchdb 2.0 some of the APIs moved to using port 5986 ... I had been using port 5984 (which is still used a lot in v2.0, but apparently not for the _config endpoint).
The following works:
curl -X PUT http://localhost:5986/_config/admins/admin1 -d '"password"'
The Couchdb2 way of adding a user is
curl -X PUT http://localhost:5984/_node/nodename/_config/admins/admin1 -d '"password"'
In the GUI, you can find out that you need to set up a single node cluster, and when you do that you specify the admin username and password.
And you can do the same thing using an API endpoint that you can POST to:
http://docs.couchdb.org/en/2.1.0/api/server/common.html#post--_cluster_setup
With 2.0 using enable_single_node returned {"error":"bad_request","reason":"Invalid Action'"} so I reverted to doing:
j=$(cat <<EOF
{
"action": "enable_cluster",
"bind_address": "0.0.0.0",
"username": "admin",
"password": "$PASS",
"port": "5984",
"node_count":"1"
}
EOF
)
curl -s -X POST -H "Content-Type: application/json" http://$IP/_cluster_setup -d "$j"
curl -s -X POST -H "Content-Type: application/json" $URI/_cluster_setup -d '{"action": "finish_cluster"}'

Fiware: How to create lazy attributes through IDAS UltraLight

I'm using the IoT Agent Ultra-Light module to communicate with the Orion context broker. I can create services and devices and I have checked that the observations reach the context broker too.
curl -X POST XXX.XXX.XXX.XXX:8090/iot/services \
-i \
-H "Content-Type: application/json" \
-H "Fiware-Service: sanitysrv " \
-H "Fiware-ServicePath: / sanitysspath " \
-d '{"services": [{"apikey": "", "cbroker": "http://127.0.0.1:1026", "entity_type": "Dispositivo_tmp", "resource": "/iot/d"}]}'
curl -X POST XXX.XXX.XXX.XXX:8090/iot/devices \
-i \
-H "Content-Type: application/json" \
-H "Fiware-Service: sanitysrv" \
-H "Fiware-ServicePath: /sanitysspath" \
-d '{"devices":[{"device_id":"CE_BDM_3","protocol":"PDI-IoTA-UltraLight", "commands": [], "attributes": [{"type":"int","name":"temperature","object_id":"t"}]}]}'
My problem is that I don´t know how to register a device that contains lazy attributes, and I haven´t found any documentation with related examples. The examples from other IoT Agents that I have tried are not working here.
¿How can it be done?
Lazy attributes are not supported in the UL2.0/MQTT Agent so far but in IoT Agents developed with node.js.
We'll let you know as soon as this feature is available.
Cheers,

CouchDB not "creating" new users

I recently install CouchDB on my CentOS box ('yum install couchdb'). I set up an admin account and then set out to create my first non-admin user. I issue the command..
curl -X PUT http://admin:abc123#localhost:5984/_users/org.couchdb.user:brad \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"name": "brad", "password": "asdf", "roles": [], "type": "user"}'
The response looks good..
{"ok":true,"id":"org.couchdb.user:brad","rev":"3-078014aabce23da851ef243f92a7fc5c"}
Now, to verify the user data has been created properly I get the new user data..
curl -X GET http://admin:abc123#localhost:5984/_users/org.couchdb.user:brad/
.. and I get the following response which seems to be missing some things..
{"_id":"org.couchdb.user:brad","_rev":"3-078014aabce23da851ef243f92a7fc5c","name":"brad","password":"asdf","roles":[],"type":"user"}
... from everything I've read there should be some additional fields.. "password_scheme", "iterations", "derived_key", and "salt". Further, I've created a database in Futon and set "brad" as a reader for that database, but when I attempt to access the DB as brad from the CLI I get an error..
curl -X GET http://brad:asdf#localhost:5984/test_db
{"error":"unauthorized","reason":"Name or password is incorrect."}
Anyone have any idea why CouchDB isn't processing the new user properly?
It looks like your CouchDB is out of date; the new authentication stuff is in 1.3.0+. You may have better luck using build-couchdb: https://github.com/jhs/build-couchdb

Resources