зеркало из https://github.com/Azure/ARO-RP.git
return 202 on asynchronous delete
This commit is contained in:
Родитель
b2b3e7244f
Коммит
c6fdf76e2a
|
@ -1 +1 @@
|
|||
421387bfbb80fbff3e7be9efd3950a8d16f8798d3822ab8bf62710790c31ee59 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json
|
||||
e415fbc9dc6b340659832222d5874db3873b929fb47cdee8ef8d2a60f15622f0 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json
|
||||
|
|
1
Makefile
1
Makefile
|
@ -39,6 +39,7 @@ client: generate
|
|||
--output-folder=/python/client
|
||||
|
||||
sudo chown -R $(USER):$(USER) pkg/client python/client
|
||||
sed -i -e 's|azure/aro-rp|Azure/ARO-RP|g' pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/models.go pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/redhatopenshiftapi/interfaces.go
|
||||
rm -rf python/client/azure/mgmt/redhatopenshift/v2019_12_31_preview/aio
|
||||
>python/client/__init__.py
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ func (client OpenShiftClustersClient) DeleteResponder(resp *http.Response) (resu
|
|||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
|
|
|
@ -6,6 +6,7 @@ package frontend
|
|||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -23,9 +24,11 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/recover"
|
||||
)
|
||||
|
||||
type noContent struct{}
|
||||
type statusCodeError int
|
||||
|
||||
func (noContent) Error() string { return "" }
|
||||
func (err statusCodeError) Error() string {
|
||||
return fmt.Sprintf("%d", err)
|
||||
}
|
||||
|
||||
type frontend struct {
|
||||
baseLog *logrus.Entry
|
||||
|
@ -216,8 +219,8 @@ func reply(log *logrus.Entry, w http.ResponseWriter, b []byte, err error) {
|
|||
switch err := err.(type) {
|
||||
case *api.CloudError:
|
||||
api.WriteCloudError(w, err)
|
||||
case *noContent:
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
case statusCodeError:
|
||||
w.WriteHeader(int(err))
|
||||
default:
|
||||
log.Error(err)
|
||||
api.WriteError(w, http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Internal server error.")
|
||||
|
|
|
@ -19,8 +19,11 @@ func (f *frontend) deleteOpenShiftCluster(w http.ResponseWriter, r *http.Request
|
|||
_, err := f.db.OpenShiftClusters.Patch(r.URL.Path, func(doc *api.OpenShiftClusterDocument) error {
|
||||
return f._deleteOpenShiftCluster(doc)
|
||||
})
|
||||
if cosmosdb.IsErrorStatusCode(err, http.StatusNotFound) {
|
||||
err = &noContent{}
|
||||
switch {
|
||||
case cosmosdb.IsErrorStatusCode(err, http.StatusNotFound):
|
||||
err = statusCodeError(http.StatusNoContent)
|
||||
case err == nil:
|
||||
err = statusCodeError(http.StatusAccepted)
|
||||
}
|
||||
|
||||
reply(log, w, nil, err)
|
||||
|
|
|
@ -144,7 +144,7 @@ func populateTopLevelPaths(resourceProviderNamespace, resourceType, friendlyName
|
|||
Description: "Deletes a " + friendlyName + " with the specified subscription, resource group and resource name. The operation returns nothing.",
|
||||
OperationID: strings.Title(resourceType) + "s_Delete",
|
||||
Parameters: populateParameters(3, strings.Title(resourceType), friendlyName),
|
||||
Responses: populateResponses(strings.Title(resourceType), true, http.StatusOK, http.StatusNoContent),
|
||||
Responses: populateResponses(strings.Title(resourceType), true, http.StatusAccepted, http.StatusNoContent),
|
||||
LongRunningOperation: true,
|
||||
},
|
||||
Patch: &Operation{
|
||||
|
|
|
@ -377,7 +377,7 @@ class OpenShiftClustersOperations(object):
|
|||
request = self._client.delete(url, query_parameters, header_parameters)
|
||||
response = self._client.send(request, stream=False, **operation_config)
|
||||
|
||||
if response.status_code not in [200, 204]:
|
||||
if response.status_code not in [202, 204]:
|
||||
exp = CloudError(response)
|
||||
exp.request_id = response.headers.get('x-ms-request-id')
|
||||
raise exp
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"resourceName": "resourceName"
|
||||
},
|
||||
"responses": {
|
||||
"200": {},
|
||||
"202": {},
|
||||
"204": {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,8 +276,8 @@
|
|||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
"202": {
|
||||
"description": "Accepted"
|
||||
},
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
|
|
Загрузка…
Ссылка в новой задаче