Visual FoxPro Google Cloud Storage: Delete Bucket

Back to Index

Permanently deletes an empty bucket. The path parameter is the name of the bucket to delete. In this example, we are deleting the bucket "chilkat-test-bucket". Success is indicated by a 204 response status code with an empty response body.

Documentation: https://cloud.google.com/storage/docs/json_api/v1/buckets/delete

CURL Command

curl -X DELETE https://www.googleapis.com/storage/v1/b/chilkat-test-bucket?project=MY_CLOUD_STORAGE_PROJECT \
    --header "Authorization: Bearer CLOUD_STORAGE_TOKEN"

Visual FoxPro Example

LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody
LOCAL lnRespStatusCode

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://www.googleapis.com/storage/v1/b/chilkat-test-bucket?project=MY_CLOUD_STORAGE_PROJECT
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("www.googleapis.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

loRest.AddHeader("Authorization","Bearer CLOUD_STORAGE_TOKEN")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("DELETE","/storage/v1/b/chilkat-test-bucket?project=MY_CLOUD_STORAGE_PROJECT",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

lnRespStatusCode = loRest.ResponseStatusCode
IF (lnRespStatusCode >= 400) THEN
    ? "Response Status Code = " + STR(lnRespStatusCode)
    ? "Response Header:"
    ? loRest.ResponseHeader
    ? "Response Body:"
    ? loSbResponseBody.GetAsString()
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

RELEASE loRest
RELEASE loSbResponseBody