|
1 | 1 | ---
|
2 |
| -title: HPE GreenLake edge-to-cloud platform scripting fundamentals |
| 2 | +title: HPE GreenLake cloud scripting fundamentals |
3 | 3 | date: 2024-01-24T09:51:57.270Z
|
4 | 4 | featuredBlog: false
|
5 | 5 | priority: 15
|
@@ -111,13 +111,13 @@ The response provides an access token of type “Bearer” with a time to live o
|
111 | 111 | According to the [API Reference documentation](https://developer.greenlake.hpe.com/docs/greenlake/services/audit-logs/public/) for the Audit Log service, I can query the log using:
|
112 | 112 |
|
113 | 113 | ```markdown
|
114 |
| -GET /audit-log/v1beta1/logs |
| 114 | +GET /audit-log/v1/logs |
115 | 115 | ```
|
116 | 116 |
|
117 | 117 | I can also see from the documentation, that I can use a filter to keep only logs after a certain date using the following parameter:
|
118 | 118 |
|
119 | 119 | ```markdown
|
120 |
| -GET /audit-log/v1beta1/logs?filter=createdAt ge '2023-07-24T04:21:22.00Z' |
| 120 | +GET /audit-log/v1/logs?filter=createdAt ge '2023-07-24T04:21:22.00Z' |
121 | 121 | ```
|
122 | 122 |
|
123 | 123 | > > *Note: the format of the date used by the API, which is [ISO 8601](https://www.iso.org/standard/70908.html) of the form: YYYY-MM-DDTHH:MM:SS.ss-/+FF:ff. For example: '2023-07-24T04:21:22.00Z' for 4:21AM on the 24th of July, 2023 in UTC (Z=Zero Meridian)*
|
|
235 | 235 | I can now call the API with the right authorization header and set the filter parameter, **startTime** greater than the computed date:
|
236 | 236 |
|
237 | 237 | ```shell
|
238 |
| -http_response=$(curl -s -o out.json -w "%{http_code}" --location "https://global.api.greenlake.hpe.com/audit-log/v1beta1/logs?filter=startTime%20ge%20'$d'" \ |
| 238 | +http_response=$(curl -s -o out.json -w "%{http_code}" --location "https://global.api.greenlake.hpe.com/audit-log/v1/logs?filter=startTime%20ge%20'$d'" \ |
239 | 239 | --header 'Accept: application/json' \
|
240 | 240 | --header "Authorization: $access_token")
|
241 | 241 | ```
|
@@ -371,7 +371,7 @@ Here, you’ll see that I can leverage exceptions that PowerShell supports:
|
371 | 371 |
|
372 | 372 | ```powershell
|
373 | 373 | try {
|
374 |
| - $response = Invoke-webrequest "https://global.api.greenlake.hpe.com/audit-log/v1beta1/logs?filter=startTime%20ge%20'$sd'" -Method GET -Headers $headers |
| 374 | + $response = Invoke-webrequest "https://global.api.greenlake.hpe.com/audit-log/v1/logs?filter=startTime%20ge%20'$sd'" -Method GET -Headers $headers |
375 | 375 | }
|
376 | 376 | catch {
|
377 | 377 | write-host "Error calling the API or token has expired!"
|
@@ -498,7 +498,7 @@ my_headers = {
|
498 | 498 | 'accept': 'application/json',
|
499 | 499 | 'Authorization': my_token,
|
500 | 500 | }
|
501 |
| - my_url = "https://global.api.greenlake.hpe.com/audit-log/v1beta1/logs?filter=startTime%20ge%20'" + date + "'" |
| 501 | + my_url = "https://global.api.greenlake.hpe.com/audit-log/v1/logs?filter=startTime%20ge%20'" + date + "'" |
502 | 502 |
|
503 | 503 | # Fetch audit logs since last minute
|
504 | 504 | response = requests.get(url=my_url, headers=my_headers)
|
|
0 commit comments