CURL: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 119: Line 119:


|}
|}
==Mock API==
<syntaxhighlight lang="bash">
time cat <<< '{
  "gender":[
    {
      "domain":"chorke.org", "group":"gender", "code":"M", "name":"Male",
      "properties":{}, "extendedProperties":{
        "code":{
          "ISO":1,
          "SCTID":"446151000124109"
        },
        "locale":{
          "ar_SA":"ذكر",
          "en_US":"Male",
          "bn_BD":"পুরুষ",
          "he_IL":"זָכָר",
          "ms_MY":"Jantan"
        }
      }
    },
    {
      "domain":"chorke.org", "group":"gender", "code":"F", "name":"Female",
      "properties":{}, "extendedProperties":{
        "code":{
          "ISO":2,
          "SCTID":"446141000124107"
        },
        "locale":{
          "ar_SA":"أنثى",
          "en_US":"Female",
          "bn_BD":"মহিলা",
          "he_IL":"נְקֵבָה",
          "ms_MY":"Perempuan"
        }
      }
    },
    {
      "domain":"chorke.org", "group":"gender", "code":"U", "name":"Unknown",
      "properties":{}, "extendedProperties":{
        "code":{
          "ISO":0,
          "SCTID":"UNK"
        },
        "locale":{
          "ar_SA":"مجهول",
          "bn_BD":"অজানা",
          "en_US":"Unknown",
          "he_IL":"לא ידוע",
          "ms_MY":"Tidak Diketahui"
        }
      }
    },
    {
      "domain":"chorke.org", "group":"gender", "code":"N", "name":"Not Applicable",
      "properties":{}, "extendedProperties":{
        "code":{
          "ISO":9,
          "SCTID":"33791000087105"
        },
        "locale":{
          "ar_SA":"غير قابل للتطبيق",
          "bn_BD":"প্রযোজ্য নয়",
          "en_US":"Applicable",
          "he_IL":"לא ישים",
          "ms_MY":"Tidak Berkaitan"
        }
      }
    }
  ]
}'| tee ~/Documents/flask-playground/MockApi/collections-v1.json >/dev/null
</syntaxhighlight>


==References==
==References==

Revision as of 20:53, 20 April 2024

sudo apt update
sudo apt install curl && curl --version

Playground

# post request body
time cat <<< '{
    "code": "M",
    "name": "Male",
    "group": "gender",
    "properties": {},
    "extendedProperties": {}
}'| curl http://127.0.0.1:1983/v1/collections\
 -H 'x-auth-key:aeda11fd-14ea-44d0-aff6-e94bf6b78c1b'\
 -H 'Content-Type:application/json'\
 --data @-
# post request body
time curl http://127.0.0.1:1983/v1/collections\
 -H 'x-auth-key:aeda11fd-14ea-44d0-aff6-e94bf6b78c1b'\
 -H 'Content-Type:application/json'\
 --data '{
    "code": "M",
    "name": "Male",
    "group": "gender",
    "properties": {},
    "extendedProperties": {}
}'

# put request body
time cat <<< '{
    "code": "M",
    "name": "Male",
    "group": "gender",
    "properties": {},
    "extendedProperties": {}
}'| curl http://127.0.0.1:1983/v1/collections\
 -H 'x-auth-key:aeda11fd-14ea-44d0-aff6-e94bf6b78c1b'\
 -H 'Content-Type:application/json'\
 -X PUT \
 --data @-
# put request body
time curl http://127.0.0.1:1983/v1/collections\
 -H 'x-auth-key:aeda11fd-14ea-44d0-aff6-e94bf6b78c1b'\
 -H 'Content-Type:application/json'\
 -X PUT \
 --data '{
    "code": "M",
    "name": "Male",
    "group": "gender",
    "properties": {},
    "extendedProperties": {}
}'

# delete response body
time cat <<< '{
    "code": "M",
    "name": "Male",
    "group": "gender",
    "properties": {},
    "extendedProperties": {}
}'| curl http://127.0.0.1:1983/v1/collections\
 -H 'x-auth-key:aeda11fd-14ea-44d0-aff6-e94bf6b78c1b'\
 -H 'Content-Type:application/json'\
 -X DELETE \
 --data @-
# delete response body
time curl http://127.0.0.1:1983/v1/collections\
 -H 'x-auth-key:aeda11fd-14ea-44d0-aff6-e94bf6b78c1b'\
 -H 'Content-Type:application/json'\
 -X DELETE \
 --data '{
    "code": "M",
    "name": "Male",
    "group": "gender",
    "properties": {},
    "extendedProperties": {}
}'

time curl http://127.0.0.1:1983/v1/collections
time curl https://cdn.chorke.org/exec/cli/
curl --version
curl --help

Mock API

time cat <<< '{
  "gender":[
    {
      "domain":"chorke.org", "group":"gender", "code":"M", "name":"Male",
      "properties":{}, "extendedProperties":{
        "code":{
          "ISO":1,
          "SCTID":"446151000124109"
        },
        "locale":{
          "ar_SA":"ذكر",
          "en_US":"Male",
          "bn_BD":"পুরুষ",
          "he_IL":"זָכָר",
          "ms_MY":"Jantan"
        }
      }
    },
    {
      "domain":"chorke.org", "group":"gender", "code":"F", "name":"Female",
      "properties":{}, "extendedProperties":{
        "code":{
          "ISO":2,
          "SCTID":"446141000124107"
        },
        "locale":{
          "ar_SA":"أنثى",
          "en_US":"Female",
          "bn_BD":"মহিলা",
          "he_IL":"נְקֵבָה",
          "ms_MY":"Perempuan"
        }
      }
    },
    {
      "domain":"chorke.org", "group":"gender", "code":"U", "name":"Unknown",
      "properties":{}, "extendedProperties":{
        "code":{
          "ISO":0,
          "SCTID":"UNK"
        },
        "locale":{
          "ar_SA":"مجهول",
          "bn_BD":"অজানা",
          "en_US":"Unknown",
          "he_IL":"לא ידוע",
          "ms_MY":"Tidak Diketahui"
        }
      }
    },
    {
      "domain":"chorke.org", "group":"gender", "code":"N", "name":"Not Applicable",
      "properties":{}, "extendedProperties":{
        "code":{
          "ISO":9,
          "SCTID":"33791000087105"
        },
        "locale":{
          "ar_SA":"غير قابل للتطبيق",
          "bn_BD":"প্রযোজ্য নয়",
          "en_US":"Applicable",
          "he_IL":"לא ישים",
          "ms_MY":"Tidak Berkaitan"
        }
      }
    }
  ]
}'| tee ~/Documents/flask-playground/MockApi/collections-v1.json >/dev/null

References