Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
[AutoPR automation/resource-manager] Reverting the schedule.json resp…
Browse files Browse the repository at this point in the history
…onse code for Created to 201 as that … (#3075)

* Generated from 04307357a8675aa7b96a0b884d10d4fccd39cf24

Reverting the schedule.json response code for Created to 201 as that conforms with our Web Service API

* Generated from 2e54eec23745555508e8b186aab2cf152eee40de

Also added dummy 200 response for idempotency
  • Loading branch information
AutorestCI authored Jun 28, 2018
1 parent 6784e47 commit 5134154
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function _createOrUpdate(resourceGroupName, automationAccountName, scheduleName,
return callback(err);
}
let statusCode = response.statusCode;
if (statusCode !== 200 && statusCode !== 409) {
if (statusCode !== 200 && statusCode !== 201 && statusCode !== 409) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
Expand Down Expand Up @@ -225,6 +225,23 @@ function _createOrUpdate(resourceGroupName, automationAccountName, scheduleName,
return callback(deserializationError);
}
}
// Deserialize Response
if (statusCode === 201) {
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['Schedule']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError1.request = msRest.stripRequest(httpRequest);
deserializationError1.response = msRest.stripResponse(response);
return callback(deserializationError1);
}
}

return callback(null, result, httpRequest, response);
});
Expand Down

0 comments on commit 5134154

Please sign in to comment.