Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Last active February 16, 2023 12:44
Show Gist options
  • Select an option

  • Save tuxfight3r/0dcdab36e5ef46f82718bedc0cb62455 to your computer and use it in GitHub Desktop.

Select an option

Save tuxfight3r/0dcdab36e5ef46f82718bedc0cb62455 to your computer and use it in GitHub Desktop.

Revisions

  1. tuxfight3r revised this gist Sep 19, 2017. No changes.
  2. tuxfight3r revised this gist Sep 19, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions curl_notes.txt
    Original file line number Diff line number Diff line change
    @@ -19,27 +19,31 @@ curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    -X PATCH \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "test", "path": "/data/testpath1", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'

    #Add aditional value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    -X PATCH \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "add", "path": "/data/testpath1", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'

    #Delete a value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    -X PATCH \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "remove", "path": "/data/testpath4" }]'

    #Replace a value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    -X PATCH \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "replace", "path": "/data/testpath", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'

    @@ -50,13 +54,15 @@ curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/merge-patch+json" \
    -H "Accept: application/json" \
    -X PATCH \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '{"data":{"testpath2":"oliverconfigmaptest2"}}'

    #Remove a basic merge json via curl merges/adds the given data to a configmap
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/merge-patch+json" \
    -H "Accept: application/json" \
    -X PATCH \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '{"data":{"testpath4": null}}'

  3. tuxfight3r revised this gist Sep 19, 2017. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions curl_notes.txt
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,13 @@ curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest

    ## USES JSON PATCH ##

    #Test if a value exists inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "test", "path": "/data/testpath1", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'

    #Add aditional value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
  4. tuxfight3r revised this gist Sep 19, 2017. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions curl_notes.txt
    Original file line number Diff line number Diff line change
    @@ -46,5 +46,12 @@ curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '{"data":{"testpath2":"oliverconfigmaptest2"}}'

    #Remove a basic merge json via curl merges/adds the given data to a configmap
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/merge-patch+json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '{"data":{"testpath4": null}}'



  5. tuxfight3r renamed this gist Sep 19, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. tuxfight3r renamed this gist Sep 19, 2017. 1 changed file with 17 additions and 5 deletions.
    22 changes: 17 additions & 5 deletions curl_notes.txt → curl_notes.md
    Original file line number Diff line number Diff line change
    @@ -12,21 +12,33 @@ curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest

    #Replace a value inside configmap named configmaptest

    ## USES JSON PATCH ##

    #Add aditional value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "replace", "path": "/data/testpath", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'
    --data '[{ "op": "add", "path": "/data/testpath1", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'

    #Delete a value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "remove", "path": "/data/testpath4" }]'

    #Add aditional value inside configmap named configmaptest
    #Replace a value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "add", "path": "/data/testpath1", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'
    --data '[{ "op": "replace", "path": "/data/testpath", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'


    ## USES MERGE PATCH ##

    #Add a basic merge json via curl merges/adds the given data to a configmap
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/merge-patch+json" \
  7. tuxfight3r created this gist Sep 19, 2017.
    38 changes: 38 additions & 0 deletions curl_notes.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #Login to openshift and retrieve token
    curl -u admin -kv -H "X-CSRF-Token: xxx" \
    'https://master.cluster.local:8443/oauth/authorize?client_id=openshift-challenging-client&response_type=token'

    #It should give you a bearer token like this
    https://master.cluster.local:8443/oauth/token/implicit#access_token=aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4&expires_in=86400&scope=user%3Afull&token_type=Bearer

    TOKEN="aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4"

    #Get a configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest

    #Replace a value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "replace", "path": "/data/testpath", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'

    #Add aditional value inside configmap named configmaptest
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/json-patch+json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '[{ "op": "add", "path": "/data/testpath1", "value": "CN=p-ocp-user,OU=openshift,OU=DEVOPS" }]'

    #Add a basic merge json via curl merges/adds the given data to a configmap
    curl -H 'Authorization: Bearer aRVmsEHbUEhd4WeP2bctj0n57ogHMBvOIcrtjc7tCw4' \
    -H "Content-Type: application/merge-patch+json" \
    -H "Accept: application/json" \
    https://master.cluster.local:8443//api/v1/namespaces/ocp_test/configmaps/configmaptest \
    --data '{"data":{"testpath2":"oliverconfigmaptest2"}}'