Chilkat Online Tools

PureBasic / Core Services API / GetVlan

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    ; This example assumes the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    CkHttp::ckSetRequestHeader(http,"opc-request-id","8wF")
    CkHttp::ckSetRequestHeader(http,"Authorization","{{signature}}")
    CkHttp::ckSetRequestHeader(http,"Date","{{date}}")

    sbResponseBody.i = CkStringBuilder::ckCreate()
    If sbResponseBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkHttp::ckQuickGetSb(http,"https://iaas.{{region}}.oraclecloud.com/20160918/vlans/:vlanId",sbResponseBody)
    If success = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkStringBuilder::ckDispose(sbResponseBody)
        ProcedureReturn
    EndIf

    jResp.i = CkJsonObject::ckCreate()
    If jResp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoadSb(jResp,sbResponseBody)
    CkJsonObject::setCkEmitCompact(jResp, 0)

    Debug "Response Body:"
    Debug CkJsonObject::ckEmit(jResp)

    respStatusCode.i = CkHttp::ckLastStatus(http)
    Debug "Response Status Code = " + Str(respStatusCode)
    If respStatusCode >= 400
        Debug "Response Header:"
        Debug CkHttp::ckLastHeader(http)
        Debug "Failed."
        CkHttp::ckDispose(http)
        CkStringBuilder::ckDispose(sbResponseBody)
        CkJsonObject::ckDispose(jResp)
        ProcedureReturn
    EndIf

    ; Sample JSON response:
    ; (Sample code for parsing the JSON response is shown below)

    ; {
    ;   "id": "magna in Lorem",
    ;   "compartmentId": "amet ut quis",
    ;   "cidrBlock": "consequat non",
    ;   "lifecycleState": "AVAILABLE",
    ;   "vcnId": "sit consectetur Ut qui",
    ;   "availabilityDomain": "ea sunt officia mollit",
    ;   "definedTags": {},
    ;   "displayName": "ullamco magna eu",
    ;   "freeformTags": {},
    ;   "nsgIds": [
    ;     "ad amet exercitation",
    ;     "ut irure magna"
    ;   ],
    ;   "routeTableId": "sunt occaecat exercitation mollit",
    ;   "timeCreated": "1974-12-31T12:49:21.840Z",
    ;   "vlanTag": -19036463
    ; }

    ; Sample code for parsing the JSON response...
    ; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    strVal.s

    id.s = CkJsonObject::ckStringOf(jResp,"id")
    compartmentId.s = CkJsonObject::ckStringOf(jResp,"compartmentId")
    cidrBlock.s = CkJsonObject::ckStringOf(jResp,"cidrBlock")
    lifecycleState.s = CkJsonObject::ckStringOf(jResp,"lifecycleState")
    vcnId.s = CkJsonObject::ckStringOf(jResp,"vcnId")
    availabilityDomain.s = CkJsonObject::ckStringOf(jResp,"availabilityDomain")
    displayName.s = CkJsonObject::ckStringOf(jResp,"displayName")
    routeTableId.s = CkJsonObject::ckStringOf(jResp,"routeTableId")
    timeCreated.s = CkJsonObject::ckStringOf(jResp,"timeCreated")
    vlanTag.i = CkJsonObject::ckIntOf(jResp,"vlanTag")
    i.i = 0
    count_i.i = CkJsonObject::ckSizeOfArray(jResp,"nsgIds")
    While i < count_i
        CkJsonObject::setCkI(jResp, i)
        strVal = CkJsonObject::ckStringOf(jResp,"nsgIds[i]")
        i = i + 1
    Wend


    CkHttp::ckDispose(http)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkJsonObject::ckDispose(jResp)


    ProcedureReturn
EndProcedure

Curl Command

curl -X GET
	-H "opc-request-id: 8wF"
	-H "Date: {{date}}"
	-H "Authorization: {{signature}}"
https://iaas.{{region}}.oraclecloud.com/20160918/vlans/:vlanId

Postman Collection Item JSON

{
  "name": "GetVlan",
  "request": {
    "method": "GET",
    "header": [
      {
        "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
        "key": "opc-request-id",
        "value": "8wF"
      },
      {
        "key": "Date",
        "value": "{{date}}",
        "description": "(Required) Current Date",
        "type": "text"
      },
      {
        "key": "Authorization",
        "value": "{{signature}}",
        "description": "(Required) Signature Authentication on Authorization header",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/vlans/:vlanId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "vlans",
        ":vlanId"
      ],
      "variable": [
        {
          "key": "vlanId",
          "value": "amet ut",
          "description": "(Required) The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the VLAN."
        }
      ]
    },
    "description": "Gets the specified VLAN's information."
  },
  "response": [
    {
      "name": "The VLAN was retrieved.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/vlans/:vlanId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "vlans",
            ":vlanId"
          ],
          "variable": [
            {
              "key": "vlanId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "etag",
          "value": "officia sed",
          "description": "For optimistic concurrency control. See `if-match`.\n"
        },
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"id\": \"magna in Lorem\",\n \"compartmentId\": \"amet ut quis\",\n \"cidrBlock\": \"consequat non\",\n \"lifecycleState\": \"AVAILABLE\",\n \"vcnId\": \"sit consectetur Ut qui\",\n \"availabilityDomain\": \"ea sunt officia mollit\",\n \"definedTags\": {},\n \"displayName\": \"ullamco magna eu\",\n \"freeformTags\": {},\n \"nsgIds\": [\n  \"ad amet exercitation\",\n  \"ut irure magna\"\n ],\n \"routeTableId\": \"sunt occaecat exercitation mollit\",\n \"timeCreated\": \"1974-12-31T12:49:21.840Z\",\n \"vlanTag\": -19036463\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/vlans/:vlanId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "vlans",
            ":vlanId"
          ],
          "variable": [
            {
              "key": "vlanId"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
    },
    {
      "name": "Not Found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/vlans/:vlanId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "vlans",
            ":vlanId"
          ],
          "variable": [
            {
              "key": "vlanId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
    },
    {
      "name": "Internal Server Error",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/vlans/:vlanId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "vlans",
            ":vlanId"
          ],
          "variable": [
            {
              "key": "vlanId"
            }
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
    },
    {
      "name": "An error has occurred.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/vlans/:vlanId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "vlans",
            ":vlanId"
          ],
          "variable": [
            {
              "key": "vlanId"
            }
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
    }
  ]
}