Skip to content

Commit

Permalink
Fix: #923
Browse files Browse the repository at this point in the history
* Fix: #923

* regenerate tests after sync
  • Loading branch information
begoldsm authored and amarzavery committed Apr 7, 2016
1 parent ab93a4a commit b73c784
Show file tree
Hide file tree
Showing 33 changed files with 85 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var clientOptions = {};

describe('nodejs', function () {
describe('Custom BaseUri Client', function () {
var testClient = new customBaseUriClient(credentials, 'host:3000', clientOptions);
clientOptions.host = 'host:3000';
var testClient = new customBaseUriClient(credentials, clientOptions);
it('should return 200', function (done) {
testClient.paths.getEmpty('local', function (error, result, request, response) {
should.not.exist(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ declare class AutoRestParameterizedHostTestClient {
*
* @param {credentials} credentials - Gets Azure subscription credentials.
*
* @param {string} host - A string value that is used as a global part of the parameterized host
*
* @param {object} [options] - The parameter options
*
* @param {Array} [options.filters] - Filters to be added to the request pipeline
Expand All @@ -30,14 +28,16 @@ declare class AutoRestParameterizedHostTestClient {
*
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
*
* @param {string} [options.host] - A string value that is used as a global part of the parameterized host
*
* @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response.
*
* @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.
*
* @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.
*
*/
constructor(credentials: ServiceClientCredentials, host: string, options: ServiceClientOptions);
constructor(credentials: ServiceClientCredentials, options: ServiceClientOptions);

credentials: ServiceClientCredentials;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ var operations = require('./operations');
*
* @param {credentials} credentials - Gets Azure subscription credentials.
*
* @param {string} host - A string value that is used as a global part of the parameterized host
*
* @param {object} [options] - The parameter options
*
* @param {Array} [options.filters] - Filters to be added to the request pipeline
Expand All @@ -40,34 +38,33 @@ var operations = require('./operations');
*
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
*
* @param {string} [options.host] - A string value that is used as a global part of the parameterized host
*
* @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response.
*
* @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.
*
* @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.
*
*/
function AutoRestParameterizedHostTestClient(credentials, host, options) {
function AutoRestParameterizedHostTestClient(credentials, options) {
this.host = 'host';
this.acceptLanguage = 'en-US';
this.longRunningOperationRetryTimeout = 30;
this.generateClientRequestId = true;
if (credentials === null || credentials === undefined) {
throw new Error('\'credentials\' cannot be null.');
}
if (host === null || host === undefined) {
throw new Error('\'host\' cannot be null.');
}

if (!options) options = {};

AutoRestParameterizedHostTestClient['super_'].call(this, credentials, options);
if (!this.baseUri) {
this.baseUri = 'http://{accountName}{host}';
}
this.baseUri = 'http://{accountName}{host}';
this.credentials = credentials;
this.host = host;

if(options.host !== null && options.host !== undefined) {
this.host = options.host;
}
if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
this.acceptLanguage = options.acceptLanguage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ var ServiceClient = msRestAzure.AzureServiceClient;
@:var operations = require('./operations');
}
@EmptyLine
@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant);}
@{var optionalParameters = Model.Properties.Where(p => !p.IsRequired && !p.IsConstant);}
@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue));}
@{var optionalParameters = Model.Properties.Where(p => (!p.IsRequired || p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)) && !p.IsConstant);}
/**
* @@class
* Initializes a new instance of the @Model.Name class.
Expand Down Expand Up @@ -73,7 +73,7 @@ var ServiceClient = msRestAzure.AzureServiceClient;
@: *
}
*/
function @(Model.Name)(@(Model.RequiredConstructorParameters), options) {
function @(Model.Name)(@(!string.IsNullOrEmpty(Model.RequiredConstructorParameters) ? Model.RequiredConstructorParameters + ", " : "")options) {
@foreach (var property in Model.Properties.Where(p => p.DefaultValue != null))
{
@:this.@(property.Name) = @(property.DefaultValue);
Expand All @@ -91,11 +91,16 @@ function @(Model.Name)(@(Model.RequiredConstructorParameters), options) {
@if(!Model.IsCustomBaseUri)
{
@:this.baseUri = baseUri;
@:if (!this.baseUri) {
@:this.baseUri = '@Model.BaseUrl';
@:}
}
else
{
@:this.baseUri = '@Model.BaseUrl';
}

if (!this.baseUri) {
this.baseUri = '@Model.BaseUrl';
}

@foreach (var param in requiredParameters)
{
@: this.@(param.Name) = @(param.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { ServiceClientOptions, RequestOptions, ServiceCallback, ServiceClientCre
}
@EmptyLine
declare class @(Model.Name) {
@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant);}
@{var optionalParameters = Model.Properties.Where(p => !p.IsRequired && !p.IsConstant);}
@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue));}
@{var optionalParameters = Model.Properties.Where(p => (!p.IsRequired || p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)) && !p.IsConstant);}
/**
* @@class
* Initializes a new instance of the @Model.Name class.
Expand Down Expand Up @@ -52,7 +52,7 @@ declare class @(Model.Name) {
@: *
}
*/
constructor(@(Model.RequiredConstructorParametersTS), options: ServiceClientOptions);
constructor(@(!string.IsNullOrEmpty(Model.RequiredConstructorParametersTS) ? Model.RequiredConstructorParametersTS + ", " : "")options: ServiceClientOptions);

@foreach (var property in Model.Properties)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ describe('nodejs', function () {

describe('Swagger BAT', function () {
describe('Custom BaseUri Client', function () {
var testClient = new customBaseUriClient('host:3000', clientOptions);
var customOptions = {
host: 'host:3000'
};
var testClient = new customBaseUriClient(customOptions);
it('should return 200', function (done) {
testClient.paths.getEmpty('local', function (error, result, request, response) {
should.not.exist(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ declare class AutoRestParameterizedHostTestClient {
* Initializes a new instance of the AutoRestParameterizedHostTestClient class.
* @constructor
*
* @param {string} host - A string value that is used as a global part of the parameterized host
*
* @param {object} [options] - The parameter options
*
* @param {Array} [options.filters] - Filters to be added to the request pipeline
Expand All @@ -28,8 +26,10 @@ declare class AutoRestParameterizedHostTestClient {
*
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
*
* @param {string} [options.host] - A string value that is used as a global part of the parameterized host
*
*/
constructor(host: string, options: ServiceClientOptions);
constructor(options: ServiceClientOptions);

host: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ var operations = require('./operations');
* Initializes a new instance of the AutoRestParameterizedHostTestClient class.
* @constructor
*
* @param {string} host - A string value that is used as a global part of the parameterized host
*
* @param {object} [options] - The parameter options
*
* @param {Array} [options.filters] - Filters to be added to the request pipeline
Expand All @@ -37,21 +35,20 @@ var operations = require('./operations');
*
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
*
* @param {string} [options.host] - A string value that is used as a global part of the parameterized host
*
*/
function AutoRestParameterizedHostTestClient(host, options) {
function AutoRestParameterizedHostTestClient(options) {
this.host = 'host';
if (host === null || host === undefined) {
throw new Error('\'host\' cannot be null.');
}

if (!options) options = {};

AutoRestParameterizedHostTestClient['super_'].call(this, null, options);
if (!this.baseUri) {
this.baseUri = 'http://{accountName}{host}';
}
this.host = host;
this.baseUri = 'http://{accountName}{host}';

if(options.host !== null && options.host !== undefined) {
this.host = options.host;
}
this.paths = new operations.Paths(this);
this.models = models;
msRest.addSerializationMixin(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,18 @@ public string RequiredConstructorParameters
get
{
var requireParams = new List<string>();
this.Properties.Where(p => p.IsRequired && !p.IsConstant)
this.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue))
.ForEach(p => requireParams.Add(p.Name.ToCamelCase()));
if (!IsCustomBaseUri)
{
requireParams.Add("baseUri");
}

if(requireParams == null || requireParams.Count == 0)
{
return string.Empty;
}

return string.Join(", ", requireParams);
}
}
Expand All @@ -174,7 +179,7 @@ public string RequiredConstructorParametersTS {

bool first = true;
foreach (var p in this.Properties) {
if (!p.IsRequired || p.IsConstant)
if (!p.IsRequired || p.IsConstant || (p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)))
continue;

if (!first)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ var ServiceClient = msRest.ServiceClient;
@:var operations = require('./operations');
}
@EmptyLine
@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant);}
@{var optionalParameters = Model.Properties.Where(p => !p.IsRequired && !p.IsConstant);}
@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue));}
@{var optionalParameters = Model.Properties.Where(p => (!p.IsRequired || p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)) && !p.IsConstant);}
/**
* @@class
* Initializes a new instance of the @Model.Name class.
Expand Down Expand Up @@ -71,7 +71,7 @@ var ServiceClient = msRest.ServiceClient;
@: *
}
*/
function @(Model.Name)(@(Model.RequiredConstructorParameters), options) {
function @(Model.Name)(@(!string.IsNullOrEmpty(Model.RequiredConstructorParameters) ? Model.RequiredConstructorParameters + ", ": "")options) {
@foreach (var property in Model.Properties.Where(p => p.DefaultValue != null))
{
@:this.@(property.Name) = @(property.DefaultValue);
Expand All @@ -91,11 +91,17 @@ function @(Model.Name)(@(Model.RequiredConstructorParameters), options) {
@if(!Model.IsCustomBaseUri)
{
@:this.baseUri = baseUri;

@:if (!this.baseUri) {
@:this.baseUri = '@Model.BaseUrl';
@:}
}
else
{
@:this.baseUri = '@Model.BaseUrl';
}

if (!this.baseUri) {
this.baseUri = '@Model.BaseUrl';
}


@foreach (var param in requiredParameters)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { ServiceClientOptions, RequestOptions, ServiceCallback } from 'ms-rest';
}
@EmptyLine
declare class @(Model.Name) {
@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant);}
@{var optionalParameters = Model.Properties.Where(p => !p.IsRequired && !p.IsConstant);}
@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue));}
@{var optionalParameters = Model.Properties.Where(p => (!p.IsRequired || p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)) && !p.IsConstant);}
/**
* @@class
* Initializes a new instance of the @Model.Name class.
Expand Down Expand Up @@ -52,7 +52,7 @@ declare class @(Model.Name) {
@: *
}
*/
constructor(@(Model.RequiredConstructorParametersTS), options: ServiceClientOptions);
constructor(@(!string.IsNullOrEmpty(Model.RequiredConstructorParametersTS) ? Model.RequiredConstructorParametersTS + ", ": "")options: ServiceClientOptions);

@foreach (var property in Model.Properties)
{
Expand Down
2 changes: 1 addition & 1 deletion Samples/azure-storage/Azure.Python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.1.0", "msrestazure>=0.1.0"]
REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CheckNameAvailabilityResult(Model):
'message': {'key': 'message', 'type': 'str'},
}

def __init__(self, name_available=None, reason=None, message=None, **kwargs):
def __init__(self, name_available=None, reason=None, message=None):
self.name_available = name_available
self.reason = reason
self.message = message
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ class CustomDomain(Model):
'use_sub_domain': {'key': 'useSubDomain', 'type': 'bool'},
}

def __init__(self, name, use_sub_domain=None, **kwargs):
def __init__(self, name, use_sub_domain=None):
self.name = name
self.use_sub_domain = use_sub_domain
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Endpoints(Model):
'file': {'key': 'file', 'type': 'str'},
}

def __init__(self, blob=None, queue=None, table=None, file=None, **kwargs):
def __init__(self, blob=None, queue=None, table=None, file=None):
self.blob = blob
self.queue = queue
self.table = table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Resource(Model):
'tags': {'key': 'tags', 'type': '{str}'},
}

def __init__(self, id=None, name=None, type=None, location=None, tags=None, **kwargs):
def __init__(self, id=None, name=None, type=None, location=None, tags=None):
self.id = id
self.name = name
self.type = type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ class StorageAccount(Resource):
'properties': {'key': 'properties', 'type': 'StorageAccountProperties'},
}

def __init__(self, id=None, name=None, type=None, location=None, tags=None, properties=None, **kwargs):
super(StorageAccount, self).__init__(id=id, name=name, type=type, location=location, tags=tags, **kwargs)
def __init__(self, id=None, name=None, type=None, location=None, tags=None, properties=None):
super(StorageAccount, self).__init__(id=id, name=name, type=type, location=location, tags=tags)
self.properties = properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ class StorageAccountCheckNameAvailabilityParameters(Model):
'type': {'key': 'type', 'type': 'str'},
}

def __init__(self, name, type="Microsoft.Storage/storageAccounts", **kwargs):
def __init__(self, name, type="Microsoft.Storage/storageAccounts"):
self.name = name
self.type = type
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class StorageAccountCreateParameters(Model):
'properties': {'key': 'properties', 'type': 'StorageAccountPropertiesCreateParameters'},
}

def __init__(self, location, tags=None, properties=None, **kwargs):
def __init__(self, location, tags=None, properties=None):
self.location = location
self.tags = tags
self.properties = properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class StorageAccountKeys(Model):
'key2': {'key': 'key2', 'type': 'str'},
}

def __init__(self, key1=None, key2=None, **kwargs):
def __init__(self, key1=None, key2=None):
self.key1 = key1
self.key2 = key2
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class StorageAccountProperties(Model):
'secondary_endpoints': {'key': 'secondaryEndpoints', 'type': 'Endpoints'},
}

def __init__(self, provisioning_state=None, account_type=None, primary_endpoints=None, primary_location=None, status_of_primary=None, last_geo_failover_time=None, secondary_location=None, status_of_secondary=None, creation_time=None, custom_domain=None, secondary_endpoints=None, **kwargs):
def __init__(self, provisioning_state=None, account_type=None, primary_endpoints=None, primary_location=None, status_of_primary=None, last_geo_failover_time=None, secondary_location=None, status_of_secondary=None, creation_time=None, custom_domain=None, secondary_endpoints=None):
self.provisioning_state = provisioning_state
self.account_type = account_type
self.primary_endpoints = primary_endpoints
Expand Down
Loading

0 comments on commit b73c784

Please sign in to comment.