Skip to content

Commit

Permalink
fixed setting default value for a complex object containing constant …
Browse files Browse the repository at this point in the history
…properties.
  • Loading branch information
amarzavery committed Apr 28, 2016
1 parent f82044b commit 7750284
Show file tree
Hide file tree
Showing 13 changed files with 1,464 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,52 @@ export interface LROSADs {
beginPutNonRetry201Creating400(options: { product? : models.Product, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.Product>): void;
beginPutNonRetry201Creating400(callback: ServiceCallback<models.Product>): void;

/**
* Long running put request, service returns a Product with
* 'ProvisioningState' = 'Creating' and 201 response code
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.product] Product to put
*
* @param {string} [options.product.provisioningState]
*
* @param {object} [options.product.tags]
*
* @param {string} [options.product.location] Resource Location
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [callback] callback function; see ServiceCallback
* doc in ms-rest index.d.ts for details
*/
putNonRetry201Creating400InvalidJson(options: { product? : models.Product, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.Product>): void;
putNonRetry201Creating400InvalidJson(callback: ServiceCallback<models.Product>): void;

/**
* Long running put request, service returns a Product with
* 'ProvisioningState' = 'Creating' and 201 response code
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.product] Product to put
*
* @param {string} [options.product.provisioningState]
*
* @param {object} [options.product.tags]
*
* @param {string} [options.product.location] Resource Location
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [callback] callback function; see ServiceCallback
* doc in ms-rest index.d.ts for details
*/
beginPutNonRetry201Creating400InvalidJson(options: { product? : models.Product, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.Product>): void;
beginPutNonRetry201Creating400InvalidJson(callback: ServiceCallback<models.Product>): void;

/**
* Long running put request, service returns a 200 with
* ProvisioningState=’Creating’. Poll the endpoint indicated in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,255 @@ LROSADs.prototype.beginPutNonRetry201Creating400 = function (options, callback)
});
};

/**
*
* Long running put request, service returns a Product with
* 'ProvisioningState' = 'Creating' and 201 response code
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.product] Product to put
*
* @param {string} [options.product.provisioningState]
*
* @param {object} [options.product.tags]
*
* @param {string} [options.product.location] Resource Location
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {object} [result] - The deserialized result object.
* See {@link Product} for more information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
LROSADs.prototype.putNonRetry201Creating400InvalidJson = function (options, callback) {
var client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}

if (!callback) {
throw new Error('callback cannot be null.');
}

// Send request
this.beginPutNonRetry201Creating400InvalidJson(options, function (err, parsedResult, httpRequest, response){
if (err) return callback(err);

var initialResult = new msRest.HttpOperationResponse();
initialResult.request = httpRequest;
initialResult.response = response;
initialResult.body = response.body;
client.getPutOrPatchOperationResult(initialResult, options, function (err, pollingResult) {
if (err) return callback(err);

// Create Result
var result = null;
httpRequest = pollingResult.request;
response = pollingResult.response;
var responseBody = pollingResult.body;
if (responseBody === '') responseBody = null;

// Deserialize Response
var parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
var resultMapper = new client.models['Product']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}

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

/**
* Long running put request, service returns a Product with
* 'ProvisioningState' = 'Creating' and 201 response code
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.product] Product to put
*
* @param {string} [options.product.provisioningState]
*
* @param {object} [options.product.tags]
*
* @param {string} [options.product.location] Resource Location
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {object} [result] - The deserialized result object.
* See {@link Product} for more information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
LROSADs.prototype.beginPutNonRetry201Creating400InvalidJson = function (options, callback) {
var client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
var product = (options && options.product !== undefined) ? options.product : undefined;
// Validate
try {
if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
throw new Error('this.client.acceptLanguage must be of type string.');
}
} catch (error) {
return callback(error);
}

// Construct URL
var requestUrl = this.client.baseUri +
'//lro/nonretryerror/put/201/creating/400/invalidjson';
var queryParameters = [];
if (queryParameters.length > 0) {
requestUrl += '?' + queryParameters.join('&');
}
// trim all duplicate forward slashes in the url
var regex = /([^:]\/)\/+/gi;
requestUrl = requestUrl.replace(regex, '$1');

// Create HTTP transport objects
var httpRequest = new WebResource();
httpRequest.method = 'PUT';
httpRequest.headers = {};
httpRequest.url = requestUrl;
// Set Headers
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
}
if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
httpRequest.headers['accept-language'] = this.client.acceptLanguage;
}
if(options) {
for(var headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
}
}
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
// Serialize Request
var requestContent = null;
var requestModel = null;
try {
if (product !== null && product !== undefined) {
var requestModelMapper = new client.models['Product']().mapper();
requestModel = client.serialize(requestModelMapper, product, 'product');
requestContent = JSON.stringify(requestModel);
}
} catch (error) {
var serializationError = new Error(util.format('Error "%s" occurred in serializing the ' +
'payload - "%s"', error.message, util.inspect(product, {depth: null})));
return callback(serializationError);
}
httpRequest.body = requestContent;
// Send Request
return client.pipeline(httpRequest, function (err, response, responseBody) {
if (err) {
return callback(err);
}
var statusCode = response.statusCode;
if (statusCode !== 200 && statusCode !== 201) {
var error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
error.response = msRest.stripResponse(response);
if (responseBody === '') responseBody = null;
var parsedErrorResponse;
try {
parsedErrorResponse = JSON.parse(responseBody);
if (parsedErrorResponse) {
if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
}
if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
var resultMapper = new client.models['CloudError']().mapper();
error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
}
} catch (defaultError) {
error.message = util.format('Error "%s" occurred in deserializing the responseBody ' +
'- "%s" for the default response.', defaultError.message, responseBody);
return callback(error);
}
return callback(error);
}
// Create Result
var result = null;
if (responseBody === '') responseBody = null;
// Deserialize Response
if (statusCode === 200) {
var parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
var resultMapper = new client.models['Product']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}
}
// Deserialize Response
if (statusCode === 201) {
var parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
var resultMapper = new client.models['Product']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
var deserializationError1 = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
deserializationError1.request = msRest.stripRequest(httpRequest);
deserializationError1.response = msRest.stripResponse(response);
return callback(deserializationError1);
}
}

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

/**
*
* Long running put request, service returns a 200 with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,62 @@ export interface IntModel {
*/
putMin64(intBody: number, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<void>): void;
putMin64(intBody: number, callback: ServiceCallback<void>): void;

/**
* Get datetime encoded as Unix time value
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [callback] callback function; see ServiceCallback
* doc in ms-rest index.d.ts for details
*/
getUnixTime(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<number>): void;
getUnixTime(callback: ServiceCallback<number>): void;

/**
* Put datetime encoded as Unix time
*
* @param {number} intBody
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [callback] callback function; see ServiceCallback
* doc in ms-rest index.d.ts for details
*/
putUnixTimeDate(intBody: number, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<void>): void;
putUnixTimeDate(intBody: number, callback: ServiceCallback<void>): void;

/**
* Get invalid Unix time value
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [callback] callback function; see ServiceCallback
* doc in ms-rest index.d.ts for details
*/
getInvalidUnixTime(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<number>): void;
getInvalidUnixTime(callback: ServiceCallback<number>): void;

/**
* Get null Unix time value
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [callback] callback function; see ServiceCallback
* doc in ms-rest index.d.ts for details
*/
getNullUnixTime(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<number>): void;
getNullUnixTime(callback: ServiceCallback<number>): void;
}
Loading

0 comments on commit 7750284

Please sign in to comment.