-
Notifications
You must be signed in to change notification settings - Fork 220
Cloneable #154
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
Merged
Cloneable #154
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
4e5f9d5
Add a Cloneable interface
08920dc
Make BaseEndpoint implement Cloneable interface
4c513f6
Add api_call_decorator
e630272
- Make BoxSession store default network request args
7adfe04
Make all smart objects cloneable and use api_call decorator
db86f40
Use api_call decorator on all API call methods
0496cec
Add Item unit test with api_call decorator.
7ed337d
Add functional tests that test cloning.
9eef7e8
Clean up.
434d65e
Add api_call decorator to BaseObject's delete method.
1ea2982
Move Cloneable to its own file.
8037373
Add api_call decorators in Client.
360fd71
Add api_call decorator more BaseObject methods.
aa85abb
Remove unnecessary api_call decorator.
6cc1aef
Add a Cloneable interface
299c3b4
Make BaseEndpoint implement Cloneable interface
124d8dd
Add api_call_decorator
a7e152a
- Make BoxSession store default network request args
a667568
Make all smart objects cloneable and use api_call decorator
5702999
Use api_call decorator on all API call methods
9aba4e9
Add Item unit test with api_call decorator.
f0febe2
Add functional tests that test cloning.
015ddeb
Clean up.
14f6f8a
Add api_call decorator to BaseObject's delete method.
f41d2d3
Move Cloneable to its own file.
b7f190f
Add api_call decorators in Client.
ac209cc
Add api_call decorator more BaseObject methods.
dfc335e
Remove unnecessary api_call decorator.
df59b66
Merge branch 'cloneable' of https://github.com/box/box-python-sdk int…
dcf58bd
Fix linter errors.
c1e5e6b
Remove unused imports.
030a262
Clean up.
7e7117b
Remove unnecessary constructor override.
53ca0a7
Fix merge conflicts.
84940e3
Response to review comments.
8c17203
Response to review comments.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # coding: utf-8 | ||
|
|
||
| from __future__ import unicode_literals, absolute_import | ||
|
|
||
|
|
||
| class Cloneable(object): | ||
| """ | ||
| Cloneable interface to be implemented by endpoint objects that should have ability to be cloned, but with a | ||
| different session member if desired. | ||
| """ | ||
|
|
||
| def as_user(self, user): | ||
| """ | ||
| Returns a new endpoint object with default headers set up to make requests as the specified user. | ||
| :param user: | ||
| The user to impersonate when making API requests. | ||
| :type user: | ||
| :class:`User` | ||
| """ | ||
| return self.clone(self.session.as_user(user)) | ||
|
|
||
| def with_shared_link(self, shared_link, shared_link_password): | ||
| """ | ||
| Returns a new endpoint object with default headers set up to make requests using the shared link for auth. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sphinx needs blank lines between the title, and the rest of the docstring. This is fine for now, but we should probably do a test run of sphinx, and fix all the errors, before doing a release. |
||
| :param shared_link: | ||
| The shared link. | ||
| :type shared_link: | ||
| `unicode` | ||
| :param shared_link_password: | ||
| The password for the shared link. | ||
| :type shared_link_password: | ||
| `unicode` | ||
| """ | ||
| return self.clone(self.session.with_shared_link(shared_link, shared_link_password)) | ||
|
|
||
| def clone(self, session=None): | ||
| """ | ||
| Returns a copy of this cloneable object using the specified session. | ||
| :param session: | ||
| The Box session used to make requests. | ||
| :type session: | ||
| :class:`BoxSession` | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @property | ||
| def session(self): | ||
| """ | ||
| Return the Box session being used to make requests. | ||
| :rtype: | ||
| :class:`BoxSession` | ||
| """ | ||
| raise NotImplementedError | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
alphabetize