Skip to content

Compute v2: flavor access list#507

Merged
jrperritt merged 5 commits intogophercloud:masterfrom
jtopjian:computev2-flavor-access-list
Nov 4, 2017
Merged

Compute v2: flavor access list#507
jrperritt merged 5 commits intogophercloud:masterfrom
jtopjian:computev2-flavor-access-list

Conversation

@jtopjian
Copy link
Copy Markdown
Contributor

For #506

@jtopjian jtopjian requested a review from jrperritt August 28, 2017 20:00
@jtopjian
Copy link
Copy Markdown
Contributor Author

@jrperritt I have a question about the design of this kind of implementation:

This implements a "List" as it returns a list of results. To conform with other lists, I used the whole pagination thing, but with a single page, given there's never going to be more than one page of results.

SinglePage works well for this type of API call, and AllPages provides a nice shortcut, but it still seems a bit too much code for what it is:

allPages, err := flavors.ListAccess(client, foo).AllPages()
allAccess, err := flavors.ExtractAccess(allPages)

I could implement it this way:

allAccess, err := flavors.ListAccess(client, foo).Extract()

But using List in this context breaks a pattern.

Am I thinking too much into this? Is it better to deal with the extra few lines in favor of conformity?

@coveralls
Copy link
Copy Markdown

coveralls commented Aug 28, 2017

Coverage Status

Coverage increased (+0.01%) to 71.565% when pulling f3c0da5 on jtopjian:computev2-flavor-access-list into 31ccc1a on gophercloud:master.

@jtopjian jtopjian mentioned this pull request Aug 28, 2017
3 tasks
@jtopjian jtopjian changed the title Computev2 flavor access list Compute v2: flavor access list Aug 28, 2017
@jtopjian jtopjian force-pushed the computev2-flavor-access-list branch from f3c0da5 to ffbb371 Compare September 4, 2017 01:21
@jtopjian
Copy link
Copy Markdown
Contributor Author

jtopjian commented Sep 4, 2017

After mulling this over for a few days, I decided to not do the whole pagination thing. Happy to revert, though.

This is ready for review.

@coveralls
Copy link
Copy Markdown

coveralls commented Sep 4, 2017

Coverage Status

Coverage increased (+0.04%) to 71.59% when pulling ffbb371 on jtopjian:computev2-flavor-access-list into 2bf16b9 on gophercloud:master.

Copy link
Copy Markdown
Contributor

@dklyle dklyle left a comment

Choose a reason for hiding this comment

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

This matches the API and LGTM.

Copy link
Copy Markdown
Contributor

@jrperritt jrperritt left a comment

Choose a reason for hiding this comment

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

After that doc change, LGTM

}

// ListAccess retrieves details about tenant access to a flavor. Use
// ExtractAccess to convert its result into a FlavorAccess.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Extract

@jrperritt
Copy link
Copy Markdown
Contributor

jrperritt commented Nov 4, 2017

If there is no Get operation for this API, should we just make this operation the Get (but maybe named differently, e.g. GetAccessInfo)? The thing I noticed about this call that differentiates it is, to your point, it isn't really a "List" (as I see it), since it's specific to a single flavor.

@jtopjian
Copy link
Copy Markdown
Contributor Author

jtopjian commented Nov 4, 2017

Yeah, that's exactly what started the whole debate for me.

The way I see it, List is used for actions that contain more than one of something. Get is usually done to retrieve one resource. But I could just be making this more difficult than it needs to be.

@jtopjian
Copy link
Copy Markdown
Contributor Author

jtopjian commented Nov 4, 2017

Actually, nevermind. GetAccessInfo works. I'll redo.

edit: To add thought to this decision: I feel that having List closely associated with paging is a better pattern to adhere to.

@jrperritt
Copy link
Copy Markdown
Contributor

jrperritt commented Nov 4, 2017

Actually, I misread what you'd written originally. I thought you were saying the response will only ever be a single object (a slice of length at most 1), but maybe you were saying that a single-page response seems more like a Get operation? Looking at the OpenStack source, it looks like private flavors will return an entry for every project that can access that flavor.

If there can in fact be, say, hundreds of items coming back in the response, it does seem to me that ListAccesses would be most consistent (with an accompanying ExtractAccesses). But, to what I think is your point, a single-page operation could just as well be a seen as a Get.

@jtopjian
Copy link
Copy Markdown
Contributor Author

jtopjian commented Nov 4, 2017

but maybe you were saying that a single-page response seems more like a Get operation?

Yes, exactly.

Looking at the OpenStack source, it looks like private flavors will return an entry for every project that can access that flavor.

Yes, exactly again. To use a real-world context, $work has a series of g1.x flavors for GPU access. These flavors are given out upon request. So there is one access entry per tenant which will all be returned in this API call. It is not possible to return a single access entry.

If there can in fact be, say, hundreds of items coming back in the response, it does seem to me that ListAccesses would be most consistent (with an accompanying ExtractAccesses). But, to what I think is your point, a single-page operation could just as well be a seen as a Get.

Right, exactly. So which direction? :)

@jrperritt
Copy link
Copy Markdown
Contributor

Because there is precedent in this package, I'd say ListAccesses/ExtractAccesses, and we could discuss using Get-style logic for single-page operations in future packages.

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 4, 2017

Coverage Status

Coverage increased (+0.7%) to 72.277% when pulling b40a4aa on jtopjian:computev2-flavor-access-list into 2bf16b9 on gophercloud:master.

@jtopjian
Copy link
Copy Markdown
Contributor Author

jtopjian commented Nov 4, 2017

@jrperritt ping when you have time.

@jrperritt
Copy link
Copy Markdown
Contributor

jrperritt commented Nov 4, 2017

Sorry if I wasn't clear earlier: I think we should use pagination for this operation. That's what I meant by "there is precedence".

@jtopjian
Copy link
Copy Markdown
Contributor Author

jtopjian commented Nov 4, 2017

ahh - OK, no problem.

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 4, 2017

Coverage Status

Coverage increased (+0.6%) to 72.201% when pulling 666468f on jtopjian:computev2-flavor-access-list into 2bf16b9 on gophercloud:master.

@jtopjian
Copy link
Copy Markdown
Contributor Author

jtopjian commented Nov 4, 2017

@jrperritt How's this?

Copy link
Copy Markdown
Contributor

@jrperritt jrperritt left a comment

Choose a reason for hiding this comment

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

Great :)

@jrperritt jrperritt merged commit 9c81722 into gophercloud:master Nov 4, 2017
@jtopjian
Copy link
Copy Markdown
Contributor Author

jtopjian commented Nov 4, 2017

Thanks for your help on this!

@jtopjian jtopjian deleted the computev2-flavor-access-list branch April 24, 2018 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants