Chilkat Online Tools

C / Core Services API / GetVirtualCircuit

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *value;
    const char *strVal;
    const char *bandwidthShapeName;
    const char *bgpManagement;
    const char *bgpSessionState;
    const char *compartmentId;
    int customerBgpAsn;
    const char *displayName;
    const char *gatewayId;
    const char *id;
    const char *lifecycleState;
    int oracleBgpAsn;
    const char *providerName;
    const char *providerServiceId;
    const char *providerServiceKeyName;
    const char *providerServiceName;
    const char *providerState;
    const char *referenceComment;
    const char *region;
    const char *serviceType;
    const char *timeCreated;
    const char *v_type;
    int i;
    int count_i;

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

    http = CkHttp_Create();

    CkHttp_SetRequestHeader(http,"Authorization","{{signature}}");
    CkHttp_SetRequestHeader(http,"Date","{{date}}");

    sbResponseBody = CkStringBuilder_Create();
    success = CkHttp_QuickGetSb(http,"https://iaas.{{region}}.oraclecloud.com/20160918/virtualCircuits/:virtualCircuitId",sbResponseBody);
    if (success == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttp_getLastStatus(http);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttp_lastHeader(http));
        printf("Failed.\n");
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

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

    // {
    //   "bandwidthShapeName": "aliquip quis",
    //   "bgpManagement": "PROVIDER_MANAGED",
    //   "bgpSessionState": "UP",
    //   "compartmentId": "ex voluptate ea eiusmod",
    //   "crossConnectMappings": [
    //     {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   ],
    //   "customerBgpAsn": 32592947,
    //   "definedTags": {},
    //   "displayName": "sunt exercitation",
    //   "freeformTags": {},
    //   "gatewayId": "sed deserunt magna",
    //   "id": "ex Duis amet culpa",
    //   "lifecycleState": "PROVISIONING",
    //   "oracleBgpAsn": 34318225,
    //   "providerName": "ullamco occaecat culpa cillum",
    //   "providerServiceId": "nisi ex culpa dolor",
    //   "providerServiceKeyName": "nostru",
    //   "providerServiceName": "laboris labore",
    //   "providerState": "ACTIVE",
    //   "publicPrefixes": [
    //     "proident et amet qui dolor",
    //     "tempor nostrud"
    //   ],
    //   "referenceComment": "laboris fugiat do",
    //   "region": "dolore sint ut non",
    //   "routingPolicy": [
    //     "MARKET_LEVEL",
    //     "GLOBAL"
    //   ],
    //   "serviceType": "LAYER2",
    //   "timeCreated": "2021-02-05T13:31:56.554Z",
    //   "type": "PUBLIC"
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    bandwidthShapeName = CkJsonObject_stringOf(jResp,"bandwidthShapeName");
    bgpManagement = CkJsonObject_stringOf(jResp,"bgpManagement");
    bgpSessionState = CkJsonObject_stringOf(jResp,"bgpSessionState");
    compartmentId = CkJsonObject_stringOf(jResp,"compartmentId");
    customerBgpAsn = CkJsonObject_IntOf(jResp,"customerBgpAsn");
    displayName = CkJsonObject_stringOf(jResp,"displayName");
    gatewayId = CkJsonObject_stringOf(jResp,"gatewayId");
    id = CkJsonObject_stringOf(jResp,"id");
    lifecycleState = CkJsonObject_stringOf(jResp,"lifecycleState");
    oracleBgpAsn = CkJsonObject_IntOf(jResp,"oracleBgpAsn");
    providerName = CkJsonObject_stringOf(jResp,"providerName");
    providerServiceId = CkJsonObject_stringOf(jResp,"providerServiceId");
    providerServiceKeyName = CkJsonObject_stringOf(jResp,"providerServiceKeyName");
    providerServiceName = CkJsonObject_stringOf(jResp,"providerServiceName");
    providerState = CkJsonObject_stringOf(jResp,"providerState");
    referenceComment = CkJsonObject_stringOf(jResp,"referenceComment");
    region = CkJsonObject_stringOf(jResp,"region");
    serviceType = CkJsonObject_stringOf(jResp,"serviceType");
    timeCreated = CkJsonObject_stringOf(jResp,"timeCreated");
    v_type = CkJsonObject_stringOf(jResp,"type");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"crossConnectMappings");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        value = CkJsonObject_stringOf(jResp,"crossConnectMappings[i].value");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"publicPrefixes");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        strVal = CkJsonObject_stringOf(jResp,"publicPrefixes[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"routingPolicy");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        strVal = CkJsonObject_stringOf(jResp,"routingPolicy[i]");
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -X GET
	-H "Date: {{date}}"
	-H "Authorization: {{signature}}"
https://iaas.{{region}}.oraclecloud.com/20160918/virtualCircuits/:virtualCircuitId

Postman Collection Item JSON

{
  "name": "GetVirtualCircuit",
  "request": {
    "method": "GET",
    "header": [
      {
        "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}}/virtualCircuits/:virtualCircuitId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "virtualCircuits",
        ":virtualCircuitId"
      ],
      "variable": [
        {
          "key": "virtualCircuitId",
          "value": "amet ut",
          "description": "(Required) The [OCID](/Content/General/Concepts/identifiers.htm) of the virtual circuit."
        }
      ]
    },
    "description": "Gets the specified virtual circuit's information."
  },
  "response": [
    {
      "name": "The virtual circuit was retrieved.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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 \"bandwidthShapeName\": \"aliquip quis\",\n \"bgpManagement\": \"PROVIDER_MANAGED\",\n \"bgpSessionState\": \"UP\",\n \"compartmentId\": \"ex voluptate ea eiusmod\",\n \"crossConnectMappings\": [\n  {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n ],\n \"customerBgpAsn\": 32592947,\n \"definedTags\": {},\n \"displayName\": \"sunt exercitation\",\n \"freeformTags\": {},\n \"gatewayId\": \"sed deserunt magna\",\n \"id\": \"ex Duis amet culpa\",\n \"lifecycleState\": \"PROVISIONING\",\n \"oracleBgpAsn\": 34318225,\n \"providerName\": \"ullamco occaecat culpa cillum\",\n \"providerServiceId\": \"nisi ex culpa dolor\",\n \"providerServiceKeyName\": \"nostru\",\n \"providerServiceName\": \"laboris labore\",\n \"providerState\": \"ACTIVE\",\n \"publicPrefixes\": [\n  \"proident et amet qui dolor\",\n  \"tempor nostrud\"\n ],\n \"referenceComment\": \"laboris fugiat do\",\n \"region\": \"dolore sint ut non\",\n \"routingPolicy\": [\n  \"MARKET_LEVEL\",\n  \"GLOBAL\"\n ],\n \"serviceType\": \"LAYER2\",\n \"timeCreated\": \"2021-02-05T13:31:56.554Z\",\n \"type\": \"PUBLIC\"\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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": [
        ],
        "url": {
          "raw": "{{baseUrl}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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": [
        ],
        "url": {
          "raw": "{{baseUrl}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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": [
        ],
        "url": {
          "raw": "{{baseUrl}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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}"
    }
  ]
}