github.com/vmware/go-vcloud-director/v2@v2.24.0/samples/openapi/README.md (about)

     1  # Open API consumption using low level functions and RAW JSON structures
     2  
     3  This example demonstrates how to consume new [OpenAPI](https://vdc-download.vmware.com/vmwb-repository/dcr-public/71f952e6-c14b-417d-8749-dbb5ff2dd48a/9b26a7c0-0cee-40a2-8c01-2f15472324cf/com.vmware.vmware_cloud_director.openapi_34_0.pdf) in VMware Cloud Director. 
     4  
     5  OpenAPI low level functions consist of the following to match REST API:
     6  * OpenApiGetAllItems (FIQL filtering can be applied to narrow down results)
     7  * OpenApiPostItem
     8  * OpenApiGetItem
     9  * OpenApiPutItem
    10  * OpenApiDeleteItem
    11  * OpenApiIsSupported
    12  * OpenApiBuildEndpoint
    13  
    14  **Note** The endpoint `1.0.0/auditTrail` requires VCD API to support version 33.0 or higher. Version 33.0 was introduced
    15  with VCD 10.0.
    16  
    17  ## Using mode 1 (Dump raw JSON message as string)
    18  This command will dump JSON for audiTrail endpoint as string allowing to pipe it and process using
    19  external tools like `jq`
    20  ```
    21  ./openapi --username my_user --password my_secret_password --org my-org --endpoint https://192.168.1.160/api --mode 1 | jq
    22  ```
    23  
    24  Sample output:
    25  ```
    26  [
    27    {
    28      "eventId": "urn:vcloud:audit:1df68f82-8e75-4bf9-94ce-c06e1cec66bc",
    29      "description": "User 'administrator' login failed",
    30      "operatingOrg": {
    31        "name": "username-custom",
    32        "id": "urn:vcloud:org:534625ff-7399-4368-8313-0b75d66bbb6e"
    33      },
    34      "user": {
    35        "name": "administrator",
    36        "id": "urn:vcloud:user:522d756c-ad00-3b4f-ae6a-6d241437b471"
    37      },
    38      "eventEntity": {
    39        "name": "administrator",
    40        "id": "urn:vcloud:user:522d756c-ad00-3b4f-ae6a-6d241437b471"
    41      },
    42      "taskId": null,
    43  ...
    44  ```
    45  
    46  ## Using mode 2 (Define custom struct with JSON tags and access fields)
    47  This mode allows to use OpenAPI in regular Go way (by defining a struct with JSON field tags)
    48  
    49  ```
    50  ./openapi --username my_user --password my_secret_password --org my-org --endpoint https://192.168.1.160/api --mode 2
    51  ```
    52  
    53  Sample output:
    54  
    55  ```
    56  Got 30 results
    57  2020-07-19T18:57:34.398+0000 - administrator, -com/vmware/vcloud/event/session/login
    58  2020-07-19T18:58:04.211+0000 - administrator, -com/vmware/vcloud/event/user/create
    59  2020-07-19T18:58:13.904+0000 - dainius, -com/vmware/vcloud/event/session/login
    60  2020-07-19T18:58:14.026+0000 - dainius, -com/vmware/vcloud/event/session/authorize
    61  2020-07-19T18:58:18.256+0000 - dainius, -com/vmware/vcloud/event/session/login
    62  2020-07-19T18:58:18.353+0000 - dainius, -com/vmware/vcloud/event/session/authorize
    63  2020-07-19T18:58:23.841+0000 - dainius, -com/vmware/vcloud/event/session/login
    64  2020-07-19T18:58:23.934+0000 - dainius, -com/vmware/vcloud/event/session/authorize
    65  2020-07-19T19:01:22.513+0000 - dainius, -com/vmware/vcloud/event/session/login
    66  2020-07-19T19:01:22.619+0000 - dainius, -com/vmware/vcloud/event/session/authorize
    67  2020-07-19T19:04:54.392+0000 - dainius, -com/vmware/vcloud/event/session/login
    68  2020-07-19T19:04:54.517+0000 - dainius, -com/vmware/vcloud/event/session/authorize
    69  2020-07-19T19:04:59.648+0000 - dainius, -com/vmware/vcloud/event/session/login
    70  2020-07-19T19:04:59.758+0000 - dainius, -com/vmware/vcloud/event/session/authorize
    71  ```
    72  
    73  ## Troubleshooting
    74  Environment variable `GOVCD_LOG=1` can be used to enable API call logging. It should log all API
    75  calls with obfuscated credentials to aid troubleshooting.