Chilkat Online Tools

C / Core Services API / GetInstance

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 *id;
    const char *compartmentId;
    const char *shape;
    const char *region;
    const char *availabilityDomain;
    const char *lifecycleState;
    const char *timeCreated;
    const char *Value;
    const char *IsManagementDisabledValue;
    const char *IsMonitoringDisabledValue;
    const char *PluginsConfigValue;
    const char *IsLiveMigrationPreferredValue;
    const char *RecoveryActionValue;
    const char *capacityReservationId;
    const char *dedicatedVmHostId;
    const char *displayName;
    const char *faultDomain;
    const char *imageId;
    const char *AreLegacyImdsEndpointsDisabledValue;
    const char *ipxeScript;
    const char *launchMode;
    const char *BootVolumeTypeValue;
    const char *FirmwareValue;
    const char *IsConsistentVolumeNamingEnabledValue;
    const char *IsPvEncryptionInTransitEnabledValue;
    const char *NetworkTypeValue;
    const char *RemoteDataVolumeTypeValue;
    const char *TypeValue;
    const char *IsMeasuredBootEnabledValue;
    const char *IsSecureBootEnabledValue;
    const char *IsTrustedPlatformModuleEnabledValue;
    const char *PreemptionActionValue;
    const char *BaselineOcpuUtilizationValue;
    const char *GpuDescriptionValue;
    const char *GpusValue;
    const char *LocalDiskDescriptionValue;
    const char *LocalDisksValue;
    const char *LocalDisksTotalSizeInGBsValue;
    const char *MaxVnicAttachmentsValue;
    const char *MemoryInGBsValue;
    const char *NetworkingBandwidthInGbpsValue;
    const char *OcpusValue;
    const char *ProcessorDescriptionValue;
    const char *SourceTypeValue;
    const char *timeMaintenanceRebootDue;

    // 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/instances/:instanceId",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)

    // {
    //   "id": "sit dolor",
    //   "compartmentId": "et esse",
    //   "shape": "sunt veniam",
    //   "region": "laboris",
    //   "availabilityDomain": "dolor",
    //   "lifecycleState": "TERMINATED",
    //   "timeCreated": "2006-02-03T20:50:31.716Z",
    //   "agentConfig": {
    //     "areAllPluginsDisabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "isManagementDisabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "isMonitoringDisabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "pluginsConfig": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "availabilityConfig": {
    //     "isLiveMigrationPreferred": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "recoveryAction": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "capacityReservationId": "occaecat sint id",
    //   "dedicatedVmHostId": "ipsum dolor incididunt sit ex",
    //   "definedTags": {},
    //   "displayName": "consequat aliquip magna ullamco",
    //   "extendedMetadata": {},
    //   "faultDomain": "incididunt esse",
    //   "freeformTags": {},
    //   "imageId": "dolor nulla consequat ipsum",
    //   "instanceOptions": {
    //     "areLegacyImdsEndpointsDisabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "ipxeScript": "anim magna",
    //   "launchMode": "CUSTOM",
    //   "launchOptions": {
    //     "bootVolumeType": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "firmware": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "isConsistentVolumeNamingEnabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "isPvEncryptionInTransitEnabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "networkType": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "remoteDataVolumeType": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "metadata": {},
    //   "platformConfig": {
    //     "type": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "isMeasuredBootEnabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "isSecureBootEnabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "isTrustedPlatformModuleEnabled": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "preemptibleInstanceConfig": {
    //     "preemptionAction": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "shapeConfig": {
    //     "baselineOcpuUtilization": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "gpuDescription": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "gpus": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "localDiskDescription": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "localDisks": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "localDisksTotalSizeInGBs": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "maxVnicAttachments": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "memoryInGBs": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "networkingBandwidthInGbps": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "ocpus": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     "processorDescription": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "sourceDetails": {
    //     "sourceType": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "timeMaintenanceRebootDue": "1973-07-06T14:36:00.263Z"
    // }

    // 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.

    id = CkJsonObject_stringOf(jResp,"id");
    compartmentId = CkJsonObject_stringOf(jResp,"compartmentId");
    shape = CkJsonObject_stringOf(jResp,"shape");
    region = CkJsonObject_stringOf(jResp,"region");
    availabilityDomain = CkJsonObject_stringOf(jResp,"availabilityDomain");
    lifecycleState = CkJsonObject_stringOf(jResp,"lifecycleState");
    timeCreated = CkJsonObject_stringOf(jResp,"timeCreated");
    Value = CkJsonObject_stringOf(jResp,"agentConfig.areAllPluginsDisabled.value");
    IsManagementDisabledValue = CkJsonObject_stringOf(jResp,"agentConfig.isManagementDisabled.value");
    IsMonitoringDisabledValue = CkJsonObject_stringOf(jResp,"agentConfig.isMonitoringDisabled.value");
    PluginsConfigValue = CkJsonObject_stringOf(jResp,"agentConfig.pluginsConfig.value");
    IsLiveMigrationPreferredValue = CkJsonObject_stringOf(jResp,"availabilityConfig.isLiveMigrationPreferred.value");
    RecoveryActionValue = CkJsonObject_stringOf(jResp,"availabilityConfig.recoveryAction.value");
    capacityReservationId = CkJsonObject_stringOf(jResp,"capacityReservationId");
    dedicatedVmHostId = CkJsonObject_stringOf(jResp,"dedicatedVmHostId");
    displayName = CkJsonObject_stringOf(jResp,"displayName");
    faultDomain = CkJsonObject_stringOf(jResp,"faultDomain");
    imageId = CkJsonObject_stringOf(jResp,"imageId");
    AreLegacyImdsEndpointsDisabledValue = CkJsonObject_stringOf(jResp,"instanceOptions.areLegacyImdsEndpointsDisabled.value");
    ipxeScript = CkJsonObject_stringOf(jResp,"ipxeScript");
    launchMode = CkJsonObject_stringOf(jResp,"launchMode");
    BootVolumeTypeValue = CkJsonObject_stringOf(jResp,"launchOptions.bootVolumeType.value");
    FirmwareValue = CkJsonObject_stringOf(jResp,"launchOptions.firmware.value");
    IsConsistentVolumeNamingEnabledValue = CkJsonObject_stringOf(jResp,"launchOptions.isConsistentVolumeNamingEnabled.value");
    IsPvEncryptionInTransitEnabledValue = CkJsonObject_stringOf(jResp,"launchOptions.isPvEncryptionInTransitEnabled.value");
    NetworkTypeValue = CkJsonObject_stringOf(jResp,"launchOptions.networkType.value");
    RemoteDataVolumeTypeValue = CkJsonObject_stringOf(jResp,"launchOptions.remoteDataVolumeType.value");
    TypeValue = CkJsonObject_stringOf(jResp,"platformConfig.type.value");
    IsMeasuredBootEnabledValue = CkJsonObject_stringOf(jResp,"platformConfig.isMeasuredBootEnabled.value");
    IsSecureBootEnabledValue = CkJsonObject_stringOf(jResp,"platformConfig.isSecureBootEnabled.value");
    IsTrustedPlatformModuleEnabledValue = CkJsonObject_stringOf(jResp,"platformConfig.isTrustedPlatformModuleEnabled.value");
    PreemptionActionValue = CkJsonObject_stringOf(jResp,"preemptibleInstanceConfig.preemptionAction.value");
    BaselineOcpuUtilizationValue = CkJsonObject_stringOf(jResp,"shapeConfig.baselineOcpuUtilization.value");
    GpuDescriptionValue = CkJsonObject_stringOf(jResp,"shapeConfig.gpuDescription.value");
    GpusValue = CkJsonObject_stringOf(jResp,"shapeConfig.gpus.value");
    LocalDiskDescriptionValue = CkJsonObject_stringOf(jResp,"shapeConfig.localDiskDescription.value");
    LocalDisksValue = CkJsonObject_stringOf(jResp,"shapeConfig.localDisks.value");
    LocalDisksTotalSizeInGBsValue = CkJsonObject_stringOf(jResp,"shapeConfig.localDisksTotalSizeInGBs.value");
    MaxVnicAttachmentsValue = CkJsonObject_stringOf(jResp,"shapeConfig.maxVnicAttachments.value");
    MemoryInGBsValue = CkJsonObject_stringOf(jResp,"shapeConfig.memoryInGBs.value");
    NetworkingBandwidthInGbpsValue = CkJsonObject_stringOf(jResp,"shapeConfig.networkingBandwidthInGbps.value");
    OcpusValue = CkJsonObject_stringOf(jResp,"shapeConfig.ocpus.value");
    ProcessorDescriptionValue = CkJsonObject_stringOf(jResp,"shapeConfig.processorDescription.value");
    SourceTypeValue = CkJsonObject_stringOf(jResp,"sourceDetails.sourceType.value");
    timeMaintenanceRebootDue = CkJsonObject_stringOf(jResp,"timeMaintenanceRebootDue");


    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/instances/:instanceId

