-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add AdminOrgVdcStorageProfile for querying #375
Conversation
Added: - QueryResultAdminOrgVdcStorageProfileRecordType type. - Constants for querying: QtOrgVdcStorageProfile and QtAdminOrgVdcStorageProfile. - Funcs for querying : QueryAdminOrgVdcStorageProfileByID and QueryOrgVdcStorageProfileByID. QueryOrgVdcStorageProfileByID (non Admin) not workin (tested wiht vCloud 10.0 and 10.2.2). May be query isn't correct.
@lelvisl, VMware has approved your signed contributor license agreement. |
|
Can we merge this PR or we need to discuss something? |
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.
Sorry for this drag. Going for review and testing.
Would you be able to add a line to CHANGELOG.md
about this?
Also - any chances you could put a few tests into system_test.go
(there are quite a few similar ones if you need inspiration :))
- corrected review notes - added point to changelog - update test suit and add test
Thanks for your review! Can you look again please? |
govcd/system.go
Outdated
@@ -975,3 +975,29 @@ func (vcdCli *VCDClient) GetOrgList() (*types.OrgList, error) { | |||
} | |||
return orgList, nil | |||
} | |||
|
|||
// QueryAdminOrgVdcStorageProfileByID finds a StorageProfile of VDC by ID as admin | |||
func QueryAdminOrgVdcStorageProfileByID(vcdCli *VCDClient, id string) ([]*types.QueryResultAdminOrgVdcStorageProfileRecordType, error) { |
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.
Thanks for this. Now just pardon, but I just tried to play with code and one thing hit me.
I think the signature could be:
func QueryAdminOrgVdcStorageProfileByID(vcdCli *VCDClient, id string) ([]*types.QueryResultAdminOrgVdcStorageProfileRecordType, error) { | |
func QueryAdminOrgVdcStorageProfileByID(vcdCli *VCDClient, id string) (*types.QueryResultAdminOrgVdcStorageProfileRecordType, error) { |
That is - you don't need to return a slice of results because you are querying by ID which guarantees that there is either exactly one result, or not.
A slice could be if it was QueryOrgVdcStorageProfile
which doesn't guarantee one object.
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 i then rename this method to GetAdminOrgVdcStorageProfileByID
?
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.
Or implement QueryOrgVdcStorageProfile
with params and GetAdminOrgVdcStorageProfileByID
that use previous?
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.
GetX
in this SDK usually mean that it is not an object from query endpoint, but from its legitimate endpoint (e.g. AdminOrg.GetVDCById
would not return a Query
result, but the VDC struct itself. Query and object endpoints usually return different data that is why we try to keep Query
and Get
(to differentiate these things). This is not 100% due to historic reasons, but that is a good thing to follow.
Or - if you want to implement a function that returns all objects then it could be QueryAdminOrgVdcStorageProfile
. But if you simply leave the code as it is (and not apply ID filter) you will hit a problem - by default it returns only the first page of data (which is usually up to 25 items). It is not easy to spot this on testing envs where not many resources exist, but we have already hit that and fixed some of the problems here. The trick here is to use client.cumulativeQuery
internally which handles pagination and makes sure all pages are retrieved. (You could look through functions like QueryEdgeGatewayList
or QueryAllVdcs
to see how it is implemented.)
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.
Agree with you and changed signature.
About QueryAdminOrgVdcStorageProfile
- i think we need separate issue for discuss.
Not sure if you saw that, but I put a comment: #375 (comment) |
…now returns only one vdcStorageProfile
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.
One last convenience spot from me and I agree QueryAdminOrgVdcStorageProfile
can be left for later on.
…nOrgVdcStorageProfileByID
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.
Thanks. Approved and I left two typo comments and will wait for other team members to have a glimpse before we can merge.
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 and thanks for contributing!
@dataclouder can you please review this PR? |
Another issue: You should merge your PR with master, as some important pieces are missing. When you run the test for |
…rofileRecord # Conflicts: # CHANGELOG.md
updated fields for QueryResultAdminOrgVdcStorageProfileRecordType and QueryResultOrgVdcStorageProfileRecordType add skip/error in case of Client.IsSysAdmin - vmware#384
@dataclouder i merged upstream into my brunch and updated all fields. About tests: |
How about this change? Close? Or you want this changes? If yes - please give some feedback. As i see - PR #393 doesn't solve this problem |
Issue: #373
Added:
QueryOrgVdcStorageProfileByID (non Admin) not workin (tested wiht vCloud 10.0 and 10.2.2).
May be query isn't correct.