Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby] Adding resource group accessor to all the resources #1668

Closed

Conversation

sarangan12
Copy link
Member

@sarangan12 sarangan12 commented Dec 7, 2016

@azuresdkci
Copy link

Can one of the admins verify this patch?

@azurecla
Copy link

azurecla commented Dec 7, 2016

Hi @sarangan12, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!


It looks like you're working at Microsoft (sarajama). If you're full-time, we DON'T require a contribution license agreement.



If you are a vendor, DO please sign the electronic contribution license agreement. It will take 2 minutes and there's no faxing! https://cla.azure.com.

TTYL, AZPRBOT;

@sarangan12 sarangan12 changed the title Adding resource group accessor to all the resources (Not ready for review yet)Adding resource group accessor to all the resources Dec 7, 2016
@sarangan12 sarangan12 force-pushed the AddResourceGroupToResources branch 3 times, most recently from 9810e67 to 99d335c Compare December 13, 2016 22:42
@sarangan12 sarangan12 changed the title (Not ready for review yet)Adding resource group accessor to all the resources Adding resource group accessor to all the resources Dec 13, 2016
if (type is CompositeType)
{
var composite = type as CompositeType;
if (composite.BaseModelType != null && composite.BaseModelType.Name == "Resource")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked offline about the hard-coded string "resource_group_name" and I'm not sure of a way of obtaining this as a variable (for it not to be hard-coded), it seems to be a convention for it to be named that way, so it's probably ok.

Though, should these lines be added to the code only if "resource_group_name" is one of the parameters of the method in which we're adding them? (as that's where the value is coming from)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would be in a much bigger trouble if anyone changes this name. Also, this name is actually hardcoded already in Swagger parser. Also, remember the defined? has been added as a safeguard to avoid any issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, though with this question I was wondering if we could avoid writing these lines of code in the file if there's no resource_group_name coming as parameter of the method. For example the following operation would end up with this added line of code, but it really doesn't apply to the method. Operation: https://github.com/Azure/azure-rest-api-specs/blob/master/arm-compute/2016-03-30/swagger/compute.json#L294, which in generated code looks like this https://github.com/Azure/azure-sdk-for-ruby/blob/master/management/azure_mgmt_compute/lib/generated/azure_mgmt_compute/virtual_machine_extension_images.rb#L163
I understand it would still work because the property is not defined, but it's really not applicable.

@@ -606,6 +606,16 @@ public string GetDeserializationString(IModelType type, string valueReference =
builder.AppendLine("{1} = @client.deserialize(result_mapper, {0}, '{1}')", responseVariable, valueReference);
}

if (type is CompositeType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this added code be only applicable to Azure related methods? If so, should this be part of AutoRest.Ruby.Azure, instead of AutoRest.Ruby?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that the resource group is an azure concept. Thanks for pointing that. I have changed the code with the latest commit

@veronicagg
Copy link
Contributor

Also, please regenerate AutoRest samples with the change.

@sarangan12
Copy link
Member Author

@veronicagg Regenerated samples using gulp regenerate:expected:samples command

@veronicagg veronicagg changed the title Adding resource group accessor to all the resources [Ruby] Adding resource group accessor to all the resources Dec 19, 2016
{
var builder = new IndentedStringBuilder(" ");

string deserializedString = base.GetDeserializationString(type, valueReference, responseVariable);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be calling super(type, valueReference, responseVariable) ? is there a difference in doing super vs base.method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base is used in C#. not super

if (type is CompositeType)
{
var composite = type as CompositeType;
if (composite.BaseModelType != null && composite.BaseModelType.Name == "Resource")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, though with this question I was wondering if we could avoid writing these lines of code in the file if there's no resource_group_name coming as parameter of the method. For example the following operation would end up with this added line of code, but it really doesn't apply to the method. Operation: https://github.com/Azure/azure-rest-api-specs/blob/master/arm-compute/2016-03-30/swagger/compute.json#L294, which in generated code looks like this https://github.com/Azure/azure-sdk-for-ruby/blob/master/management/azure_mgmt_compute/lib/generated/azure_mgmt_compute/virtual_machine_extension_images.rb#L163
I understand it would still work because the property is not defined, but it's really not applicable.

Copy link
Contributor

@veronicagg veronicagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few more comments.

@fearthecowboy
Copy link
Member

@azuresdkci retest this please

@sarangan12
Copy link
Member Author

This PR is no longer required. Closing this now.

@sarangan12 sarangan12 closed this Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants