|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +''' |
| 3 | +# Copyright (c) 2015 Microsoft Corporation |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in |
| 13 | +# all copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 21 | +# THE SOFTWARE. |
| 22 | +# |
| 23 | +# This file was generated and any changes will be overwritten. |
| 24 | +''' |
| 25 | + |
| 26 | +from __future__ import unicode_literals |
| 27 | +from ..request.drives_collection import DrivesCollectionRequestBuilder |
| 28 | +from ..request.shares_collection import SharesCollectionRequestBuilder |
| 29 | +import sys |
| 30 | + |
| 31 | + |
| 32 | +class OneDriveClient(object): |
| 33 | + |
| 34 | + def __init__(self, base_url, auth_provider, http_provider, loop=None): |
| 35 | + """Initialize the :class:`OneDriveClient` to be |
| 36 | + used for all OneDrive API interactions |
| 37 | + |
| 38 | + Args: |
| 39 | + base_url (str): The OneDrive base url to use for API interactions |
| 40 | + auth_provider(:class:`AuthProviderBase<onedrivesdk.auth_provider_base.AuthProviderBase>`): |
| 41 | + The authentication provider used by the client to auth |
| 42 | + with OneDrive services |
| 43 | + http_provider(:class:`HttpProviderBase<onedrivesdk.http_provider_base.HttpProviderBase>`): |
| 44 | + The HTTP provider used by the client to send all |
| 45 | + requests to OneDrive |
| 46 | + loop (BaseEventLoop): Default to None, the AsyncIO loop |
| 47 | + to use for all async requests |
| 48 | + """ |
| 49 | + self.base_url = base_url |
| 50 | + self.auth_provider = auth_provider |
| 51 | + self.http_provider = http_provider |
| 52 | + |
| 53 | + if sys.version_info >= (3, 4, 0): |
| 54 | + import asyncio |
| 55 | + self._loop = loop if loop else asyncio.get_event_loop() |
| 56 | + |
| 57 | + @property |
| 58 | + def auth_provider(self): |
| 59 | + """Gets and sets the client auth provider |
| 60 | + |
| 61 | + Returns: |
| 62 | + :class:`AuthProviderBase<onedrivesdk.auth_provider_base.AuthProviderBase>`: |
| 63 | + The authentication provider |
| 64 | + """ |
| 65 | + return self._auth_provider |
| 66 | + |
| 67 | + @auth_provider.setter |
| 68 | + def auth_provider(self, value): |
| 69 | + self._auth_provider = value |
| 70 | + |
| 71 | + @property |
| 72 | + def http_provider(self): |
| 73 | + """Gets and sets the client HTTP provider |
| 74 | +
|
| 75 | + Returns: |
| 76 | + :class:`HttpProviderBase<onedrivesdk.http_provider_base.HttpProviderBase>`: |
| 77 | + The HTTP provider |
| 78 | + """ |
| 79 | + return self._http_provider |
| 80 | + |
| 81 | + @http_provider.setter |
| 82 | + def http_provider(self, value): |
| 83 | + self._http_provider = value |
| 84 | + |
| 85 | + @property |
| 86 | + def base_url(self): |
| 87 | + """Gets and sets the base URL used by the client to make requests |
| 88 | +
|
| 89 | + Returns: |
| 90 | + str: The base URL |
| 91 | + """ |
| 92 | + return self._base_url |
| 93 | + |
| 94 | + @base_url.setter |
| 95 | + def base_url(self, value): |
| 96 | + self._base_url = value |
| 97 | + |
| 98 | + @property |
| 99 | + def drives(self): |
| 100 | + """Get the DrivesCollectionRequestBuilder for constructing requests |
| 101 | + |
| 102 | + Returns: |
| 103 | + :class:`DrivesCollectionRequestBuilder<onedrivesdk.request.drives_collection.DrivesCollectionRequestBuilder>`: |
| 104 | + The DrivesCollectionRequestBuilder to return |
| 105 | + """ |
| 106 | + return DrivesCollectionRequestBuilder(self.base_url + "drives", self) |
| 107 | + |
| 108 | + @property |
| 109 | + def shares(self): |
| 110 | + """Get the SharesCollectionRequestBuilder for constructing requests |
| 111 | + |
| 112 | + Returns: |
| 113 | + :class:`SharesCollectionRequestBuilder<onedrivesdk.request.shares_collection.SharesCollectionRequestBuilder>`: |
| 114 | + The SharesCollectionRequestBuilder to return |
| 115 | + """ |
| 116 | + return SharesCollectionRequestBuilder(self.base_url + "shares", self) |
0 commit comments