-
Notifications
You must be signed in to change notification settings - Fork 55
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
Gnocchi: implement resource types List method #55
Gnocchi: implement resource types List method #55
Conversation
Add new resourcetypes package with List method. Add tests and a documentation example.
e497b0f
to
03a74c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ozerovandrei I apologize for the delay.
I've left one inline comment. In addition, I think the Attribute
type might need some changes. According to the REST API docs there are a set amount of "types": string, bool, number, etc. This is reflected in the code, too:
- https://github.com/gnocchixyz/gnocchi/blob/stable/4.2/gnocchi/resource_type.py#L132
- https://github.com/gnocchixyz/gnocchi/blob/stable/4.2/gnocchi/resource_type.py#L164
Each type can have different attributes. For example, a "number" type has min
and max
but a "string" does not.
I wonder if it would be best to model Attribute
like:
type Attribute {
Type string
Required bool
Extra map[string]interface{}
}
Thoughts?
} | ||
|
||
// ResourceTypeAttribute represents single attribute of a Gnocchi resource type. | ||
type ResourceTypeAttribute struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this Attribute
?
Sounds good. Another option is to leave |
Rename resource type attributes to Attributes struct, use cutom field "Extra" with map[string]interface{} type instead of different fields. Those fields will be different for different attribute types.
@jtopjian I made changes related to Attribute field. I think that it's better to have at least |
@ozerovandrei This still felt a little strange to me and then I realized it is because we're trying to convert a map of values into an array. How about something like this: jtopjian@89b3bbb |
@jtopjian it's because I've tried to do a very strong structure types without any maps from the beginning of that PR. Some Go developer told me to so so once: #issuecomment-362023884 😉 But yeah, I can change this, why not. |
That discussion is still applicable. :) What I'm proposing is modeling the data in its normal map/object/hash/dict form and not coalescing it into an array/list/slice. |
Migrate from list to map representation for the attribute details to make it more similar to the actual Gnocchi response JSON.
@jtopjian I thought about it and I think that your variant is better, because it looks more similar to actual Gnocchi response structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@ozerovandrei Just to confirm: you're finished with this and it's mergeable? |
@jtopjian yes, it is ready. |
Add new resourcetypes package with List method.
Add tests and a documentation example.
Code references:
https://github.com/gnocchixyz/gnocchi/blob/stable/4.2/gnocchi/rest/api.py#L953
https://github.com/gnocchixyz/gnocchi/blob/stable/4.2/gnocchi/indexer/sqlalchemy.py#L485
https://github.com/gnocchixyz/gnocchi/blob/stable/4.2/gnocchi/resource_type.py#L264
For #54