Postman Collection Item JSON

{
  "name": "GetInstance",
  "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}}/instances/:instanceId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "instances",
        ":instanceId"
      ],
      "variable": [
        {
          "key": "instanceId",
          "value": "officia sed",
          "description": "(Required) The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the instance."
        }
      ]
    },
    "description": "Gets information about the specified instance."
  },
  "response": [
    {
      "name": "The instance was retrieved.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/instances/:instanceId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "instances",
            ":instanceId"
          ],
          "variable": [
            {
              "key": "instanceId"
            }
          ]
        }
      },
      "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\": \"sit dolor\",\n \"compartmentId\": \"et esse\",\n \"shape\": \"sunt veniam\",\n \"region\": \"laboris\",\n \"availabilityDomain\": \"dolor\",\n \"lifecycleState\": \"TERMINATED\",\n \"timeCreated\": \"2006-02-03T20:50:31.716Z\",\n \"agentConfig\": {\n  \"areAllPluginsDisabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"isManagementDisabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"isMonitoringDisabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"pluginsConfig\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n },\n \"availabilityConfig\": {\n  \"isLiveMigrationPreferred\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"recoveryAction\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n },\n \"capacityReservationId\": \"occaecat sint id\",\n \"dedicatedVmHostId\": \"ipsum dolor incididunt sit ex\",\n \"definedTags\": {},\n \"displayName\": \"consequat aliquip magna ullamco\",\n \"extendedMetadata\": {},\n \"faultDomain\": \"incididunt esse\",\n \"freeformTags\": {},\n \"imageId\": \"dolor nulla consequat ipsum\",\n \"instanceOptions\": {\n  \"areLegacyImdsEndpointsDisabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n },\n \"ipxeScript\": \"anim magna\",\n \"launchMode\": \"CUSTOM\",\n \"launchOptions\": {\n  \"bootVolumeType\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"firmware\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"isConsistentVolumeNamingEnabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"isPvEncryptionInTransitEnabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"networkType\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"remoteDataVolumeType\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n },\n \"metadata\": {},\n \"platformConfig\": {\n  \"type\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"isMeasuredBootEnabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"isSecureBootEnabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"isTrustedPlatformModuleEnabled\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n },\n \"preemptibleInstanceConfig\": {\n  \"preemptionAction\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n },\n \"shapeConfig\": {\n  \"baselineOcpuUtilization\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"gpuDescription\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"gpus\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"localDiskDescription\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"localDisks\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"localDisksTotalSizeInGBs\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"maxVnicAttachments\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"memoryInGBs\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"networkingBandwidthInGbps\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"ocpus\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  \"processorDescription\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n },\n \"sourceDetails\": {\n  \"sourceType\": {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n },\n \"timeMaintenanceRebootDue\": \"1973-07-06T14:36:00.263Z\"\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/instances/:instanceId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "instances",
            ":instanceId"
          ],
          "variable": [
            {
              "key": "instanceId"
            }
          ]
        }
      },
      "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}}/instances/:instanceId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "instances",
            ":instanceId"
          ],
          "variable": [
            {
              "key": "instanceId"
            }
          ]
        }
      },
      "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}}/instances/:instanceId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "instances",
            ":instanceId"
          ],
          "variable": [
            {
              "key": "instanceId"
            }
          ]
        }
      },
      "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}}/instances/:instanceId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "instances",
            ":instanceId"
          ],
          "variable": [
            {
              "key": "instanceId"
            }
          ]
        }
      },
      "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}"
    }
  ]
}