diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 196a84ec..00000000 --- a/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -.git -*.pyc -__pycache__ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index a7a2389d..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Build - -on: - push: - branches: - - master - pull_request: - branches: - - master - -defaults: - run: - shell: bash - -jobs: - test: - name: pytest - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - run: pip install -r requirements.txt - - run: pytest - \ No newline at end of file diff --git a/.github/workflows/publish-to-github-releases.yml b/.github/workflows/publish-to-github-releases.yml deleted file mode 100644 index 5e4f6450..00000000 --- a/.github/workflows/publish-to-github-releases.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Publish to GitHub Releases - -on: - push: - tags: - - "v*.*.*" - -jobs: - build-n-publish-to-github: - name: Build and publish to GitHub Releases - runs-on: ubuntu-latest - steps: - - name: Publish to GitHub Releases - uses: softprops/action-gh-release@v1 - with: - # Use the newest commit message as the release description - body: ${{ github.event.head_commit.message }} diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml deleted file mode 100644 index c6aa1548..00000000 --- a/.github/workflows/publish-to-pypi.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI - -on: - release: - types: [published] - push: - tags: - - "v*.*.*" - -jobs: - build-n-publish-to-pypi: - name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.7 - uses: actions/setup-python@v3 - with: - python-version: 3.7 - - name: Install pypa/build - run: >- - python -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ - . - - name: Publish distribution 📦 to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c4fa9d5f..cf18b79f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,57 +1,59 @@ -name: Bump Version and Publish +name: Generate client library + Publish 📦 to PyPI + Publish to GitHub Releases on: workflow_dispatch: inputs: - bumpVersion: - description: Choose a version number to bump + version: required: true - type: choice - options: - - patch - - minor - - major jobs: - bump-semantic-versioning: - name: Bump the semantic versioning for the package + generate-python-library: + name: Generate python client library runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up Python 3.7 - uses: actions/setup-python@v4 + - uses: actions/setup-java@v3 with: - python-version: 3.7 - - name: Run deploy script + distribution: "temurin" + java-version: "17" + - name: Setup environment variables run: | - git config user.name github-actions - git config user.email github-actions@github.com - python deploy.py ${{ inputs.bumpVersion }} - publish-to-github: - needs: bump-semantic-versioning - name: Publish to GitHub Releases - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: master - - name: Get version tag - id: tag - run: echo "version=v$(cat VERSION)" >> $GITHUB_OUTPUT - - name: Print version tag - run: echo ${{ steps.tag.outputs.version }} - - name: Publish to GitHub Releases - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + echo "generator_version=3.0.46" >> "$GITHUB_ENV" + echo "generator_name=swagger-codegen-cli.jar" >> "$GITHUB_ENV" + echo "jar_asana=codegen/swagger/target/AsanaClientCodegen-swagger-codegen-1.0.0.jar" >> "$GITHUB_ENV" + echo "actual_lang=com.asana.codegen.PythonClientCodegenGenerator" >> "$GITHUB_ENV" + echo "name=asana" >> "$GITHUB_ENV" + - name: Download generator + run: | + wget -q -O $generator_name https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${{ env.generator_version }}/swagger-codegen-cli-${{ env.generator_version }}.jar + - name: Build custom code + run: | + pushd codegen/swagger >/dev/null + mvn package + popd >/dev/null + - name: Generate library + run: >- + java -cp "${{ env.jar_asana }}:${{ env.generator_name }}" + io.swagger.codegen.v3.cli.SwaggerCodegen + generate + --input-spec https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_sdk_oas.yaml + --template-dir "codegen/templates" + --lang "${{ env.actual_lang }}" + -DpackageName=${{ env.name }} + --additional-properties "packageVersion=${{ inputs.version }},projectName=${{ env.name }},packageName=${{ env.name }}" + - name: Clean up generator + run: rm -rf codegen/swagger/target ${{ env.generator_name }} + - name: Push changes to master branch + uses: EndBug/add-and-commit@v9 with: - tag_name: ${{ steps.tag.outputs.version }} - # Use the newest commit message as the release description - body: ${{ github.event.head_commit.message }} + message: 'Updated Python SDK: v${{ inputs.version }}' + committer_name: GitHub Actions + committer_email: actions@github.com + tag: 'v${{ inputs.version }} --force' + tag_push: '--force' build-n-publish-to-pypi: - needs: [bump-semantic-versioning, publish-to-github] - name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI + needs: generate-python-library + name: Build and publish Python 🐍 distributions 📦 to TestPyPI and PyPI runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -82,6 +84,21 @@ jobs: password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} + publish-to-github: + needs: build-n-publish-to-pypi + name: Publish to GitHub Releases + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: master + - name: Publish to GitHub Releases + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ inputs.version }} diff --git a/.gitignore b/.gitignore index f6d87f8d..447b9425 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,67 @@ -.idea -/build -/dist -/*.egg-info +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class -__pycache__ -*.pyc +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* .cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.python-version + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints + +.travis.yml +git_push.sh diff --git a/.swagger-codegen-ignore b/.swagger-codegen-ignore deleted file mode 100644 index b0c534d4..00000000 --- a/.swagger-codegen-ignore +++ /dev/null @@ -1,3 +0,0 @@ -# Swagger Codegen Ignore - -test/* diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 345ea0f7..00000000 --- a/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM python:3 - -WORKDIR /app - -ADD requirements.txt /app/requirements.txt - -RUN pip install -r requirements.txt - -ADD asana /app/asana -ADD examples /app/examples -ADD tests /app/tests -ADD setup.py /app/setup.py -ADD README.md /app/README.md - -RUN find . -name '*.pyc' -delete - -RUN python --version -RUN python -m pytest - -RUN python setup.py bdist_egg diff --git a/README.md b/README.md deleted file mode 100644 index e1b215b7..00000000 --- a/README.md +++ /dev/null @@ -1,183 +0,0 @@ -# asana [![Build][github-actions-image]][github-actions-url] [![PyPi Version][pypi-image]][pypi-url] - -> **Warning** -> Python client library version `>4.X.X` is currently in BETA and subject to change. Please use v3.2.X for stable / production environments `pip install asana` or `pip install asana==3.2.2`. If you have feedback on the new version, please your feedback [here](https://form.asana.com/?k=C4sELCq6hAUsoWEY0kJwAA&d=15793206719). - -> You can try out our new python beta by installing version [v4.0.11](https://github.com/Asana/python-asana/tree/v4.0.11) (`pip install asana==4.0.11`) - -Python client library for Asana. - -Authentication --------------- - -### Personal Access Token - -Create a client using your Asana Personal Access Token: - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - -### OAuth 2 - -Asana supports OAuth 2. `asana` handles some of the details of the OAuth flow for you. - -Create a client using your OAuth Client ID and secret: - - client = asana.Client.oauth( - client_id='ASANA_CLIENT_ID', - client_secret='ASANA_CLIENT_SECRET', - redirect_uri='https://yourapp.com/auth/asana/callback' - ) - -Redirect the user to the authorization URL obtained from the client's `session` object: - - (url, state) = client.session.authorization_url() - -When the user is redirected back to your callback, check the `state` URL parameter matches, then pass the `code` parameter to obtain a bearer token: - - if request.params['state'] == state: - token = client.session.fetch_token(code=request.params['code']) - # ... - else: - # error! possible CSRF attack - -Note: if you're writing a non-browser-based application (e.x. a command line tool) you can use the special redirect URI `urn:ietf:wg:oauth:2.0:oob` to prompt the user to copy and paste the code into the application. - -Usage ------ - -The client's methods are divided into several resources: `attachments`, `events`, `jobs`, `portfolios`, `portfolio_memberships`, `projects`, `project_memberships`, `stories`, `tags`, `tasks`, `teams`, `users`, `user_task_lists`, and `workspaces`. - -Methods that return a single object return that object directly: - - me = client.users.get_user('me') - print(f'Hello {me['name']}') - - workspace_id = me['workspaces'][0]['gid'] - project = client.projects.create_in_workspace(workspace_id, { 'name': 'new project' }) - print(f'Created project with id: {project['gid']}') - -Methods that return multiple items (e.x. `get_tasks`, `get_projects`, `get_portfolios`, etc.) return a page iterator by default. See the "Collections" section. - -#### See [the gen folder](asana/resources/gen) for methods available for each resource. - -Options -------- - -Various options can be set globally on the `Client.DEFAULTS` object, per-client on `client.options`, or per-request as additional named arguments. For example: - - # global: - asana.Client.DEFAULT_OPTIONS['page_size'] = 100 - - # per-client: - client.options['page_size'] = 100 - - # per-request: - client.tasks.get_tasks({ 'project': 1234 }, page_size=100) - -### Available options - -* `base_url` (default: "https://app.asana.com/api/1.0"): API endpoint base URL to connect to -* `max_retries` (default: 5): number to times to retry if API rate limit is reached or a server error occures. Rate limit retries delay until the rate limit expires, server errors exponentially backoff starting with a 1 second delay. -* `full_payload` (default: False): return the entire JSON response instead of the 'data' propery (default for collection methods and `events.get`) -* `fields` and `expand`: see [API documentation](https://asana.com/developers/documentation/getting-started/input-output-options) - -Collections (methods returning an array as its 'data' property): - -* `iterator_type` (default: "items"): specifies which type of iterator (or not) to return. Valid values are "items" and `None`. -* `item_limit` (default: None): limits the number of items of a collection to return. -* `page_size` (default: 50): limits the number of items per page to fetch at a time. -* `offset`: offset token returned by previous calls to the same method (in `response['next_page']['offset']`) - -Events: - -* `poll_interval` (default: 5): polling interval for getting new events via `events.get_next` and `events.get_iterator` -* `sync`: sync token returned by previous calls to `events.get` (in `response['sync']`) - -### Asana Change Warnings - -You will receive warning logs if performing requests that may be affected by a deprecation. The warning contains a link that explains the deprecation. - -If you receive one of these warnings, you should: -* Read about the deprecation. -* Resolve sections of your code that would be affected by the deprecation. -* Add the deprecation flag to your "asana-enable" header. - -You can place it on the client for all requests, or place it on a single request. - - client.headers={'asana-enable': 'string_ids'} - or - me = client.users.get_user('me', headers={'asana-enable': 'string_ids'}) - -If you would rather suppress these warnings, you can set - - client.LOG_ASANA_CHANGE_WARNINGS = False - -Collections ------------ - -### Items Iterator - -By default, methods that return a collection of objects return an item iterator: - - workspaces = client.workspaces.get_workspaces(item_limit=1) - print(next(workspaces)) - print(next(workspaces)) # raises StopIteration if there are no more items - -Or: - - for workspace in client.workspaces.get_workspaces() - print(workspace) - -### Raw API - -You can also use the raw API to fetch a page at a time: - - offset = None - while True: - page = client.workspaces.get_workspaces(offset=offset, iterator_type=None, full_payload=True) - print(page['data']) - if 'next_page' in page and page['next_page']: - offset = page['next_page']['offset'] - else: - break - -Contributing ------------- - -Feel free to fork and submit pull requests for the code! Please follow the -existing code as an example of style and make sure that all your code passes -lint and tests. - -### Code generation - -The specific Asana resource classes under `gen` (`_Tag`, `_Workspace`, `_Task`, etc) are -generated code, hence they shouldn't be modified by hand. - -### Deployment - -**Repo Owners Only.** Take the following steps to issue a new release of the library. - -#### Automatic Deployment - -Run `deploy.py [major|minor|patch]`. See `deploy.py -h` for additional info. - -#### Manual Deployment - - 1. Merge in the desired changes into the `master` branch and commit them. - 2. Clone the repo, work on master. - 3. Edit package version in `asana/__init__.py` and `./VERSION` to indicate the [semantic version](http://semver.org/) change. - 4. Commit the change - 5. Tag the commit with `v` plus the same version number you set in the file. - `git tag v1.2.3` - 6. Push changes to origin, including tags: - `git push origin master --tags` - -GitHub Actions will automatically build and deploy the tagged release to [PyPI](https://pypi.org/). - -[github-actions-url]: https://github.com/Asana/python-asana/actions -[github-actions-image]: https://github.com/Asana/python-asana/workflows/Build/badge.svg - -[pypi-url]: https://pypi.python.org/pypi/asana/ -[pypi-image]: https://img.shields.io/pypi/v/asana.svg?style=flat-square - -[asana-docs]: https://developers.asana.com/docs diff --git a/TESTING b/TESTING deleted file mode 100644 index d1917e59..00000000 --- a/TESTING +++ /dev/null @@ -1,4 +0,0 @@ -Unit tests ----------- - - py.test tests diff --git a/VERSION b/VERSION deleted file mode 100644 index acf9bf09..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.2.2 \ No newline at end of file diff --git a/asana/__init__.py b/asana/__init__.py deleted file mode 100644 index 863b9d31..00000000 --- a/asana/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -__title__ = 'asana' -__license__ = 'MIT' -__copyright__ = 'Copyright 2016 Asana, Inc.' - -from asana.version import __version__ -from .client import Client diff --git a/asana/client.py b/asana/client.py deleted file mode 100644 index f72b1727..00000000 --- a/asana/client.py +++ /dev/null @@ -1,367 +0,0 @@ -from types import ModuleType -import json -import platform -import time -import string -import warnings - -import requests - -from . import error, resources, session, __version__ -from .page_iterator import CollectionPageIterator -import urllib.parse as urlparse - -# Create a dict of resource classes -RESOURCE_CLASSES = {} -for name, module in resources.__dict__.items(): - classified_name = string.capwords(name, '_').replace('_', '') - if classified_name == "BatchApi": - classified_name = "BatchAPI" - if classified_name == "AuditLogApi": - classified_name = "AuditLogAPI" - if isinstance(module, ModuleType) and classified_name in module.__dict__: - RESOURCE_CLASSES[name] = module.__dict__[classified_name] - -# Create a mapping of status codes to classes -STATUS_MAP = {} -for name, Klass in error.__dict__.items(): - if isinstance(Klass, type) and issubclass(Klass, error.AsanaError): - STATUS_MAP[Klass().status] = Klass - - -class Client(object): - """Asana client class""" - - DEFAULT_OPTIONS = { - 'base_url': 'https://app.asana.com/api/1.0', - 'item_limit': None, - 'page_size': 50, - 'poll_interval': 5, - 'max_retries': 5, - 'full_payload': False, - 'iterator_type': 'items' - } - - RETRY_DELAY = 1.0 - RETRY_BACKOFF = 2.0 - - CLIENT_OPTIONS = set(DEFAULT_OPTIONS.keys()) - QUERY_OPTIONS = {'limit', 'offset', 'sync'} - REQUEST_OPTIONS = {'headers', 'params', 'data', 'files', 'verify', - 'timeout'} - API_OPTIONS = {'pretty', 'fields', 'expand', 'client_name'} - - LOG_ASANA_CHANGE_WARNINGS = True - - ALL_OPTIONS = ( - CLIENT_OPTIONS | QUERY_OPTIONS | REQUEST_OPTIONS | API_OPTIONS) - - def __init__(self, session=None, auth=None, **options): - """A :class:`Client` object for interacting with Asana's API. - - A Client object with session, optional auth handler, and options. - - """ - self.session = session or requests.Session() - self.auth = auth - self.headers = options.pop('headers', {}) - # merge the provided options (if any) with the global DEFAULTS - self.options = _merge(self.DEFAULT_OPTIONS, options) - # intializes each resource, injecting this client object into the - # constructor - for name, Klass in RESOURCE_CLASSES.items(): - setattr(self, name, Klass(self)) - - def request(self, method, path, **options): - """Dispatches a request to the Asana HTTP API""" - options = self._merge_options(options) - url = options['base_url'] + path - retry_count = 0 - request_options = self._parse_request_options(options) - self._add_version_header(request_options) - while True: - try: - try: - response = getattr(self.session, method)( - url, auth=self.auth, **request_options) - except requests.exceptions.Timeout: - raise error.RetryableAsanaError() - - self._log_asana_change_header(request_options['headers'], response.headers) - if response.status_code in STATUS_MAP: - raise STATUS_MAP[response.status_code](response) - elif 500 <= response.status_code < 600: - # Any unhandled 500 is a server error. - raise error.ServerError(response) - else: - if options['full_payload']: - return response.json() - else: - return response.json()['data'] - except error.RetryableAsanaError as e: - if retry_count < options['max_retries']: - self._handle_retryable_error(e, retry_count) - retry_count += 1 - else: - raise e - - def _log_asana_change_header(self, req_headers, res_headers): - if self.LOG_ASANA_CHANGE_WARNINGS: - change_header_key = None - - for key in res_headers: - if key.lower() == 'asana-change': - change_header_key = key - - if change_header_key is not None: - accounted_for_flags = [] - - # Grab the request's asana-enable flags - for reqHeader in req_headers: - if reqHeader.lower() == 'asana-enable': - for flag in req_headers[reqHeader].split(','): - accounted_for_flags.append(flag) - elif reqHeader.lower() == 'asana-disable': - for flag in req_headers[reqHeader].split(','): - accounted_for_flags.append(flag) - - changes = res_headers[change_header_key].split(',') - - for unsplit_change in changes: - change = unsplit_change.split(';') - - name = None - info = None - affected = None - - for unsplit_field in change: - field = unsplit_field.split('=') - - field[0] = field[0].strip() - if field[0].strip() == 'name': - name = field[1].strip() - elif field[0].strip() == 'info': - info = field[1].strip() - elif field[0].strip() == 'affected': - affected = field[1].strip() - - # Only show the error if the flag was not in the request's asana-enable header - if (name not in accounted_for_flags) & (affected == 'true'): - message = 'This request is affected by the "' + name + \ - '" deprecation. Please visit this url for more info: ' + info + \ - '\n' + 'Adding "' + name + '" to your "Asana-Enable" or ' + \ - '"Asana-Disable" header will opt in/out to this deprecation ' + \ - 'and suppress this warning.' - - warnings.warn(message) - - - def _handle_retryable_error(self, e, retry_count): - """Sleep based on the type of :class:`RetryableAsanaError`""" - if isinstance(e, error.RateLimitEnforcedError): - time.sleep(e.retry_after) - else: - time.sleep(self.RETRY_DELAY * (self.RETRY_BACKOFF ** retry_count)) - - def get(self, path, query, **options): - """Parses GET request options and dispatches a request.""" - api_options = self._parse_api_options(options, query_string=True) - query_options = self._parse_query_options(options) - parameter_options = self._parse_parameter_options(options) - - # options in the query takes precendence - query = _merge(query_options, api_options, parameter_options, query) - return self.request('get', path, params=query, **options) - - def get_collection(self, path, query, **options): - """Get a collection from a collection endpoint. - - Parses GET request options for a collection endpoint and dispatches a - request. - - """ - options = self._merge_options(options) - if options['iterator_type'] == 'items': - return CollectionPageIterator(self, path, query, options).items() - if options['iterator_type'] is None: - return self.get(path, query, **options) - raise Exception('Unknown value for "iterator_type" option: {}'.format( - str(options['iterator_type']))) - - def post(self, path, data, **options): - """Parses POST request options and dispatches a request.""" - parameter_options = self._parse_parameter_options(options) - body = { - # values in the data body takes precendence - 'data': _merge(parameter_options, data), - 'options': self._parse_api_options(options) - } - headers = _merge( - {'content-type': 'application/json'}, - options.pop('headers', {}) - ) - return self.request('post', path, data=body, headers=headers, **options) - - def put(self, path, data, **options): - """Parses PUT request options and dispatches a request.""" - parameter_options = self._parse_parameter_options(options) - body = { - # values in the data body takes precendence - 'data': _merge(parameter_options, data), - 'options': self._parse_api_options(options) - } - headers = _merge( - {'content-type': 'application/json'}, - options.pop('headers', {}) - ) - return self.request('put', path, data=body, headers=headers, **options) - - def delete(self, path, data, **options): - """Dispatches a DELETE request.""" - return self.request('delete', path, **options) - - def _merge_options(self, *objects): - """Merge option objects with the client's object. - - Merges one or more options objects with client's options and returns a - new options object. - - """ - return _merge(self.options, *objects) - - def _parse_query_options(self, options): - """Select query string options out of the provided options object""" - return self._select_options(options, self.QUERY_OPTIONS) - - def _parse_parameter_options(self, options): - """Select all unknown options. - - Select all unknown options (not query string, API, or request - options) - - """ - return self._select_options(options, self.ALL_OPTIONS, invert=True) - - def _parse_api_options(self, options, query_string=False): - """Select API options out of the provided options object. - - Selects API string options out of the provided options object and - formats for either request body (default) or query string. - - """ - api_options = self._select_options(options, self.API_OPTIONS) - if query_string: - # Prefix all options with "opt_" - query_api_options = {} - for key in api_options: - # Transform list/tuples into comma separated list - if isinstance(api_options[key], (list, tuple)): - query_api_options[ - 'opt_' + key] = ','.join(api_options[key]) - else: - query_api_options[ - 'opt_' + key] = api_options[key] - return query_api_options - else: - return api_options - - def _parse_request_options(self, options): - """Select request options out of the provided options object. - - - Select and formats options to be passed to the 'requests' library's - request methods. - - """ - request_options = self._select_options(options, self.REQUEST_OPTIONS) - if 'params' in request_options: - params = request_options['params'] - for key in params: - if isinstance(params[key], bool): - params[key] = json.dumps(params[key]) - if 'data' in request_options: - # remove empty 'options': - if 'options' in request_options['data'] and ( - len(request_options['data']['options']) == 0): - del request_options['data']['options'] - # serialize 'data' to JSON, requests doesn't do this automatically: - request_options['data'] = json.dumps(request_options['data']) - - headers = self.headers.copy() - headers.update(request_options.get('headers', {})) - request_options['headers'] = headers - return request_options - - def _select_options(self, options, keys, invert=False): - """Select the provided keys out of an options object. - - - Selects the provided keys (or everything except the provided keys) out - of an options object. - - """ - options = self._merge_options(options) - result = {} - for key in options: - if (invert and key not in keys) or (not invert and key in keys): - result[key] = options[key] - return result - - def _add_version_header(self, options): - """Add the client lib version header to the request.""" - headers = options.setdefault('headers', {}) - headers['X-Asana-Client-Lib'] = self._version_header() - - _cached_version_header = None - - def _version_header(self): - """Generate the client version header to send on each request.""" - if not self._cached_version_header: - self._cached_version_header = urlparse.urlencode( - self._version_values()) - return self._cached_version_header - - def _version_values(self): - """Generate the values to go in the client version header.""" - return { - 'language': 'Python', - 'version': __version__, - 'language_version': platform.python_version(), - 'os': platform.system(), - 'os_version': platform.release() - } - - @classmethod - def basic_auth(Klass, apiKey): - """DEPRECATED: this is only present for backwards-compatibility. - - This will be removed in the future; for new apps, prefer the - `access_token` method. - - Construct an Asana Client using a Personal Access Token as if it - were an old (removed) Asana API Key. - """ - return Klass(auth=requests.auth.HTTPBasicAuth(apiKey, '')) - - @classmethod - def access_token(Klass, accessToken): - """Construct an Asana Client with a Personal Access Token""" - return Klass( - session.AsanaOAuth2Session(token={'access_token': accessToken})) - - @classmethod - def oauth(Klass, **kwargs): - """Construct an Asana Client with Oauth credentials. - - Construct an Asana Client with OAuth credentials ('client_id' and - 'client_secret' or 'token'). - - """ - return Klass(session.AsanaOAuth2Session(**kwargs)) - - -def _merge(*objects): - """Merge one or more objects into a new object""" - result = {} - [result.update(obj) for obj in objects] - return result diff --git a/asana/error.py b/asana/error.py deleted file mode 100644 index 71902f80..00000000 --- a/asana/error.py +++ /dev/null @@ -1,105 +0,0 @@ -class AsanaError(Exception): - """Base Asana error class""" - def __init__(self, message=None, status=None, response=None): - try: - messages = [ - error['message'] for error in response.json()['errors']] - message = message + ': ' + '; '.join(messages) - except Exception: - pass - - super(AsanaError, self).__init__(message) - - self.status = status - self.response = response - self.message = message - - -class InvalidRequestError(AsanaError): - def __init__(self, response=None): - super(InvalidRequestError, self).__init__( - message='Invalid Request', - status=400, - response=response - ) - - -class NoAuthorizationError(AsanaError): - def __init__(self, response=None): - super(NoAuthorizationError, self).__init__( - message='No Authorization', - status=401, - response=response - ) - - -class PremiumOnlyError(AsanaError): - def __init__(self, response=None): - super(PremiumOnlyError, self).__init__( - message='Payment Required', - status=402, - response=response - ) - - -class ForbiddenError(AsanaError): - def __init__(self, response=None): - super(ForbiddenError, self).__init__( - message='Forbidden', - status=403, - response=response - ) - - -class NotFoundError(AsanaError): - def __init__(self, response=None): - super(NotFoundError, self).__init__( - message='Not Found', - status=404, - response=response - ) - - -class InvalidTokenError(AsanaError): - def __init__(self, response=None): - super(InvalidTokenError, self).__init__( - message='Sync token invalid or too old', - status=412, - response=response - ) - self.sync = response is not None and response.json()['sync'] - - -class RetryableAsanaError(AsanaError): - """Base class for retryable errors. - - Base class for errors which should trigger a retry (if configured to do - so). - - """ - def __init__(self, message=None, status=None, response=None): - super(RetryableAsanaError, self).__init__( - message=message, status=status, response=response) - - -class RateLimitEnforcedError(RetryableAsanaError): - def __init__(self, response=None): - super(RateLimitEnforcedError, self).__init__( - message='Rate Limit Enforced', - status=429, - response=response - ) - self.retry_after = ( - response is not None and float(response.headers['Retry-After'])) - - -class ServerError(RetryableAsanaError): - def __init__(self, response=None): - status = 500 - if response: - status = response.status - super(ServerError, self).__init__( - message='Server Error', - status=status, - response=response - ) diff --git a/asana/page_iterator.py b/asana/page_iterator.py deleted file mode 100644 index 313c1d33..00000000 --- a/asana/page_iterator.py +++ /dev/null @@ -1,134 +0,0 @@ - -from .error import InvalidTokenError -import time - -class PageIterator(object): - """Generic page iterator class, used for collections and events""" - - def __init__(self, client, path, query, options): - self.client = client - self.path = path - self.query = query - self.options = client._merge_options(options, { 'full_payload': True }) - - self.item_limit = float('inf') if self.options.get('item_limit', None) == None else self.options['item_limit'] - self.page_size = self.options['page_size'] - self.count = 0 - - self.continuation = False - - def __getattr__(self, name): - """Getter for the custom named 'continuation' object.""" - if name == self.CONTINUATION_KEY: - return self.continuation - raise AttributeError("%r object has no attribute %r" % (self.__class__, attr)) - - def __iter__(self): - """Iterator interface, self is an iterator""" - return self - - def __next__(self): - """Iterator interface, returns the next 'page'""" - - # Compute the limit from the page size, and remaining item limit - self.options['limit'] = min(self.page_size, self.item_limit - self.count) - # If there is no continuation value or computed limit is 0, we're done - if self.continuation == None or self.options['limit'] == 0: - raise StopIteration - # First call to __next__ - elif self.continuation == False: - result = self.get_initial() - # Subsequent calls to __next__ - else: - result = self.get_next() - # Extract the continuation from the response - self.continuation = result.get(self.CONTINUATION_KEY, None) - # Get the data, update the count, return the data - data = result.get('data', None) - if data != None: - self.count += len(data) - return data - - def next(self): - """Alias for __next__""" - return self.__next__() - - def items(self): - """Returns an iterator for each item in each page""" - for page in self: - for item in page: - yield item - - -class CollectionPageIterator(PageIterator): - """Iterator that returns one page of a collection at a time""" - - CONTINUATION_KEY = 'next_page' - - def get_initial(self): - return self.client.get(self.path, self.query, **self.options) - - def get_next(self): - self.options['offset'] = self.continuation['offset'] - return self.client.get(self.path, self.query, **self.options) - - -class EventsPageIterator(PageIterator): - """Iterator that returns the next page of events, polls until a non-empty page is returned""" - - CONTINUATION_KEY = 'sync' - - def get_initial(self): - # If no sync token was provided, make a request to get one - if 'sync' not in self.query: - try: - self.client.events.get(self.query, **self.options) - except InvalidTokenError as e: - # InvalidTokenError is expected to be thrown since we didn't provide a sync token - self.continuation = e.sync - else: - self.continuation = self.query['sync'] - return self.get_next() - - def get_next(self): - self.query['sync'] = self.continuation - return self.client.events.get(self.query, **self.options) - - def __next__(self): - # Override __next__ to continue polling until a non-empty page of events is returned - while True: - results = super(EventsPageIterator, self).__next__() - if len(results) > 0: - return results - else: - time.sleep(self.options['poll_interval']) - - -class AuditLogAPIIterator(CollectionPageIterator): - """Iterator that returns the next page of audit_log_api""" - - def __next__(self): - """Override __next__ to stop when there is no more data""" - - # Compute the limit from the page size, and remaining item limit - self.options['limit'] = min( - self.page_size, self.item_limit - self.count) - # If there is no continuation value or computed limit is 0, we're done - if self.continuation == None or self.options['limit'] == 0: - raise StopIteration - # First call to __next__ - elif self.continuation == False: - result = self.get_initial() - # Subsequent calls to __next__ - else: - result = self.get_next() - # Extract the continuation from the response - self.continuation = result.get(self.CONTINUATION_KEY, None) - # Get the data - data = result.get('data', None) - # If there is no more data we're done. Otherwise, we update the count and return the data - if not data: - raise StopIteration - else: - self.count += len(data) - return data diff --git a/asana/resources/__init__.py b/asana/resources/__init__.py deleted file mode 100644 index 58f3953f..00000000 --- a/asana/resources/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -from . import ( - attachments, - audit_log_api, - batch_api, - custom_field_settings, - custom_fields, - events, - goal_relationships, - goals, - jobs, - memberships, - message, - organization_exports, - portfolios, - portfolio_memberships, - project_briefs, - project_memberships, - project_statuses, - project_templates, - projects, - sections, - status_updates, - stories, - tags, - tasks, - teams, - time_periods, - team_memberships, - typeahead, - users, - user_task_lists, - webhooks, - workspace_memberships, - workspaces -) diff --git a/asana/resources/attachments.py b/asana/resources/attachments.py deleted file mode 100644 index 9d44ddde..00000000 --- a/asana/resources/attachments.py +++ /dev/null @@ -1,36 +0,0 @@ - -from .gen.attachments import _Attachments - -class Attachments(_Attachments): - """Attachments resource""" - - def create_attachment_for_task(self, task_id, file_content, file_name, file_content_type=None, **options): - """Upload an attachment for a task. Accepts a file object or string, file name, and optional file Content-Type""" - path = '/tasks/%s/attachments' % (task_id) - return self.client.request('post', path, files=[('file', (file_name, file_content, file_content_type))], **options) - - def create_on_task(self, task_id, file_content, file_name, file_content_type=None, **options): - path = '/tasks/%s/attachments' % (task_id) - return self.client.request('post', path, files=[('file', (file_name, file_content, file_content_type))], **options) - - def find_by_id(self, attachment, params={}, **options): - """Returns the full record for a single attachment. - - Parameters - ---------- - attachment : {Gid} Globally unique identifier for the attachment. - [params] : {Object} Parameters for the request - """ - path = "/attachments/%s" % (attachment) - return self.client.get(path, params, **options) - - def find_by_task(self, task, params={}, **options): - """Returns the compact records for all attachments on the task. - - Parameters - ---------- - task : {Gid} Globally unique identifier for the task. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s/attachments" % (task) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/audit_log_api.py b/asana/resources/audit_log_api.py deleted file mode 100644 index 43c3e30f..00000000 --- a/asana/resources/audit_log_api.py +++ /dev/null @@ -1,19 +0,0 @@ - -from .gen.audit_log_api import _AuditLogAPI -from ..page_iterator import AuditLogAPIIterator - - -class AuditLogAPI(_AuditLogAPI): - """AuditLogAPI resource""" - - def get_audit_log_events(self, workspace_gid, params={}, **options): - """Override get_audit_log_events to handle non-empty next_page parameter""" - path = "/workspaces/{workspace_gid}/audit_log_events".replace( - "{workspace_gid}", workspace_gid) - options = self.client._merge_options(options) - if options['iterator_type'] == 'items': - return AuditLogAPIIterator(self.client, path, params, options).items() - if options['iterator_type'] is None: - return self.client.get(path, params, **options) - raise Exception('Unknown value for "iterator_type" option: {}'.format( - str(options['iterator_type']))) diff --git a/asana/resources/batch_api.py b/asana/resources/batch_api.py deleted file mode 100644 index c9f1954a..00000000 --- a/asana/resources/batch_api.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.batch_api import _BatchAPI - -class BatchAPI(_BatchAPI): - """BatchAPI resource""" - pass diff --git a/asana/resources/custom_field_settings.py b/asana/resources/custom_field_settings.py deleted file mode 100644 index e524ba29..00000000 --- a/asana/resources/custom_field_settings.py +++ /dev/null @@ -1,26 +0,0 @@ - -from .gen.custom_field_settings import _CustomFieldSettings - -class CustomFieldSettings(_CustomFieldSettings): - """Custom Field Settings resource""" - def find_by_project(self, project, params={}, **options): - """Returns a list of all of the custom fields settings on a project. - - Parameters - ---------- - project : {Gid} The ID of the project for which to list custom field settings - [params] : {Object} Parameters for the request - """ - path = "/projects/%s/custom_field_settings" % (project) - return self.client.get_collection(path, params, **options) - - def find_by_portfolio(self, portfolio, params={}, **options): - """Returns a list of all of the custom fields settings on a portfolio. - - Parameters - ---------- - portfolio : {Gid} The ID of the portfolio for which to list custom field settings - [params] : {Object} Parameters for the request - """ - path = "/portfolios/%s/custom_field_settings" % (portfolio) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/custom_fields.py b/asana/resources/custom_fields.py deleted file mode 100644 index 45008c36..00000000 --- a/asana/resources/custom_fields.py +++ /dev/null @@ -1,140 +0,0 @@ - -from .gen.custom_fields import _CustomFields - -class CustomFields(_CustomFields): - """Custom Fields resource""" - def add_enum_option(self, custom_field, params={}, **options): - self.create_enum_option(custom_field, params, **options) - - def reorder_enum_option(self, custom_field, params={}, **options): - self.insert_enum_option(custom_field, params, **options) - - def create(self, params={}, **options): - """Creates a new custom field in a workspace. Every custom field is required to be created in a specific workspace, and this workspace cannot be changed once set. - - A custom field's `name` must be unique within a workspace and not conflict with names of existing task properties such as 'Due Date' or 'Assignee'. A custom field's `type` must be one of 'text', 'enum', or 'number'. - - Returns the full record of the newly created custom field. - - Parameters - ---------- - [data] : {Object} Data for the request - - workspace : {Gid} The workspace to create a custom field in. - - resource_subtype : {String} The type of the custom field. Must be one of the given values. - - [type] : {String} **Deprecated: New integrations should prefer the `resource_subtype` parameter.** - - name : {String} The name of the custom field. - - [description] : {String} The description of the custom field. - - [precision] : {Integer} The number of decimal places for the numerical values. Required if the custom field is of type 'number'. - - [enum_options] : {String} The discrete values the custom field can assume. Required if the custom field is of type 'enum'. - """ - return self.client.post("/custom_fields", params, **options) - - def find_by_id(self, custom_field, params={}, **options): - """Returns the complete definition of a custom field's metadata. - - Parameters - ---------- - custom_field : {Gid} Globally unique identifier for the custom field. - [params] : {Object} Parameters for the request - """ - path = "/custom_fields/%s" % (custom_field) - return self.client.get(path, params, **options) - - def find_by_workspace(self, workspace, params={}, **options): - """Returns a list of the compact representation of all of the custom fields in a workspace. - - Parameters - ---------- - workspace : {Gid} The workspace or organization to find custom field definitions in. - [params] : {Object} Parameters for the request - """ - path = "/workspaces/%s/custom_fields" % (workspace) - return self.client.get_collection(path, params, **options) - - def update(self, custom_field, params={}, **options): - """A specific, existing custom field can be updated by making a PUT request on the URL for that custom field. Only the fields provided in the `data` block will be updated; any unspecified fields will remain unchanged - - When using this method, it is best to specify only those fields you wish to change, or else you may overwrite changes made by another user since you last retrieved the custom field. - - An enum custom field's `enum_options` cannot be updated with this endpoint. Instead see "Work With Enum Options" for information on how to update `enum_options`. - - Locked custom fields can only be updated by the user who locked the field. - - Returns the complete updated custom field record. - - Parameters - ---------- - custom_field : {Gid} Globally unique identifier for the custom field. - [data] : {Object} Data for the request - """ - path = "/custom_fields/%s" % (custom_field) - return self.client.put(path, params, **options) - - def delete(self, custom_field, params={}, **options): - """A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field. - - Locked custom fields can only be deleted by the user who locked the field. - - Returns an empty data record. - - Parameters - ---------- - custom_field : {Gid} Globally unique identifier for the custom field. - """ - path = "/custom_fields/%s" % (custom_field) - return self.client.delete(path, params, **options) - - def create_enum_option(self, custom_field, params={}, **options): - """Creates an enum option and adds it to this custom field's list of enum options. A custom field can have at most 50 enum options (including disabled options). By default new enum options are inserted at the end of a custom field's list. - - Locked custom fields can only have enum options added by the user who locked the field. - - Returns the full record of the newly created enum option. - - Parameters - ---------- - custom_field : {Gid} Globally unique identifier for the custom field. - [data] : {Object} Data for the request - - name : {String} The name of the enum option. - - [color] : {String} The color of the enum option. Defaults to 'none'. - - [insert_before] : {Gid} An existing enum option within this custom field before which the new enum option should be inserted. Cannot be provided together with after_enum_option. - - [insert_after] : {Gid} An existing enum option within this custom field after which the new enum option should be inserted. Cannot be provided together with before_enum_option. - """ - path = "/custom_fields/%s/enum_options" % (custom_field) - return self.client.post(path, params, **options) - - def update_enum_option(self, enum_option, params={}, **options): - """Updates an existing enum option. Enum custom fields require at least one enabled enum option. - - Locked custom fields can only be updated by the user who locked the field. - - Returns the full record of the updated enum option. - - Parameters - ---------- - enum_option : {Gid} Globally unique identifier for the enum option. - [data] : {Object} Data for the request - - name : {String} The name of the enum option. - - [color] : {String} The color of the enum option. Defaults to 'none'. - - [enabled] : {Boolean} Whether or not the enum option is a selectable value for the custom field. - """ - path = "/enum_options/%s" % (enum_option) - return self.client.put(path, params, **options) - - def insert_enum_option(self, custom_field, params={}, **options): - """Moves a particular enum option to be either before or after another specified enum option in the custom field. - - Locked custom fields can only be reordered by the user who locked the field. - - Parameters - ---------- - custom_field : {Gid} Globally unique identifier for the custom field. - [data] : {Object} Data for the request - - enum_option : {Gid} The ID of the enum option to relocate. - - name : {String} The name of the enum option. - - [color] : {String} The color of the enum option. Defaults to 'none'. - - [before_enum_option] : {Gid} An existing enum option within this custom field before which the new enum option should be inserted. Cannot be provided together with after_enum_option. - - [after_enum_option] : {Gid} An existing enum option within this custom field after which the new enum option should be inserted. Cannot be provided together with before_enum_option. - """ - path = "/custom_fields/%s/enum_options/insert" % (custom_field) - return self.client.post(path, params, **options) diff --git a/asana/resources/events.py b/asana/resources/events.py deleted file mode 100644 index dc1643ac..00000000 --- a/asana/resources/events.py +++ /dev/null @@ -1,22 +0,0 @@ - -from .gen.events import _Events -from ..error import InvalidTokenError -from ..page_iterator import EventsPageIterator - -class Events(_Events): - """Events resource""" - - def get(self, params, **options): - """Dispatches a GET request to /events of the API to get a set of recent changes to a resource.""" - options = self.client._merge_options({ 'full_payload': True }) - return self.client.get('/events', params, **options) - - def get_next(self, query, **options): - """Returns a tuple containing the next page of events and a sync token for the given query (and optional 'sync' token)""" - iterator = EventsPageIterator(self.client, '/events', query, options) - result = next(iterator) - return (result, iterator.sync) - - def get_iterator(self, query, **options): - """Returns an event iterator for the given query (and optional 'sync' token)""" - return EventsPageIterator(self.client, '/events', query, options).items() diff --git a/asana/resources/gen/__init__.py b/asana/resources/gen/__init__.py deleted file mode 100644 index 2786f20b..00000000 --- a/asana/resources/gen/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -from . import ( - attachments, - audit_log_api, - batch_api, - custom_field_settings, - custom_fields, - events, - goals, - jobs, - organization_exports, - portfolios, - portfolio_memberships, - project_briefs, - project_memberships, - project_statuses, - project_templates, - projects, - sections, - status_updates, - stories, - tags, - tasks, - team_memberships, - teams, - time_periods, - typeahead, - users, - user_task_lists, - webhooks, - workspace_memberships, - workspaces -) diff --git a/asana/resources/gen/attachments.py b/asana/resources/gen/attachments.py deleted file mode 100644 index cb5f2998..00000000 --- a/asana/resources/gen/attachments.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding=utf-8 -class _Attachments: - - def __init__(self, client=None): - self.client = client - - def delete_attachment(self, attachment_gid, params=None, **options): - """Delete an attachment - :param str attachment_gid: (required) Globally unique identifier for the attachment. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/attachments/{attachment_gid}".replace("{attachment_gid}", attachment_gid) - return self.client.delete(path, params, **options) - - def get_attachment(self, attachment_gid, params=None, **options): - """Get an attachment - :param str attachment_gid: (required) Globally unique identifier for the attachment. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/attachments/{attachment_gid}".replace("{attachment_gid}", attachment_gid) - return self.client.get(path, params, **options) - - def get_attachments_for_object(self, params=None, **options): - """Get attachments from an object - :param Object params: Parameters for the request - - parent {str}: (required) Globally unique identifier for object to fetch statuses from. Must be a GID for a `project`, `project_brief`, or `task`. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/attachments" - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/audit_log_api.py b/asana/resources/gen/audit_log_api.py deleted file mode 100644 index 36c81cc3..00000000 --- a/asana/resources/gen/audit_log_api.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -class _AuditLogAPI: - - def __init__(self, client=None): - self.client = client - - def get_audit_log_events(self, workspace_gid, params=None, **options): - """Get audit log events - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - - start_at {datetime}: Filter to events created after this time (inclusive). - - end_at {datetime}: Filter to events created before this time (exclusive). - - event_type {str}: Filter to events of this type. Refer to the [supported audit log events](/docs/audit-log-events#supported-audit-log-events) for a full list of values. - - actor_type {str}: Filter to events with an actor of this type. This only needs to be included if querying for actor types without an ID. If `actor_gid` is included, this should be excluded. - - actor_gid {str}: Filter to events triggered by the actor with this ID. - - resource_gid {str}: Filter to events with this resource ID. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/audit_log_events".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/batch_api.py b/asana/resources/gen/batch_api.py deleted file mode 100644 index 3652b3d3..00000000 --- a/asana/resources/gen/batch_api.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 -class _BatchAPI: - - def __init__(self, client=None): - self.client = client - - def create_batch_request(self, params=None, **options): - """Submit parallel requests - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/batch" - return self.client.post(path, params, **options) diff --git a/asana/resources/gen/custom_field_settings.py b/asana/resources/gen/custom_field_settings.py deleted file mode 100644 index 563a68c3..00000000 --- a/asana/resources/gen/custom_field_settings.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding=utf-8 -class _CustomFieldSettings: - - def __init__(self, client=None): - self.client = client - - def get_custom_field_settings_for_portfolio(self, portfolio_gid, params=None, **options): - """Get a portfolio's custom fields - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/custom_field_settings".replace("{portfolio_gid}", portfolio_gid) - return self.client.get_collection(path, params, **options) - - def get_custom_field_settings_for_project(self, project_gid, params=None, **options): - """Get a project's custom fields - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/custom_field_settings".replace("{project_gid}", project_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/custom_fields.py b/asana/resources/gen/custom_fields.py deleted file mode 100644 index ba1a673e..00000000 --- a/asana/resources/gen/custom_fields.py +++ /dev/null @@ -1,122 +0,0 @@ -# coding=utf-8 -class _CustomFields: - - def __init__(self, client=None): - self.client = client - - def create_custom_field(self, params=None, **options): - """Create a custom field - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/custom_fields" - return self.client.post(path, params, **options) - - def create_enum_option_for_custom_field(self, custom_field_gid, params=None, **options): - """Create an enum option - :param str custom_field_gid: (required) Globally unique identifier for the custom field. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/custom_fields/{custom_field_gid}/enum_options".replace("{custom_field_gid}", custom_field_gid) - return self.client.post(path, params, **options) - - def delete_custom_field(self, custom_field_gid, params=None, **options): - """Delete a custom field - :param str custom_field_gid: (required) Globally unique identifier for the custom field. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/custom_fields/{custom_field_gid}".replace("{custom_field_gid}", custom_field_gid) - return self.client.delete(path, params, **options) - - def get_custom_field(self, custom_field_gid, params=None, **options): - """Get a custom field - :param str custom_field_gid: (required) Globally unique identifier for the custom field. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/custom_fields/{custom_field_gid}".replace("{custom_field_gid}", custom_field_gid) - return self.client.get(path, params, **options) - - def get_custom_fields_for_workspace(self, workspace_gid, params=None, **options): - """Get a workspace's custom fields - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/custom_fields".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) - - def insert_enum_option_for_custom_field(self, custom_field_gid, params=None, **options): - """Reorder a custom field's enum - :param str custom_field_gid: (required) Globally unique identifier for the custom field. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/custom_fields/{custom_field_gid}/enum_options/insert".replace("{custom_field_gid}", custom_field_gid) - return self.client.post(path, params, **options) - - def update_custom_field(self, custom_field_gid, params=None, **options): - """Update a custom field - :param str custom_field_gid: (required) Globally unique identifier for the custom field. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/custom_fields/{custom_field_gid}".replace("{custom_field_gid}", custom_field_gid) - return self.client.put(path, params, **options) - - def update_enum_option(self, enum_option_gid, params=None, **options): - """Update an enum option - :param str enum_option_gid: (required) Globally unique identifier for the enum option. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/enum_options/{enum_option_gid}".replace("{enum_option_gid}", enum_option_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/events.py b/asana/resources/gen/events.py deleted file mode 100644 index 5ba54075..00000000 --- a/asana/resources/gen/events.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 -class _Events: - - def __init__(self, client=None): - self.client = client - - def get_events(self, params=None, **options): - """Get events on a resource - :param Object params: Parameters for the request - - resource {str}: (required) A resource ID to subscribe to. The resource can be a task or project. - - sync {str}: A sync token received from the last request, or none on first sync. Events will be returned from the point in time that the sync token was generated. *Note: On your first request, omit the sync token. The response will be the same as for an expired sync token, and will include a new valid sync token.If the sync token is too old (which may happen from time to time) the API will return a `412 Precondition Failed` error, and include a fresh sync token in the response.* - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/events" - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/goal_relationships.py b/asana/resources/gen/goal_relationships.py deleted file mode 100644 index e5ee197c..00000000 --- a/asana/resources/gen/goal_relationships.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding=utf-8 -class _GoalRelationships: - - def __init__(self, client=None): - self.client = client - - def add_supporting_relationship(self, goal_gid, params=None, **options): - """Add a supporting goal relationship - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}/addSupportingRelationship".replace("{goal_gid}", goal_gid) - return self.client.post(path, params, **options) - - def get_goal_relationship(self, goal_relationship_gid, params=None, **options): - """Get a goal relationship - :param str goal_relationship_gid: (required) Globally unique identifier for the goal relationship. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goal_relationships/{goal_relationship_gid}".replace("{goal_relationship_gid}", goal_relationship_gid) - return self.client.get(path, params, **options) - - def get_goal_relationships(self, params=None, **options): - """Get goal relationships - :param Object params: Parameters for the request - - supported_goal {str}: (required) Globally unique identifier for the supported goal in the goal relationship. - - resource_subtype {str}: If provided, filter to goal relationships with a given resource_subtype. - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goal_relationships" - return self.client.get_collection(path, params, **options) - - def remove_supporting_relationship(self, goal_gid, params=None, **options): - """Removes a supporting goal relationship - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}/removeSupportingRelationship".replace("{goal_gid}", goal_gid) - return self.client.post(path, params, **options) - - def update_goal_relationship(self, goal_relationship_gid, params=None, **options): - """Update a goal relationship - :param str goal_relationship_gid: (required) Globally unique identifier for the goal relationship. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goal_relationships/{goal_relationship_gid}".replace("{goal_relationship_gid}", goal_relationship_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/goals.py b/asana/resources/gen/goals.py deleted file mode 100644 index 79e47743..00000000 --- a/asana/resources/gen/goals.py +++ /dev/null @@ -1,153 +0,0 @@ -# coding=utf-8 -class _Goals: - - def __init__(self, client=None): - self.client = client - - def add_followers(self, goal_gid, params=None, **options): - """Add a collaborator to a goal - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}/addFollowers".replace("{goal_gid}", goal_gid) - return self.client.post(path, params, **options) - - def create_goal(self, params=None, **options): - """Create a goal - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals" - return self.client.post(path, params, **options) - - def create_goal_metric(self, goal_gid, params=None, **options): - """Create a goal metric - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}/setMetric".replace("{goal_gid}", goal_gid) - return self.client.post(path, params, **options) - - def delete_goal(self, goal_gid, params=None, **options): - """Delete a goal - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}".replace("{goal_gid}", goal_gid) - return self.client.delete(path, params, **options) - - def get_goal(self, goal_gid, params=None, **options): - """Get a goal - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}".replace("{goal_gid}", goal_gid) - return self.client.get(path, params, **options) - - def get_goals(self, params=None, **options): - """Get goals - :param Object params: Parameters for the request - - portfolio {str}: Globally unique identifier for supporting portfolio. - - project {str}: Globally unique identifier for supporting project. - - is_workspace_level {bool}: Filter to goals with is_workspace_level set to query value. Must be used with the workspace parameter. - - team {str}: Globally unique identifier for the team. - - workspace {str}: Globally unique identifier for the workspace. - - time_periods {list[str]}: Globally unique identifiers for the time periods. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals" - return self.client.get_collection(path, params, **options) - - def get_parent_goals_for_goal(self, goal_gid, params=None, **options): - """Get parent goals from a goal - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}/parentGoals".replace("{goal_gid}", goal_gid) - return self.client.get_collection(path, params, **options) - - def remove_followers(self, goal_gid, params=None, **options): - """Remove a collaborator from a goal - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}/removeFollowers".replace("{goal_gid}", goal_gid) - return self.client.post(path, params, **options) - - def update_goal(self, goal_gid, params=None, **options): - """Update a goal - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}".replace("{goal_gid}", goal_gid) - return self.client.put(path, params, **options) - - def update_goal_metric(self, goal_gid, params=None, **options): - """Update a goal metric - :param str goal_gid: (required) Globally unique identifier for the goal. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/goals/{goal_gid}/setMetricCurrentValue".replace("{goal_gid}", goal_gid) - return self.client.post(path, params, **options) diff --git a/asana/resources/gen/jobs.py b/asana/resources/gen/jobs.py deleted file mode 100644 index 2c1d7027..00000000 --- a/asana/resources/gen/jobs.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -class _Jobs: - - def __init__(self, client=None): - self.client = client - - def get_job(self, job_gid, params=None, **options): - """Get a job by id - :param str job_gid: (required) Globally unique identifier for the job. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/jobs/{job_gid}".replace("{job_gid}", job_gid) - return self.client.get(path, params, **options) diff --git a/asana/resources/gen/memberships.py b/asana/resources/gen/memberships.py deleted file mode 100644 index 64a222a9..00000000 --- a/asana/resources/gen/memberships.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -class _Memberships: - - def __init__(self, client=None): - self.client = client - - def create_membership(self, params=None, **options): - """Create a membership - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/memberships" - return self.client.post(path, params, **options) - - def delete_membership(self, membership_gid, params=None, **options): - """Delete a membership - :param str membership_gid: (required) Globally unique identifier for the membership. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/memberships/{membership_gid}".replace("{membership_gid}", membership_gid) - return self.client.delete(path, params, **options) - - def get_memberships(self, params=None, **options): - """Get multiple memberships - :param Object params: Parameters for the request - - parent {str}: Globally unique identifier for `project`, `portfolio`, `team`, `goal`, and `workspace`. - - member {str}: Globally unique identifier for `team` or `user`. - - resource_subtype {str}: The resource_subtype to filter on. Must be provided with `member` and `workspace` if `parent` is not provided. Valid values include `team_membership`, `workspace_membership`, `portfolio_membership` - - workspace {str}: The workspace to filter on. Must be provided with `member` and `resource_subtype` if `parent` is not provided. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Pagination limit for the request. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/memberships" - return self.client.get_collection(path, params, **options) - - def update_membership(self, membership_gid, params=None, **options): - """Update a membership - :param str membership_gid: (required) Globally unique identifier for the membership. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/memberships/{membership_gid}".replace("{membership_gid}", membership_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/message.py b/asana/resources/gen/message.py deleted file mode 100644 index 13791545..00000000 --- a/asana/resources/gen/message.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -class _Message: - - def __init__(self, client=None): - self.client = client - - def get_message(self, message_gid, params=None, **options): - """Get a message - :param str message_gid: (required) The message to get. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/messages/{message_gid}".replace("{message_gid}", message_gid) - return self.client.get(path, params, **options) diff --git a/asana/resources/gen/organization_exports.py b/asana/resources/gen/organization_exports.py deleted file mode 100644 index 0c196941..00000000 --- a/asana/resources/gen/organization_exports.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -class _OrganizationExports: - - def __init__(self, client=None): - self.client = client - - def create_organization_export(self, params=None, **options): - """Create an organization export request - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/organization_exports" - return self.client.post(path, params, **options) - - def get_organization_export(self, organization_export_gid, params=None, **options): - """Get details on an org export request - :param str organization_export_gid: (required) Globally unique identifier for the organization export. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/organization_exports/{organization_export_gid}".replace("{organization_export_gid}", organization_export_gid) - return self.client.get(path, params, **options) diff --git a/asana/resources/gen/portfolio_memberships.py b/asana/resources/gen/portfolio_memberships.py deleted file mode 100644 index bbae489d..00000000 --- a/asana/resources/gen/portfolio_memberships.py +++ /dev/null @@ -1,54 +0,0 @@ -# coding=utf-8 -class _PortfolioMemberships: - - def __init__(self, client=None): - self.client = client - - def get_portfolio_membership(self, portfolio_membership_gid, params=None, **options): - """Get a portfolio membership - :param str portfolio_membership_gid: (required) - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolio_memberships/{portfolio_membership_gid}".replace("{portfolio_membership_gid}", portfolio_membership_gid) - return self.client.get(path, params, **options) - - def get_portfolio_memberships(self, params=None, **options): - """Get multiple portfolio memberships - :param Object params: Parameters for the request - - portfolio {str}: The portfolio to filter results on. - - workspace {str}: The workspace to filter results on. - - user {str}: A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolio_memberships" - return self.client.get_collection(path, params, **options) - - def get_portfolio_memberships_for_portfolio(self, portfolio_gid, params=None, **options): - """Get memberships from a portfolio - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - - user {str}: A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/portfolio_memberships".replace("{portfolio_gid}", portfolio_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/portfolios.py b/asana/resources/gen/portfolios.py deleted file mode 100644 index 5ec3d557..00000000 --- a/asana/resources/gen/portfolios.py +++ /dev/null @@ -1,175 +0,0 @@ -# coding=utf-8 -class _Portfolios: - - def __init__(self, client=None): - self.client = client - - def add_custom_field_setting_for_portfolio(self, portfolio_gid, params=None, **options): - """Add a custom field to a portfolio - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/addCustomFieldSetting".replace("{portfolio_gid}", portfolio_gid) - return self.client.post(path, params, **options) - - def add_item_for_portfolio(self, portfolio_gid, params=None, **options): - """Add a portfolio item - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/addItem".replace("{portfolio_gid}", portfolio_gid) - return self.client.post(path, params, **options) - - def add_members_for_portfolio(self, portfolio_gid, params=None, **options): - """Add users to a portfolio - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/addMembers".replace("{portfolio_gid}", portfolio_gid) - return self.client.post(path, params, **options) - - def create_portfolio(self, params=None, **options): - """Create a portfolio - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios" - return self.client.post(path, params, **options) - - def delete_portfolio(self, portfolio_gid, params=None, **options): - """Delete a portfolio - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}".replace("{portfolio_gid}", portfolio_gid) - return self.client.delete(path, params, **options) - - def get_items_for_portfolio(self, portfolio_gid, params=None, **options): - """Get portfolio items - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/items".replace("{portfolio_gid}", portfolio_gid) - return self.client.get_collection(path, params, **options) - - def get_portfolio(self, portfolio_gid, params=None, **options): - """Get a portfolio - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}".replace("{portfolio_gid}", portfolio_gid) - return self.client.get(path, params, **options) - - def get_portfolios(self, params=None, **options): - """Get multiple portfolios - :param Object params: Parameters for the request - - workspace {str}: (required) The workspace or organization to filter portfolios on. - - owner {str}: The user who owns the portfolio. Currently, API users can only get a list of portfolios that they themselves own. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios" - return self.client.get_collection(path, params, **options) - - def remove_custom_field_setting_for_portfolio(self, portfolio_gid, params=None, **options): - """Remove a custom field from a portfolio - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/removeCustomFieldSetting".replace("{portfolio_gid}", portfolio_gid) - return self.client.post(path, params, **options) - - def remove_item_for_portfolio(self, portfolio_gid, params=None, **options): - """Remove a portfolio item - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/removeItem".replace("{portfolio_gid}", portfolio_gid) - return self.client.post(path, params, **options) - - def remove_members_for_portfolio(self, portfolio_gid, params=None, **options): - """Remove users from a portfolio - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}/removeMembers".replace("{portfolio_gid}", portfolio_gid) - return self.client.post(path, params, **options) - - def update_portfolio(self, portfolio_gid, params=None, **options): - """Update a portfolio - :param str portfolio_gid: (required) Globally unique identifier for the portfolio. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/portfolios/{portfolio_gid}".replace("{portfolio_gid}", portfolio_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/project_briefs.py b/asana/resources/gen/project_briefs.py deleted file mode 100644 index 4d59ff55..00000000 --- a/asana/resources/gen/project_briefs.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -class _ProjectBriefs: - - def __init__(self, client=None): - self.client = client - - def create_project_brief(self, project_gid, params=None, **options): - """Create a project brief - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/project_briefs".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def delete_project_brief(self, project_brief_gid, params=None, **options): - """Delete a project brief - :param str project_brief_gid: (required) Globally unique identifier for the project brief. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_briefs/{project_brief_gid}".replace("{project_brief_gid}", project_brief_gid) - return self.client.delete(path, params, **options) - - def get_project_brief(self, project_brief_gid, params=None, **options): - """Get a project brief - :param str project_brief_gid: (required) Globally unique identifier for the project brief. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_briefs/{project_brief_gid}".replace("{project_brief_gid}", project_brief_gid) - return self.client.get(path, params, **options) - - def update_project_brief(self, project_brief_gid, params=None, **options): - """Update a project brief - :param str project_brief_gid: (required) Globally unique identifier for the project brief. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_briefs/{project_brief_gid}".replace("{project_brief_gid}", project_brief_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/project_memberships.py b/asana/resources/gen/project_memberships.py deleted file mode 100644 index a78c0af5..00000000 --- a/asana/resources/gen/project_memberships.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -class _ProjectMemberships: - - def __init__(self, client=None): - self.client = client - - def get_project_membership(self, project_membership_gid, params=None, **options): - """Get a project membership - :param str project_membership_gid: (required) - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_memberships/{project_membership_gid}".replace("{project_membership_gid}", project_membership_gid) - return self.client.get(path, params, **options) - - def get_project_memberships_for_project(self, project_gid, params=None, **options): - """Get memberships from a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - - user {str}: A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/project_memberships".replace("{project_gid}", project_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/project_statuses.py b/asana/resources/gen/project_statuses.py deleted file mode 100644 index 94e9af82..00000000 --- a/asana/resources/gen/project_statuses.py +++ /dev/null @@ -1,63 +0,0 @@ -# coding=utf-8 -class _ProjectStatuses: - - def __init__(self, client=None): - self.client = client - - def create_project_status_for_project(self, project_gid, params=None, **options): - """Create a project status - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/project_statuses".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def delete_project_status(self, project_status_gid, params=None, **options): - """Delete a project status - :param str project_status_gid: (required) The project status update to get. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_statuses/{project_status_gid}".replace("{project_status_gid}", project_status_gid) - return self.client.delete(path, params, **options) - - def get_project_status(self, project_status_gid, params=None, **options): - """Get a project status - :param str project_status_gid: (required) The project status update to get. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_statuses/{project_status_gid}".replace("{project_status_gid}", project_status_gid) - return self.client.get(path, params, **options) - - def get_project_statuses_for_project(self, project_gid, params=None, **options): - """Get statuses from a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/project_statuses".replace("{project_gid}", project_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/project_templates.py b/asana/resources/gen/project_templates.py deleted file mode 100644 index 87c99d29..00000000 --- a/asana/resources/gen/project_templates.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -class _ProjectTemplates: - - def __init__(self, client=None): - self.client = client - - def get_project_template(self, project_template_gid, params=None, **options): - """Get a project template - :param str project_template_gid: (required) Globally unique identifier for the project template. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_templates/{project_template_gid}".replace("{project_template_gid}", project_template_gid) - return self.client.get(path, params, **options) - - def get_project_templates(self, params=None, **options): - """Get multiple project templates - :param Object params: Parameters for the request - - workspace {str}: The workspace to filter results on. - - team {str}: The team to filter projects on. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_templates" - return self.client.get_collection(path, params, **options) - - def get_project_templates_for_team(self, team_gid, params=None, **options): - """Get a team's project templates - :param str team_gid: (required) Globally unique identifier for the team. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams/{team_gid}/project_templates".replace("{team_gid}", team_gid) - return self.client.get_collection(path, params, **options) - - def instantiate_project(self, project_template_gid, params=None, **options): - """Instantiate a project from a project template - :param str project_template_gid: (required) Globally unique identifier for the project template. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/project_templates/{project_template_gid}/instantiateProject".replace("{project_template_gid}", project_template_gid) - return self.client.post(path, params, **options) diff --git a/asana/resources/gen/projects.py b/asana/resources/gen/projects.py deleted file mode 100644 index f93fba92..00000000 --- a/asana/resources/gen/projects.py +++ /dev/null @@ -1,282 +0,0 @@ -# coding=utf-8 -class _Projects: - - def __init__(self, client=None): - self.client = client - - def add_custom_field_setting_for_project(self, project_gid, params=None, **options): - """Add a custom field to a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/addCustomFieldSetting".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def add_followers_for_project(self, project_gid, params=None, **options): - """Add followers to a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/addFollowers".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def add_members_for_project(self, project_gid, params=None, **options): - """Add users to a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/addMembers".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def create_project(self, params=None, **options): - """Create a project - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects" - return self.client.post(path, params, **options) - - def create_project_for_team(self, team_gid, params=None, **options): - """Create a project in a team - :param str team_gid: (required) Globally unique identifier for the team. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams/{team_gid}/projects".replace("{team_gid}", team_gid) - return self.client.post(path, params, **options) - - def create_project_for_workspace(self, workspace_gid, params=None, **options): - """Create a project in a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/projects".replace("{workspace_gid}", workspace_gid) - return self.client.post(path, params, **options) - - def delete_project(self, project_gid, params=None, **options): - """Delete a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}".replace("{project_gid}", project_gid) - return self.client.delete(path, params, **options) - - def duplicate_project(self, project_gid, params=None, **options): - """Duplicate a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/duplicate".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def get_project(self, project_gid, params=None, **options): - """Get a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}".replace("{project_gid}", project_gid) - return self.client.get(path, params, **options) - - def get_projects(self, params=None, **options): - """Get multiple projects - :param Object params: Parameters for the request - - workspace {str}: The workspace or organization to filter projects on. - - team {str}: The team to filter projects on. - - archived {bool}: Only return projects whose `archived` field takes on the value of this parameter. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects" - return self.client.get_collection(path, params, **options) - - def get_projects_for_task(self, task_gid, params=None, **options): - """Get projects a task is in - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/projects".replace("{task_gid}", task_gid) - return self.client.get_collection(path, params, **options) - - def get_projects_for_team(self, team_gid, params=None, **options): - """Get a team's projects - :param str team_gid: (required) Globally unique identifier for the team. - :param Object params: Parameters for the request - - archived {bool}: Only return projects whose `archived` field takes on the value of this parameter. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams/{team_gid}/projects".replace("{team_gid}", team_gid) - return self.client.get_collection(path, params, **options) - - def get_projects_for_workspace(self, workspace_gid, params=None, **options): - """Get all projects in a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - - archived {bool}: Only return projects whose `archived` field takes on the value of this parameter. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/projects".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) - - def get_task_counts_for_project(self, project_gid, params=None, **options): - """Get task count of a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/task_counts".replace("{project_gid}", project_gid) - return self.client.get(path, params, **options) - - def project_save_as_template(self, project_gid, params=None, **options): - """Create a project template from a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/saveAsTemplate".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def remove_custom_field_setting_for_project(self, project_gid, params=None, **options): - """Remove a custom field from a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/removeCustomFieldSetting".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def remove_followers_for_project(self, project_gid, params=None, **options): - """Remove followers from a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/removeFollowers".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def remove_members_for_project(self, project_gid, params=None, **options): - """Remove users from a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/removeMembers".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def update_project(self, project_gid, params=None, **options): - """Update a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}".replace("{project_gid}", project_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/sections.py b/asana/resources/gen/sections.py deleted file mode 100644 index 043ac4c0..00000000 --- a/asana/resources/gen/sections.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -class _Sections: - - def __init__(self, client=None): - self.client = client - - def add_task_for_section(self, section_gid, params=None, **options): - """Add task to section - :param str section_gid: (required) The globally unique identifier for the section. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/sections/{section_gid}/addTask".replace("{section_gid}", section_gid) - return self.client.post(path, params, **options) - - def create_section_for_project(self, project_gid, params=None, **options): - """Create a section in a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/sections".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def delete_section(self, section_gid, params=None, **options): - """Delete a section - :param str section_gid: (required) The globally unique identifier for the section. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/sections/{section_gid}".replace("{section_gid}", section_gid) - return self.client.delete(path, params, **options) - - def get_section(self, section_gid, params=None, **options): - """Get a section - :param str section_gid: (required) The globally unique identifier for the section. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/sections/{section_gid}".replace("{section_gid}", section_gid) - return self.client.get(path, params, **options) - - def get_sections_for_project(self, project_gid, params=None, **options): - """Get sections in a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/sections".replace("{project_gid}", project_gid) - return self.client.get_collection(path, params, **options) - - def insert_section_for_project(self, project_gid, params=None, **options): - """Move or Insert sections - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/sections/insert".replace("{project_gid}", project_gid) - return self.client.post(path, params, **options) - - def update_section(self, section_gid, params=None, **options): - """Update a section - :param str section_gid: (required) The globally unique identifier for the section. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/sections/{section_gid}".replace("{section_gid}", section_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/status_updates.py b/asana/resources/gen/status_updates.py deleted file mode 100644 index ef89bd5d..00000000 --- a/asana/resources/gen/status_updates.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -class _StatusUpdates: - - def __init__(self, client=None): - self.client = client - - def create_status_for_object(self, params=None, **options): - """Create a status update - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/status_updates" - return self.client.post(path, params, **options) - - def delete_status(self, status_gid, params=None, **options): - """Delete a status update - :param str status_gid: (required) The status update to get. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/status_updates/{status_gid}".replace("{status_gid}", status_gid) - return self.client.delete(path, params, **options) - - def get_status(self, status_gid, params=None, **options): - """Get a status update - :param str status_gid: (required) The status update to get. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/status_updates/{status_gid}".replace("{status_gid}", status_gid) - return self.client.get(path, params, **options) - - def get_statuses_for_object(self, params=None, **options): - """Get status updates from an object - :param Object params: Parameters for the request - - parent {str}: (required) Globally unique identifier for object to fetch statuses from. Must be a GID for a project, portfolio, or goal. - - created_since {datetime}: Only return statuses that have been created since the given time. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/status_updates" - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/stories.py b/asana/resources/gen/stories.py deleted file mode 100644 index d0dd73ed..00000000 --- a/asana/resources/gen/stories.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding=utf-8 -class _Stories: - - def __init__(self, client=None): - self.client = client - - def create_story_for_task(self, task_gid, params=None, **options): - """Create a story on a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/stories".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def delete_story(self, story_gid, params=None, **options): - """Delete a story - :param str story_gid: (required) Globally unique identifier for the story. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/stories/{story_gid}".replace("{story_gid}", story_gid) - return self.client.delete(path, params, **options) - - def get_stories_for_task(self, task_gid, params=None, **options): - """Get stories from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/stories".replace("{task_gid}", task_gid) - return self.client.get_collection(path, params, **options) - - def get_story(self, story_gid, params=None, **options): - """Get a story - :param str story_gid: (required) Globally unique identifier for the story. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/stories/{story_gid}".replace("{story_gid}", story_gid) - return self.client.get(path, params, **options) - - def update_story(self, story_gid, params=None, **options): - """Update a story - :param str story_gid: (required) Globally unique identifier for the story. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/stories/{story_gid}".replace("{story_gid}", story_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/tags.py b/asana/resources/gen/tags.py deleted file mode 100644 index 52fd7988..00000000 --- a/asana/resources/gen/tags.py +++ /dev/null @@ -1,128 +0,0 @@ -# coding=utf-8 -class _Tags: - - def __init__(self, client=None): - self.client = client - - def create_tag(self, params=None, **options): - """Create a tag - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tags" - return self.client.post(path, params, **options) - - def create_tag_for_workspace(self, workspace_gid, params=None, **options): - """Create a tag in a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/tags".replace("{workspace_gid}", workspace_gid) - return self.client.post(path, params, **options) - - def delete_tag(self, tag_gid, params=None, **options): - """Delete a tag - :param str tag_gid: (required) Globally unique identifier for the tag. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tags/{tag_gid}".replace("{tag_gid}", tag_gid) - return self.client.delete(path, params, **options) - - def get_tag(self, tag_gid, params=None, **options): - """Get a tag - :param str tag_gid: (required) Globally unique identifier for the tag. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tags/{tag_gid}".replace("{tag_gid}", tag_gid) - return self.client.get(path, params, **options) - - def get_tags(self, params=None, **options): - """Get multiple tags - :param Object params: Parameters for the request - - workspace {str}: The workspace to filter tags on. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tags" - return self.client.get_collection(path, params, **options) - - def get_tags_for_task(self, task_gid, params=None, **options): - """Get a task's tags - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/tags".replace("{task_gid}", task_gid) - return self.client.get_collection(path, params, **options) - - def get_tags_for_workspace(self, workspace_gid, params=None, **options): - """Get tags in a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/tags".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) - - def update_tag(self, tag_gid, params=None, **options): - """Update a tag - :param str tag_gid: (required) Globally unique identifier for the tag. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tags/{tag_gid}".replace("{tag_gid}", tag_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/tasks.py b/asana/resources/gen/tasks.py deleted file mode 100644 index 1b100d28..00000000 --- a/asana/resources/gen/tasks.py +++ /dev/null @@ -1,443 +0,0 @@ -# coding=utf-8 -class _Tasks: - - def __init__(self, client=None): - self.client = client - - def add_dependencies_for_task(self, task_gid, params=None, **options): - """Set dependencies for a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/addDependencies".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def add_dependents_for_task(self, task_gid, params=None, **options): - """Set dependents for a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/addDependents".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def add_followers_for_task(self, task_gid, params=None, **options): - """Add followers to a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/addFollowers".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def add_project_for_task(self, task_gid, params=None, **options): - """Add a project to a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/addProject".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def add_tag_for_task(self, task_gid, params=None, **options): - """Add a tag to a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/addTag".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def create_subtask_for_task(self, task_gid, params=None, **options): - """Create a subtask - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/subtasks".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def create_task(self, params=None, **options): - """Create a task - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks" - return self.client.post(path, params, **options) - - def delete_task(self, task_gid, params=None, **options): - """Delete a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}".replace("{task_gid}", task_gid) - return self.client.delete(path, params, **options) - - def duplicate_task(self, task_gid, params=None, **options): - """Duplicate a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/duplicate".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def get_dependencies_for_task(self, task_gid, params=None, **options): - """Get dependencies from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/dependencies".replace("{task_gid}", task_gid) - return self.client.get_collection(path, params, **options) - - def get_dependents_for_task(self, task_gid, params=None, **options): - """Get dependents from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/dependents".replace("{task_gid}", task_gid) - return self.client.get_collection(path, params, **options) - - def get_subtasks_for_task(self, task_gid, params=None, **options): - """Get subtasks from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/subtasks".replace("{task_gid}", task_gid) - return self.client.get_collection(path, params, **options) - - def get_task(self, task_gid, params=None, **options): - """Get a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}".replace("{task_gid}", task_gid) - return self.client.get(path, params, **options) - - def get_tasks(self, params=None, **options): - """Get multiple tasks - :param Object params: Parameters for the request - - assignee {str}: The assignee to filter tasks on. If searching for unassigned tasks, assignee.any = null can be specified. *Note: If you specify `assignee`, you must also specify the `workspace` to filter on.* - - project {str}: The project to filter tasks on. - - section {str}: The section to filter tasks on. - - workspace {str}: The workspace to filter tasks on. *Note: If you specify `workspace`, you must also specify the `assignee` to filter on.* - - completed_since {datetime}: Only return tasks that are either incomplete or that have been completed since this time. - - modified_since {datetime}: Only return tasks that have been modified since the given time. *Note: A task is considered “modified” if any of its properties change, or associations between it and other objects are modified (e.g. a task being added to a project). A task is not considered modified just because another object it is associated with (e.g. a subtask) is modified. Actions that count as modifying the task include assigning, renaming, completing, and adding stories.* - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks" - return self.client.get_collection(path, params, **options) - - def get_tasks_for_project(self, project_gid, params=None, **options): - """Get tasks from a project - :param str project_gid: (required) Globally unique identifier for the project. - :param Object params: Parameters for the request - - completed_since {str}: Only return tasks that are either incomplete or that have been completed since this time. Accepts a date-time string or the keyword *now*. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/projects/{project_gid}/tasks".replace("{project_gid}", project_gid) - return self.client.get_collection(path, params, **options) - - def get_tasks_for_section(self, section_gid, params=None, **options): - """Get tasks from a section - :param str section_gid: (required) The globally unique identifier for the section. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/sections/{section_gid}/tasks".replace("{section_gid}", section_gid) - return self.client.get_collection(path, params, **options) - - def get_tasks_for_tag(self, tag_gid, params=None, **options): - """Get tasks from a tag - :param str tag_gid: (required) Globally unique identifier for the tag. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tags/{tag_gid}/tasks".replace("{tag_gid}", tag_gid) - return self.client.get_collection(path, params, **options) - - def get_tasks_for_user_task_list(self, user_task_list_gid, params=None, **options): - """Get tasks from a user task list - :param str user_task_list_gid: (required) Globally unique identifier for the user task list. - :param Object params: Parameters for the request - - completed_since {str}: Only return tasks that are either incomplete or that have been completed since this time. Accepts a date-time string or the keyword *now*. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/user_task_lists/{user_task_list_gid}/tasks".replace("{user_task_list_gid}", user_task_list_gid) - return self.client.get_collection(path, params, **options) - - def remove_dependencies_for_task(self, task_gid, params=None, **options): - """Unlink dependencies from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/removeDependencies".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def remove_dependents_for_task(self, task_gid, params=None, **options): - """Unlink dependents from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/removeDependents".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def remove_follower_for_task(self, task_gid, params=None, **options): - """Remove followers from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/removeFollowers".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def remove_project_for_task(self, task_gid, params=None, **options): - """Remove a project from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/removeProject".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def remove_tag_for_task(self, task_gid, params=None, **options): - """Remove a tag from a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/removeTag".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def search_tasks_for_workspace(self, workspace_gid, params=None, **options): - """Search tasks in a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - - text {str}: Performs full-text search on both task name and description - - resource_subtype {str}: Filters results by the task's resource_subtype - - assignee_any {str}: Comma-separated list of user identifiers - - assignee_not {str}: Comma-separated list of user identifiers - - portfolios_any {str}: Comma-separated list of portfolio IDs - - projects_any {str}: Comma-separated list of project IDs - - projects_not {str}: Comma-separated list of project IDs - - projects_all {str}: Comma-separated list of project IDs - - sections_any {str}: Comma-separated list of section or column IDs - - sections_not {str}: Comma-separated list of section or column IDs - - sections_all {str}: Comma-separated list of section or column IDs - - tags_any {str}: Comma-separated list of tag IDs - - tags_not {str}: Comma-separated list of tag IDs - - tags_all {str}: Comma-separated list of tag IDs - - teams_any {str}: Comma-separated list of team IDs - - followers_not {str}: Comma-separated list of user identifiers - - created_by_any {str}: Comma-separated list of user identifiers - - created_by_not {str}: Comma-separated list of user identifiers - - assigned_by_any {str}: Comma-separated list of user identifiers - - assigned_by_not {str}: Comma-separated list of user identifiers - - liked_by_not {str}: Comma-separated list of user identifiers - - commented_on_by_not {str}: Comma-separated list of user identifiers - - due_on_before {date}: ISO 8601 date string - - due_on_after {date}: ISO 8601 date string - - due_on {date}: ISO 8601 date string or `null` - - due_at_before {datetime}: ISO 8601 datetime string - - due_at_after {datetime}: ISO 8601 datetime string - - start_on_before {date}: ISO 8601 date string - - start_on_after {date}: ISO 8601 date string - - start_on {date}: ISO 8601 date string or `null` - - created_on_before {date}: ISO 8601 date string - - created_on_after {date}: ISO 8601 date string - - created_on {date}: ISO 8601 date string or `null` - - created_at_before {datetime}: ISO 8601 datetime string - - created_at_after {datetime}: ISO 8601 datetime string - - completed_on_before {date}: ISO 8601 date string - - completed_on_after {date}: ISO 8601 date string - - completed_on {date}: ISO 8601 date string or `null` - - completed_at_before {datetime}: ISO 8601 datetime string - - completed_at_after {datetime}: ISO 8601 datetime string - - modified_on_before {date}: ISO 8601 date string - - modified_on_after {date}: ISO 8601 date string - - modified_on {date}: ISO 8601 date string or `null` - - modified_at_before {datetime}: ISO 8601 datetime string - - modified_at_after {datetime}: ISO 8601 datetime string - - is_blocking {bool}: Filter to incomplete tasks with dependents - - is_blocked {bool}: Filter to tasks with incomplete dependencies - - has_attachment {bool}: Filter to tasks with attachments - - completed {bool}: Filter to completed tasks - - is_subtask {bool}: Filter to subtasks - - sort_by {str}: One of `due_date`, `created_at`, `completed_at`, `likes`, or `modified_at`, defaults to `modified_at` - - sort_ascending {bool}: Default `false` - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/tasks/search".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) - - def set_parent_for_task(self, task_gid, params=None, **options): - """Set the parent of a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}/setParent".replace("{task_gid}", task_gid) - return self.client.post(path, params, **options) - - def update_task(self, task_gid, params=None, **options): - """Update a task - :param str task_gid: (required) The task to operate on. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/tasks/{task_gid}".replace("{task_gid}", task_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/team_memberships.py b/asana/resources/gen/team_memberships.py deleted file mode 100644 index ef3ba93c..00000000 --- a/asana/resources/gen/team_memberships.py +++ /dev/null @@ -1,70 +0,0 @@ -# coding=utf-8 -class _TeamMemberships: - - def __init__(self, client=None): - self.client = client - - def get_team_membership(self, team_membership_gid, params=None, **options): - """Get a team membership - :param str team_membership_gid: (required) - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/team_memberships/{team_membership_gid}".replace("{team_membership_gid}", team_membership_gid) - return self.client.get(path, params, **options) - - def get_team_memberships(self, params=None, **options): - """Get team memberships - :param Object params: Parameters for the request - - team {str}: Globally unique identifier for the team. - - user {str}: A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. This parameter must be used with the workspace parameter. - - workspace {str}: Globally unique identifier for the workspace. This parameter must be used with the user parameter. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/team_memberships" - return self.client.get_collection(path, params, **options) - - def get_team_memberships_for_team(self, team_gid, params=None, **options): - """Get memberships from a team - :param str team_gid: (required) Globally unique identifier for the team. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams/{team_gid}/team_memberships".replace("{team_gid}", team_gid) - return self.client.get_collection(path, params, **options) - - def get_team_memberships_for_user(self, user_gid, params=None, **options): - """Get memberships from a user - :param str user_gid: (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param Object params: Parameters for the request - - workspace {str}: (required) Globally unique identifier for the workspace. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/users/{user_gid}/team_memberships".replace("{user_gid}", user_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/teams.py b/asana/resources/gen/teams.py deleted file mode 100644 index 459f0b34..00000000 --- a/asana/resources/gen/teams.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -class _Teams: - - def __init__(self, client=None): - self.client = client - - def add_user_for_team(self, team_gid, params=None, **options): - """Add a user to a team - :param str team_gid: (required) Globally unique identifier for the team. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams/{team_gid}/addUser".replace("{team_gid}", team_gid) - return self.client.post(path, params, **options) - - def create_team(self, params=None, **options): - """Create a team - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams" - return self.client.post(path, params, **options) - - def get_team(self, team_gid, params=None, **options): - """Get a team - :param str team_gid: (required) Globally unique identifier for the team. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams/{team_gid}".replace("{team_gid}", team_gid) - return self.client.get(path, params, **options) - - def get_teams_for_user(self, user_gid, params=None, **options): - """Get teams for a user - :param str user_gid: (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param Object params: Parameters for the request - - organization {str}: (required) The workspace or organization to filter teams on. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/users/{user_gid}/teams".replace("{user_gid}", user_gid) - return self.client.get_collection(path, params, **options) - - def get_teams_for_workspace(self, workspace_gid, params=None, **options): - """Get teams in a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/teams".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) - - def remove_user_for_team(self, team_gid, params=None, **options): - """Remove a user from a team - :param str team_gid: (required) Globally unique identifier for the team. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams/{team_gid}/removeUser".replace("{team_gid}", team_gid) - return self.client.post(path, params, **options) - - def update_team(self, params=None, **options): - """Update a team - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams" - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/time_periods.py b/asana/resources/gen/time_periods.py deleted file mode 100644 index a1471b9f..00000000 --- a/asana/resources/gen/time_periods.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding=utf-8 -class _TimePeriods: - - def __init__(self, client=None): - self.client = client - - def get_time_period(self, time_period_gid, params=None, **options): - """Get a time period - :param str time_period_gid: (required) Globally unique identifier for the time period. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/time_periods/{time_period_gid}".replace("{time_period_gid}", time_period_gid) - return self.client.get(path, params, **options) - - def get_time_periods(self, params=None, **options): - """Get time periods - :param Object params: Parameters for the request - - start_on {date}: ISO 8601 date string - - end_on {date}: ISO 8601 date string - - workspace {str}: (required) Globally unique identifier for the workspace. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/time_periods" - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/typeahead.py b/asana/resources/gen/typeahead.py deleted file mode 100644 index c23110cf..00000000 --- a/asana/resources/gen/typeahead.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -class _Typeahead: - - def __init__(self, client=None): - self.client = client - - def typeahead_for_workspace(self, workspace_gid, params=None, **options): - """Get objects via typeahead - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - - resource_type {str}: (required) The type of values the typeahead should return. You can choose from one of the following: `custom_field`, `project`, `project_template`, `portfolio`, `tag`, `task`, and `user`. Note that unlike in the names of endpoints, the types listed here are in singular form (e.g. `task`). Using multiple types is not yet supported. - - type {str}: *Deprecated: new integrations should prefer the resource_type field.* - - query {str}: The string that will be used to search for relevant objects. If an empty string is passed in, the API will return results. - - count {int}: The number of results to return. The default is 20 if this parameter is omitted, with a minimum of 1 and a maximum of 100. If there are fewer results found than requested, all will be returned. - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/typeahead".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/user_task_lists.py b/asana/resources/gen/user_task_lists.py deleted file mode 100644 index b59a9d56..00000000 --- a/asana/resources/gen/user_task_lists.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -class _UserTaskLists: - - def __init__(self, client=None): - self.client = client - - def get_user_task_list(self, user_task_list_gid, params=None, **options): - """Get a user task list - :param str user_task_list_gid: (required) Globally unique identifier for the user task list. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/user_task_lists/{user_task_list_gid}".replace("{user_task_list_gid}", user_task_list_gid) - return self.client.get(path, params, **options) - - def get_user_task_list_for_user(self, user_gid, params=None, **options): - """Get a user's task list - :param str user_gid: (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param Object params: Parameters for the request - - workspace {str}: (required) The workspace in which to get the user task list. - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/users/{user_gid}/user_task_list".replace("{user_gid}", user_gid) - return self.client.get(path, params, **options) diff --git a/asana/resources/gen/users.py b/asana/resources/gen/users.py deleted file mode 100644 index 55538f6e..00000000 --- a/asana/resources/gen/users.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding=utf-8 -class _Users: - - def __init__(self, client=None): - self.client = client - - def get_favorites_for_user(self, user_gid, params=None, **options): - """Get a user's favorites - :param str user_gid: (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param Object params: Parameters for the request - - resource_type {str}: (required) The resource type of favorites to be returned. - - workspace {str}: (required) The workspace in which to get favorites. - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/users/{user_gid}/favorites".replace("{user_gid}", user_gid) - return self.client.get_collection(path, params, **options) - - def get_user(self, user_gid, params=None, **options): - """Get a user - :param str user_gid: (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/users/{user_gid}".replace("{user_gid}", user_gid) - return self.client.get(path, params, **options) - - def get_users(self, params=None, **options): - """Get multiple users - :param Object params: Parameters for the request - - workspace {str}: The workspace or organization ID to filter users on. - - team {str}: The team ID to filter users on. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/users" - return self.client.get_collection(path, params, **options) - - def get_users_for_team(self, team_gid, params=None, **options): - """Get users in a team - :param str team_gid: (required) Globally unique identifier for the team. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/teams/{team_gid}/users".replace("{team_gid}", team_gid) - return self.client.get_collection(path, params, **options) - - def get_users_for_workspace(self, workspace_gid, params=None, **options): - """Get users in a workspace or organization - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/users".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/webhooks.py b/asana/resources/gen/webhooks.py deleted file mode 100644 index 29a59840..00000000 --- a/asana/resources/gen/webhooks.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding=utf-8 -class _Webhooks: - - def __init__(self, client=None): - self.client = client - - def create_webhook(self, params=None, **options): - """Establish a webhook - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/webhooks" - return self.client.post(path, params, **options) - - def delete_webhook(self, webhook_gid, params=None, **options): - """Delete a webhook - :param str webhook_gid: (required) Globally unique identifier for the webhook. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/webhooks/{webhook_gid}".replace("{webhook_gid}", webhook_gid) - return self.client.delete(path, params, **options) - - def get_webhook(self, webhook_gid, params=None, **options): - """Get a webhook - :param str webhook_gid: (required) Globally unique identifier for the webhook. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/webhooks/{webhook_gid}".replace("{webhook_gid}", webhook_gid) - return self.client.get(path, params, **options) - - def get_webhooks(self, params=None, **options): - """Get multiple webhooks - :param Object params: Parameters for the request - - workspace {str}: (required) The workspace to query for webhooks in. - - resource {str}: Only return webhooks for the given resource. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/webhooks" - return self.client.get_collection(path, params, **options) - - def update_webhook(self, webhook_gid, params=None, **options): - """Update a webhook - :param str webhook_gid: (required) Globally unique identifier for the webhook. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/webhooks/{webhook_gid}".replace("{webhook_gid}", webhook_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/gen/workspace_memberships.py b/asana/resources/gen/workspace_memberships.py deleted file mode 100644 index ec84ddb7..00000000 --- a/asana/resources/gen/workspace_memberships.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding=utf-8 -class _WorkspaceMemberships: - - def __init__(self, client=None): - self.client = client - - def get_workspace_membership(self, workspace_membership_gid, params=None, **options): - """Get a workspace membership - :param str workspace_membership_gid: (required) - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspace_memberships/{workspace_membership_gid}".replace("{workspace_membership_gid}", workspace_membership_gid) - return self.client.get(path, params, **options) - - def get_workspace_memberships_for_user(self, user_gid, params=None, **options): - """Get workspace memberships for a user - :param str user_gid: (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/users/{user_gid}/workspace_memberships".replace("{user_gid}", user_gid) - return self.client.get_collection(path, params, **options) - - def get_workspace_memberships_for_workspace(self, workspace_gid, params=None, **options): - """Get the workspace memberships for a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - - user {str}: A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/workspace_memberships".replace("{workspace_gid}", workspace_gid) - return self.client.get_collection(path, params, **options) diff --git a/asana/resources/gen/workspaces.py b/asana/resources/gen/workspaces.py deleted file mode 100644 index 0250dffd..00000000 --- a/asana/resources/gen/workspaces.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding=utf-8 -class _Workspaces: - - def __init__(self, client=None): - self.client = client - - def add_user_for_workspace(self, workspace_gid, params=None, **options): - """Add a user to a workspace or organization - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/addUser".replace("{workspace_gid}", workspace_gid) - return self.client.post(path, params, **options) - - def get_workspace(self, workspace_gid, params=None, **options): - """Get a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}".replace("{workspace_gid}", workspace_gid) - return self.client.get(path, params, **options) - - def get_workspaces(self, params=None, **options): - """Get multiple workspaces - :param Object params: Parameters for the request - :param **options - - offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' - - limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100. - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces" - return self.client.get_collection(path, params, **options) - - def remove_user_for_workspace(self, workspace_gid, params=None, **options): - """Remove a user from a workspace or organization - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}/removeUser".replace("{workspace_gid}", workspace_gid) - return self.client.post(path, params, **options) - - def update_workspace(self, workspace_gid, params=None, **options): - """Update a workspace - :param str workspace_gid: (required) Globally unique identifier for the workspace or organization. - :param Object params: Parameters for the request - :param **options - - opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. - - opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. - :return: Object - """ - if params is None: - params = {} - path = "/workspaces/{workspace_gid}".replace("{workspace_gid}", workspace_gid) - return self.client.put(path, params, **options) diff --git a/asana/resources/goal_relationships.py b/asana/resources/goal_relationships.py deleted file mode 100644 index 8580407d..00000000 --- a/asana/resources/goal_relationships.py +++ /dev/null @@ -1,5 +0,0 @@ -from .gen.goal_relationships import _GoalRelationships - -class GoalRelationships(_GoalRelationships): - """Goal relationships resource""" - pass diff --git a/asana/resources/goals.py b/asana/resources/goals.py deleted file mode 100644 index 7d2b961d..00000000 --- a/asana/resources/goals.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.goals import _Goals - -class Goals(_Goals): - """Goals resource""" - pass diff --git a/asana/resources/jobs.py b/asana/resources/jobs.py deleted file mode 100644 index d10f7e83..00000000 --- a/asana/resources/jobs.py +++ /dev/null @@ -1,15 +0,0 @@ - -from .gen.jobs import _Jobs - -class Jobs(_Jobs): - """Jobs resource""" - def find_by_id(self, job, params={}, **options): - """Returns the complete job record for a single job. - - Parameters - ---------- - job : {Gid} The job to get. - [params] : {Object} Parameters for the request - """ - path = "/jobs/%s" % (job) - return self.client.get(path, params, **options) diff --git a/asana/resources/memberships.py b/asana/resources/memberships.py deleted file mode 100644 index 1da78a76..00000000 --- a/asana/resources/memberships.py +++ /dev/null @@ -1,5 +0,0 @@ -from .gen.memberships import _Memberships - -class Memberships(_Memberships): - """Memberships resource""" - pass diff --git a/asana/resources/message.py b/asana/resources/message.py deleted file mode 100644 index 8eeacca6..00000000 --- a/asana/resources/message.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.message import _Message - -class Message(_Message): - """Message resource""" - pass diff --git a/asana/resources/organization_exports.py b/asana/resources/organization_exports.py deleted file mode 100644 index e649b7c0..00000000 --- a/asana/resources/organization_exports.py +++ /dev/null @@ -1,30 +0,0 @@ -from .gen.organization_exports import _OrganizationExports - - -class OrganizationExports(_OrganizationExports): - """The :class:`OrganizationExports` object, which represents the resource - of the same name in Asana's API. - - """ - - def find_by_id(self, organization_export, params={}, **options): - """Returns details of a previously-requested Organization export. - - Parameters - ---------- - organization_export : {Gid} Globally unique identifier for the Organization export. - [params] : {Object} Parameters for the request - """ - path = "/organization_exports/%s" % (organization_export) - return self.client.get(path, params, **options) - - def create(self, params={}, **options): - """This method creates a request to export an Organization. Asana will complete the export at some - point after you create the request. - - Parameters - ---------- - [data] : {Object} Data for the request - - organization : {Gid} Globally unique identifier for the workspace or organization. - """ - return self.client.post("/organization_exports", params, **options) diff --git a/asana/resources/portfolio_memberships.py b/asana/resources/portfolio_memberships.py deleted file mode 100644 index ae20ffea..00000000 --- a/asana/resources/portfolio_memberships.py +++ /dev/null @@ -1,42 +0,0 @@ - -from .gen.portfolio_memberships import _PortfolioMemberships - -class PortfolioMemberships(_PortfolioMemberships): - """Portfolio Memberships resource""" - - def find_all(self, params={}, **options): - """Returns the compact portfolio membership records for the portfolio. You must - specify `portfolio`, `portfolio` and `user`, or `workspace` and `user`. - - Parameters - ---------- - [params] : {Object} Parameters for the request - - [portfolio] : {Gid} The portfolio for which to fetch memberships. - - [workspace] : {Gid} The workspace for which to fetch memberships. - - [user] : {String} The user to filter the memberships to. - """ - return self.client.get_collection("/portfolio_memberships", params, **options) - - def find_by_portfolio(self, portfolio, params={}, **options): - """Returns the compact portfolio membership records for the portfolio. - - Parameters - ---------- - portfolio : {Gid} The portfolio for which to fetch memberships. - [params] : {Object} Parameters for the request - - [user] : {String} If present, the user to filter the memberships to. - """ - path = "/portfolios/%s/portfolio_memberships" % (portfolio) - return self.client.get_collection(path, params, **options) - - def find_by_id(self, portfolio_membership, params={}, **options): - """Returns the portfolio membership record. - - Parameters - ---------- - portfolio_membership : {Gid} Globally unique identifier for the portfolio membership. - [params] : {Object} Parameters for the request - """ - path = "/portfolio_memberships/%s" % (portfolio_membership) - return self.client.get(path, params, **options) - diff --git a/asana/resources/portfolios.py b/asana/resources/portfolios.py deleted file mode 100644 index fbe27435..00000000 --- a/asana/resources/portfolios.py +++ /dev/null @@ -1,184 +0,0 @@ - -from .gen.portfolios import _Portfolios - -class Portfolios(_Portfolios): - """Portfolios resource""" - - def create(self, params={}, **options): - """Creates a new portfolio in the given workspace with the supplied name. - - Note that portfolios created in the Asana UI may have some state - (like the "Priority" custom field) which is automatically added to the - portfolio when it is created. Portfolios created via our API will **not** - be created with the same initial state to allow integrations to create - their own starting state on a portfolio. - - Parameters - ---------- - [data] : {Object} Data for the request - - workspace : {Gid} The workspace or organization in which to create the portfolio. - - name : {String} The name of the newly-created portfolio - - [color] : {String} An optional color for the portfolio - """ - return self.client.post("/portfolios", params, **options) - - def find_by_id(self, portfolio, params={}, **options): - """Returns the complete record for a single portfolio. - - Parameters - ---------- - portfolio : {Gid} The portfolio to get. - [params] : {Object} Parameters for the request - """ - path = "/portfolios/%s" % (portfolio) - return self.client.get(path, params, **options) - - def update(self, portfolio, params={}, **options): - """An existing portfolio can be updated by making a PUT request on the - URL for that portfolio. Only the fields provided in the `data` block will be - updated; any unspecified fields will remain unchanged. - - Returns the complete updated portfolio record. - - Parameters - ---------- - portfolio : {Gid} The portfolio to update. - [data] : {Object} Data for the request - """ - path = "/portfolios/%s" % (portfolio) - return self.client.put(path, params, **options) - - def delete(self, portfolio, params={}, **options): - """An existing portfolio can be deleted by making a DELETE request - on the URL for that portfolio. - - Returns an empty data record. - - Parameters - ---------- - portfolio : {Gid} The portfolio to delete. - """ - path = "/portfolios/%s" % (portfolio) - return self.client.delete(path, params, **options) - - def find_all(self, params={}, **options): - """Returns a list of the portfolios in compact representation that are owned - by the current API user. - - Parameters - ---------- - [params] : {Object} Parameters for the request - - workspace : {Gid} The workspace or organization to filter portfolios on. - - owner : {String} The user who owns the portfolio. Currently, API users can only get a - list of portfolios that they themselves own. - """ - return self.client.get_collection("/portfolios", params, **options) - - def get_items(self, portfolio, params={}, **options): - """Get a list of the items in compact form in a portfolio. - - Parameters - ---------- - portfolio : {Gid} The portfolio from which to get the list of items. - [params] : {Object} Parameters for the request - """ - path = "/portfolios/%s/items" % (portfolio) - return self.client.get_collection(path, params, **options) - - def add_item(self, portfolio, params={}, **options): - """Add an item to a portfolio. - - Returns an empty data block. - - Parameters - ---------- - portfolio : {Gid} The portfolio to which to add an item. - [data] : {Object} Data for the request - - item : {Gid} The item to add to the portfolio. - - [insert_before] : {Gid} An id of an item in this portfolio. The new item will be added before the one specified here. - `insert_before` and `insert_after` parameters cannot both be specified. - - [insert_after] : {Gid} An id of an item in this portfolio. The new item will be added after the one specified here. - `insert_before` and `insert_after` parameters cannot both be specified. - """ - path = "/portfolios/%s/addItem" % (portfolio) - return self.client.post(path, params, **options) - - def remove_item(self, portfolio, params={}, **options): - """Remove an item to a portfolio. - - Returns an empty data block. - - Parameters - ---------- - portfolio : {Gid} The portfolio from which to remove the item. - [data] : {Object} Data for the request - - item : {Gid} The item to remove from the portfolio. - """ - path = "/portfolios/%s/removeItem" % (portfolio) - return self.client.post(path, params, **options) - - def add_members(self, portfolio, params={}, **options): - """Adds the specified list of users as members of the portfolio. Returns the updated portfolio record. - - Parameters - ---------- - portfolio : {Gid} The portfolio to add members to. - [data] : {Object} Data for the request - - members : {Array} An array of user ids. - """ - path = "/portfolios/%s/addMembers" % (portfolio) - return self.client.post(path, params, **options) - - def remove_members(self, portfolio, params={}, **options): - """Removes the specified list of members from the portfolio. Returns the updated portfolio record. - - Parameters - ---------- - portfolio : {Gid} The portfolio to remove members from. - [data] : {Object} Data for the request - - members : {Array} An array of user ids. - """ - path = "/portfolios/%s/removeMembers" % (portfolio) - return self.client.post(path, params, **options) - - def custom_field_settings(self, portfolio, params={}, **options): - """Get the custom field settings on a portfolio. - - Parameters - ---------- - portfolio : {Gid} The portfolio from which to get the custom field settings. - [params] : {Object} Parameters for the request - """ - path = "/portfolios/%s/custom_field_settings" % (portfolio) - return self.client.get_collection(path, params, **options) - - def add_custom_field_setting(self, portfolio, params={}, **options): - """Create a new custom field setting on the portfolio. Returns the full - record for the new custom field setting. - - Parameters - ---------- - portfolio : {Gid} The portfolio onto which to add the custom field. - [data] : {Object} Data for the request - - custom_field : {Gid} The id of the custom field to add to the portfolio. - - [is_important] : {Boolean} Whether this field should be considered important to this portfolio (for instance, to display in the list view of items in the portfolio). - - [insert_before] : {Gid} An id of a custom field setting on this portfolio. The new custom field setting will be added before this one. - `insert_before` and `insert_after` parameters cannot both be specified. - - [insert_after] : {Gid} An id of a custom field setting on this portfolio. The new custom field setting will be added after this one. - `insert_before` and `insert_after` parameters cannot both be specified. - """ - path = "/portfolios/%s/addCustomFieldSetting" % (portfolio) - return self.client.post(path, params, **options) - - def remove_custom_field_setting(self, portfolio, params={}, **options): - """Remove a custom field setting on the portfolio. Returns an empty data - block. - - Parameters - ---------- - portfolio : {Gid} The portfolio from which to remove the custom field. - [data] : {Object} Data for the request - - custom_field : {Gid} The id of the custom field to remove from this portfolio. - """ - path = "/portfolios/%s/removeCustomFieldSetting" % (portfolio) - return self.client.post(path, params, **options) diff --git a/asana/resources/project_briefs.py b/asana/resources/project_briefs.py deleted file mode 100644 index ff73b5d1..00000000 --- a/asana/resources/project_briefs.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.project_briefs import _ProjectBriefs - -class ProjectBriefs(_ProjectBriefs): - """ProjectBriefs resource""" - pass diff --git a/asana/resources/project_memberships.py b/asana/resources/project_memberships.py deleted file mode 100644 index ec44a91b..00000000 --- a/asana/resources/project_memberships.py +++ /dev/null @@ -1,29 +0,0 @@ - -from .gen.project_memberships import _ProjectMemberships - -class ProjectMemberships(_ProjectMemberships): - """Project Memberships resource""" - - def find_by_project(self, project, params={}, **options): - """Returns the compact project membership records for the project. - - Parameters - ---------- - project : {Gid} The project for which to fetch memberships. - [params] : {Object} Parameters for the request - - [user] : {String} If present, the user to filter the memberships to. - """ - path = "/projects/%s/project_memberships" % (project) - return self.client.get_collection(path, params, **options) - - def find_by_id(self, project_membership, params={}, **options): - """Returns the project membership record. - - Parameters - ---------- - project_membership : {Gid} Globally unique identifier for the project membership. - [params] : {Object} Parameters for the request - """ - path = "/project_memberships/%s" % (project_membership) - return self.client.get(path, params, **options) - diff --git a/asana/resources/project_statuses.py b/asana/resources/project_statuses.py deleted file mode 100644 index 397e0bec..00000000 --- a/asana/resources/project_statuses.py +++ /dev/null @@ -1,56 +0,0 @@ - -from .gen.project_statuses import _ProjectStatuses - -class ProjectStatuses(_ProjectStatuses): - """Project Statuses resource""" - def create(self, project, params={}, **options): - self.create_in_project(project, params, **options) - - def create_in_project(self, project, params={}, **options): - """Creates a new status update on the project. - - Returns the full record of the newly created project status update. - - Parameters - ---------- - project : {Gid} The project on which to create a status update. - [data] : {Object} Data for the request - - text : {String} The text of the project status update. - - color : {String} The color to associate with the status update. Must be one of `"red"`, `"yellow"`, or `"green"`. - """ - path = "/projects/%s/project_statuses" % (project) - return self.client.post(path, params, **options) - - def find_by_project(self, project, params={}, **options): - """Returns the compact project status update records for all updates on the project. - - Parameters - ---------- - project : {Gid} The project to find status updates for. - [params] : {Object} Parameters for the request - """ - path = "/projects/%s/project_statuses" % (project) - return self.client.get_collection(path, params, **options) - - def find_by_id(self, project_status, params={}, **options): - """Returns the complete record for a single status update. - - Parameters - ---------- - project-status : {Gid} The project status update to get. - [params] : {Object} Parameters for the request - """ - path = "/project_statuses/%s" % (project_status) - return self.client.get(path, params, **options) - - def delete(self, project_status, params={}, **options): - """Deletes a specific, existing project status update. - - Returns an empty data record. - - Parameters - ---------- - project-status : {Gid} The project status update to delete. - """ - path = "/project_statuses/%s" % (project_status) - return self.client.delete(path, params, **options) diff --git a/asana/resources/project_templates.py b/asana/resources/project_templates.py deleted file mode 100644 index 3715a537..00000000 --- a/asana/resources/project_templates.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.project_templates import _ProjectTemplates - -class ProjectTemplates(_ProjectTemplates): - """ProjectTemplates resource""" - pass diff --git a/asana/resources/projects.py b/asana/resources/projects.py deleted file mode 100644 index d4c38c9f..00000000 --- a/asana/resources/projects.py +++ /dev/null @@ -1,258 +0,0 @@ - -from .gen.projects import _Projects - -class Projects(_Projects): - """Projects resource""" - def create(self, params={}, **options): - """Creates a new project in a workspace or team. - - Every project is required to be created in a specific workspace or - organization, and this cannot be changed once set. Note that you can use - the `workspace` parameter regardless of whether or not it is an - organization. - - If the workspace for your project _is_ an organization, you must also - supply a `team` to share the project with. - - Returns the full record of the newly created project. - - Parameters - ---------- - [data] : {Object} Data for the request - - workspace : {Gid} The workspace or organization to create the project in. - - [team] : {Gid} If creating in an organization, the specific team to create the - project in. - """ - return self.client.post("/projects", params, **options) - - def create_in_workspace(self, workspace, params={}, **options): - """If the workspace for your project _is_ an organization, you must also - supply a `team` to share the project with. - - Returns the full record of the newly created project. - - Parameters - ---------- - workspace : {Gid} The workspace or organization to create the project in. - [data] : {Object} Data for the request - """ - path = "/workspaces/%s/projects" % (workspace) - return self.client.post(path, params, **options) - - def create_in_team(self, team, params={}, **options): - """Creates a project shared with the given team. - - Returns the full record of the newly created project. - - Parameters - ---------- - team : {Gid} The team to create the project in. - [data] : {Object} Data for the request - """ - path = "/teams/%s/projects" % (team) - return self.client.post(path, params, **options) - - def find_by_id(self, project, params={}, **options): - """Returns the complete project record for a single project. - - Parameters - ---------- - project : {Gid} The project to get. - [params] : {Object} Parameters for the request - """ - path = "/projects/%s" % (project) - return self.client.get(path, params, **options) - - def update(self, project, params={}, **options): - """A specific, existing project can be updated by making a PUT request on the - URL for that project. Only the fields provided in the `data` block will be - updated; any unspecified fields will remain unchanged. - - When using this method, it is best to specify only those fields you wish - to change, or else you may overwrite changes made by another user since - you last retrieved the task. - - Returns the complete updated project record. - - Parameters - ---------- - project : {Gid} The project to update. - [data] : {Object} Data for the request - """ - path = "/projects/%s" % (project) - return self.client.put(path, params, **options) - - def delete(self, project, params={}, **options): - """A specific, existing project can be deleted by making a DELETE request - on the URL for that project. - - Returns an empty data record. - - Parameters - ---------- - project : {Gid} The project to delete. - """ - path = "/projects/%s" % (project) - return self.client.delete(path, params, **options) - - def duplicate_project(self, project, params={}, **options): - """Creates and returns a job that will asynchronously handle the duplication. - - Parameters - ---------- - project : {Gid} The project to duplicate. - [data] : {Object} Data for the request - - name : {String} The name of the new project. - - [team] : {Gid} Sets the team of the new project. If team is not defined, the new project - will be in the same team as the the original project. - - [include] : {Array} The elements that will be duplicated to the new project. - Tasks are always included. - - [schedule_dates] : {String} A dictionary of options to auto-shift dates. - `task_dates` must be included to use this option. - Requires either `start_on` or `due_on`, but not both. - `start_on` will set the first start date of the new - project to the given date, while `due_on` will set the last due date - to the given date. Both will offset the remaining dates by the same amount - of the original project. - """ - path = "/projects/%s/duplicate" % (project) - return self.client.post(path, params, **options) - - def find_all(self, params={}, **options): - """Returns the compact project records for some filtered set of projects. - Use one or more of the parameters provided to filter the projects returned. - - Parameters - ---------- - [params] : {Object} Parameters for the request - - [workspace] : {Gid} The workspace or organization to filter projects on. - - [team] : {Gid} The team to filter projects on. - - [is_template] : {Boolean} **Note: This parameter can only be included if a team is also defined, or the workspace is not an organization** - Filters results to include only template projects. - - [archived] : {Boolean} Only return projects whose `archived` field takes on the value of - this parameter. - """ - return self.client.get_collection("/projects", params, **options) - - def find_by_workspace(self, workspace, params={}, **options): - """Returns the compact project records for all projects in the workspace. - - Parameters - ---------- - workspace : {Gid} The workspace or organization to find projects in. - [params] : {Object} Parameters for the request - - [is_template] : {Boolean} **Note: This parameter can only be included if a team is also defined, or the workspace is not an organization** - Filters results to include only template projects. - - [archived] : {Boolean} Only return projects whose `archived` field takes on the value of - this parameter. - """ - path = "/workspaces/%s/projects" % (workspace) - return self.client.get_collection(path, params, **options) - - def find_by_team(self, team, params={}, **options): - """Returns the compact project records for all projects in the team. - - Parameters - ---------- - team : {Gid} The team to find projects in. - [params] : {Object} Parameters for the request - - [is_template] : {Boolean} Filters results to include only template projects. - - [archived] : {Boolean} Only return projects whose `archived` field takes on the value of - this parameter. - """ - path = "/teams/%s/projects" % (team) - return self.client.get_collection(path, params, **options) - - def tasks(self, project, params={}, **options): - """Returns the compact task records for all tasks within the given project, - ordered by their priority within the project. Tasks can exist in more than one project at a time. - - Parameters - ---------- - project : {Gid} The project in which to search for tasks. - [params] : {Object} Parameters for the request - """ - path = "/projects/%s/tasks" % (project) - return self.client.get_collection(path, params, **options) - - def add_followers(self, project, params={}, **options): - """Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if - the users are not already members of the project they will also become members as a result of this operation. - Returns the updated project record. - - Parameters - ---------- - project : {Gid} The project to add followers to. - [data] : {Object} Data for the request - - followers : {Array} An array of followers to add to the project. - """ - path = "/projects/%s/addFollowers" % (project) - return self.client.post(path, params, **options) - - def remove_followers(self, project, params={}, **options): - """Removes the specified list of users from following the project, this will not affect project membership status. - Returns the updated project record. - - Parameters - ---------- - project : {Gid} The project to remove followers from. - [data] : {Object} Data for the request - - followers : {Array} An array of followers to remove from the project. - """ - path = "/projects/%s/removeFollowers" % (project) - return self.client.post(path, params, **options) - - def add_members(self, project, params={}, **options): - """Adds the specified list of users as members of the project. Returns the updated project record. - - Parameters - ---------- - project : {Gid} The project to add members to. - [data] : {Object} Data for the request - - members : {Array} An array of user ids. - """ - path = "/projects/%s/addMembers" % (project) - return self.client.post(path, params, **options) - - def remove_members(self, project, params={}, **options): - """Removes the specified list of members from the project. Returns the updated project record. - - Parameters - ---------- - project : {Gid} The project to remove members from. - [data] : {Object} Data for the request - - members : {Array} An array of user ids. - """ - path = "/projects/%s/removeMembers" % (project) - return self.client.post(path, params, **options) - - def add_custom_field_setting(self, project, params={}, **options): - """Create a new custom field setting on the project. - - Parameters - ---------- - project : {Gid} The project to associate the custom field with - [data] : {Object} Data for the request - - custom_field : {Gid} The id of the custom field to associate with this project. - - [is_important] : {Boolean} Whether this field should be considered important to this project. - - [insert_before] : {Gid} An id of a Custom Field Settings on this project, before which the new Custom Field Settings will be added. - `insert_before` and `insert_after` parameters cannot both be specified. - - [insert_after] : {Gid} An id of a Custom Field Settings on this project, after which the new Custom Field Settings will be added. - `insert_before` and `insert_after` parameters cannot both be specified. - """ - path = "/projects/%s/addCustomFieldSetting" % (project) - return self.client.post(path, params, **options) - - def remove_custom_field_setting(self, project, params={}, **options): - """Remove a custom field setting on the project. - - Parameters - ---------- - project : {Gid} The project to associate the custom field with - [data] : {Object} Data for the request - - [custom_field] : {Gid} The id of the custom field to remove from this project. - """ - path = "/projects/%s/removeCustomFieldSetting" % (project) - return self.client.post(path, params, **options) - - diff --git a/asana/resources/sections.py b/asana/resources/sections.py deleted file mode 100644 index 002acedc..00000000 --- a/asana/resources/sections.py +++ /dev/null @@ -1,119 +0,0 @@ -from .gen.sections import _Sections - - -class Sections(_Sections): - """The :class:`Sections` object, which represents the resource of the same - name in Asana's API. - - """ - def create_in_project(self, project, params={}, **options): - """Creates a new section in a project. - - Returns the full record of the newly created section. - - Parameters - ---------- - project : {Gid} The project to create the section in - [data] : {Object} Data for the request - - name : {String} The text to be displayed as the section name. This cannot be an empty string. - """ - path = "/projects/%s/sections" % (project) - return self.client.post(path, params, **options) - - def find_by_project(self, project, params={}, **options): - """Returns the compact records for all sections in the specified project. - - Parameters - ---------- - project : {Gid} The project to get sections from. - [params] : {Object} Parameters for the request - """ - path = "/projects/%s/sections" % (project) - return self.client.get_collection(path, params, **options) - - def find_by_id(self, section, params={}, **options): - """Returns the complete record for a single section. - - Parameters - ---------- - section : {Gid} The section to get. - [params] : {Object} Parameters for the request - """ - path = "/sections/%s" % (section) - return self.client.get(path, params, **options) - - def update(self, section, params={}, **options): - """A specific, existing section can be updated by making a PUT request on - the URL for that project. Only the fields provided in the `data` block - will be updated; any unspecified fields will remain unchanged. (note that - at this time, the only field that can be updated is the `name` field.) - - When using this method, it is best to specify only those fields you wish - to change, or else you may overwrite changes made by another user since - you last retrieved the task. - - Returns the complete updated section record. - - Parameters - ---------- - section : {Gid} The section to update. - [data] : {Object} Data for the request - """ - path = "/sections/%s" % (section) - return self.client.put(path, params, **options) - - def delete(self, section, params={}, **options): - """A specific, existing section can be deleted by making a DELETE request - on the URL for that section. - - Note that sections must be empty to be deleted. - - The last remaining section in a board view cannot be deleted. - - Returns an empty data block. - - Parameters - ---------- - section : {Gid} The section to delete. - """ - path = "/sections/%s" % (section) - return self.client.delete(path, params, **options) - - def add_task(self, section, params={}, **options): - """Add a task to a specific, existing section. This will remove the task from other sections of the project. - - The task will be inserted at the top of a section unless an `insert_before` or `insert_after` parameter is declared. - - This does not work for separators (tasks with the `resource_subtype` of section). - - Parameters - ---------- - section : {Gid} The section to add a task to - [data] : {Object} Data for the request - - task : {Gid} The task to add to this section - - [insert_before] : {Gid} Insert the given task immediately before the task specified by this parameter. Cannot be provided together with `insert_after`. - - [insert_after] : {Gid} Insert the given task immediately after the task specified by this parameter. Cannot be provided together with `insert_before`. - """ - path = "/sections/%s/addTask" % (section) - return self.client.post(path, params, **options) - - def insert_in_project(self, project, params={}, **options): - """Move sections relative to each other in a board view. One of - `before_section` or `after_section` is required. - - Sections cannot be moved between projects. - - At this point in time, moving sections is not supported in list views, only board views. - - Returns an empty data block. - - Parameters - ---------- - project : {Gid} The project in which to reorder the given section - [data] : {Object} Data for the request - - section : {Gid} The section to reorder - - [before_section] : {Gid} Insert the given section immediately before the section specified by this parameter. - - [after_section] : {Gid} Insert the given section immediately after the section specified by this parameter. - """ - path = "/projects/%s/sections/insert" % (project) - return self.client.post(path, params, **options) diff --git a/asana/resources/status_updates.py b/asana/resources/status_updates.py deleted file mode 100644 index c061a7bb..00000000 --- a/asana/resources/status_updates.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.status_updates import _StatusUpdates - -class StatusUpdates(_StatusUpdates): - """Goals resource""" - pass diff --git a/asana/resources/stories.py b/asana/resources/stories.py deleted file mode 100644 index edf2913c..00000000 --- a/asana/resources/stories.py +++ /dev/null @@ -1,70 +0,0 @@ - -from .gen.stories import _Stories - -class Stories(_Stories): - """Stories resource""" - def find_by_task(self, task, params={}, **options): - """Returns the compact records for all stories on the task. - - Parameters - ---------- - task : {Gid} Globally unique identifier for the task. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s/stories" % (task) - return self.client.get_collection(path, params, **options) - - def find_by_id(self, story, params={}, **options): - """Returns the full record for a single story. - - Parameters - ---------- - story : {Gid} Globally unique identifier for the story. - [params] : {Object} Parameters for the request - """ - path = "/stories/%s" % (story) - return self.client.get(path, params, **options) - - def create_on_task(self, task, params={}, **options): - """Adds a comment to a task. The comment will be authored by the - currently authenticated user, and timestamped when the server receives - the request. - - Returns the full record for the new story added to the task. - - Parameters - ---------- - task : {Id} Globally unique identifier for the task. - [data] : {Object} Data for the request - - text : {String} The plain text of the comment to add. - """ - path = "/tasks/%s/stories" % (task) - return self.client.post(path, params, **options) - - def update(self, story, params={}, **options): - """Updates the story and returns the full record for the updated story. - Only comment stories can have their text updated, and only comment stories and - attachment stories can be pinned. Only one of `text` and `html_text` can be specified. - - Parameters - ---------- - story : {Gid} Globally unique identifier for the story. - [data] : {Object} Data for the request - - [text] : {String} The plain text with which to update the comment. - - [html_text] : {String} The rich text with which to update the comment. - - [is_pinned] : {Boolean} Whether the story should be pinned on the resource. - """ - path = "/stories/%s" % (story) - return self.client.put(path, params, **options) - - def delete(self, story, params={}, **options): - """Deletes a story. A user can only delete stories they have created. Returns an empty data record. - - Parameters - ---------- - story : {Gid} Globally unique identifier for the story. - """ - path = "/stories/%s" % (story) - return self.client.delete(path, params, **options) - - diff --git a/asana/resources/tags.py b/asana/resources/tags.py deleted file mode 100644 index 20356310..00000000 --- a/asana/resources/tags.py +++ /dev/null @@ -1,118 +0,0 @@ - -from .gen.tags import _Tags - -class Tags(_Tags): - """Tags resource""" - def create(self, params={}, **options): - """Creates a new tag in a workspace or organization. - - Every tag is required to be created in a specific workspace or - organization, and this cannot be changed once set. Note that you can use - the `workspace` parameter regardless of whether or not it is an - organization. - - Returns the full record of the newly created tag. - - Parameters - ---------- - [data] : {Object} Data for the request - - workspace : {Gid} The workspace or organization to create the tag in. - """ - return self.client.post("/tags", params, **options) - - def create_in_workspace(self, workspace, params={}, **options): - """Creates a new tag in a workspace or organization. - - Every tag is required to be created in a specific workspace or - organization, and this cannot be changed once set. Note that you can use - the `workspace` parameter regardless of whether or not it is an - organization. - - Returns the full record of the newly created tag. - - Parameters - ---------- - workspace : {Gid} The workspace or organization to create the tag in. - [data] : {Object} Data for the request - """ - path = "/workspaces/%s/tags" % (workspace) - return self.client.post(path, params, **options) - - def find_by_id(self, tag, params={}, **options): - """Returns the complete tag record for a single tag. - - Parameters - ---------- - tag : {Gid} The tag to get. - [params] : {Object} Parameters for the request - """ - path = "/tags/%s" % (tag) - return self.client.get(path, params, **options) - - def update(self, tag, params={}, **options): - """Updates the properties of a tag. Only the fields provided in the `data` - block will be updated; any unspecified fields will remain unchanged. - - When using this method, it is best to specify only those fields you wish - to change, or else you may overwrite changes made by another user since - you last retrieved the task. - - Returns the complete updated tag record. - - Parameters - ---------- - tag : {Gid} The tag to update. - [data] : {Object} Data for the request - """ - path = "/tags/%s" % (tag) - return self.client.put(path, params, **options) - - def delete(self, tag, params={}, **options): - """A specific, existing tag can be deleted by making a DELETE request - on the URL for that tag. - - Returns an empty data record. - - Parameters - ---------- - tag : {Gid} The tag to delete. - """ - path = "/tags/%s" % (tag) - return self.client.delete(path, params, **options) - - def find_all(self, params={}, **options): - """Returns the compact tag records for some filtered set of tags. - Use one or more of the parameters provided to filter the tags returned. - - Parameters - ---------- - [params] : {Object} Parameters for the request - - [workspace] : {Gid} The workspace or organization to filter tags on. - - [team] : {Gid} The team to filter tags on. - - [archived] : {Boolean} Only return tags whose `archived` field takes on the value of - this parameter. - """ - return self.client.get_collection("/tags", params, **options) - - def find_by_workspace(self, workspace, params={}, **options): - """Returns the compact tag records for all tags in the workspace. - - Parameters - ---------- - workspace : {Gid} The workspace or organization to find tags in. - [params] : {Object} Parameters for the request - """ - path = "/workspaces/%s/tags" % (workspace) - return self.client.get_collection(path, params, **options) - - def get_tasks_with_tag(self, tag, params={}, **options): - """Returns the compact task records for all tasks with the given tag. - Tasks can have more than one tag at a time. - Parameters - ---------- - tag : {Id} The tag to fetch tasks from. - [params] : {Object} Parameters for the request - """ - path = "/tags/%s/tasks" % (tag) - return self.client.get_collection(path, params, **options) - diff --git a/asana/resources/tasks.py b/asana/resources/tasks.py deleted file mode 100644 index 0f6436a6..00000000 --- a/asana/resources/tasks.py +++ /dev/null @@ -1,472 +0,0 @@ - -from .gen.tasks import _Tasks - -class Tasks(_Tasks): - """Tasks resource""" - def set_parent(self, task_id, params={}, **options): - """Changes the parent of a task. Each task may only be a subtask of a single - parent, or no parent task at all. Returns an empty data block. - - Parameters - ---------- - task : {Id} Globally unique identifier for the task. - [data] : {Object} Data for the request - - parent : {Id} The new parent of the task, or `null` for no parent. - """ - path = '/tasks/%s/setParent' % (task_id) - return self.client.post(path, params, **options) - - def create(self, params={}, **options): - """Creating a new task is as easy as POSTing to the `/tasks` endpoint - with a data block containing the fields you'd like to set on the task. - Any unspecified fields will take on default values. - - Every task is required to be created in a specific workspace, and this - workspace cannot be changed once set. The workspace need not be set - explicitly if you specify `projects` or a `parent` task instead. - - `projects` can be a comma separated list of projects, or just a single - project the task should belong to. - - Parameters - ---------- - [data] : {Object} Data for the request - - [workspace] : {Gid} The workspace to create a task in. - """ - return self.client.post("/tasks", params, **options) - - def create_in_workspace(self, workspace, params={}, **options): - """Creating a new task is as easy as POSTing to the `/tasks` endpoint - with a data block containing the fields you'd like to set on the task. - Any unspecified fields will take on default values. - - Every task is required to be created in a specific workspace, and this - workspace cannot be changed once set. The workspace need not be set - explicitly if you specify a `project` or a `parent` task instead. - - Parameters - ---------- - workspace : {Gid} The workspace to create a task in. - [data] : {Object} Data for the request - """ - path = "/workspaces/%s/tasks" % (workspace) - return self.client.post(path, params, **options) - - def find_by_id(self, task, params={}, **options): - """Returns the complete task record for a single task. - - Parameters - ---------- - task : {Gid} The task to get. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s" % (task) - return self.client.get(path, params, **options) - - def update(self, task, params={}, **options): - """A specific, existing task can be updated by making a PUT request on the - URL for that task. Only the fields provided in the `data` block will be - updated; any unspecified fields will remain unchanged. - - When using this method, it is best to specify only those fields you wish - to change, or else you may overwrite changes made by another user since - you last retrieved the task. - - Returns the complete updated task record. - - Parameters - ---------- - task : {Gid} The task to update. - [data] : {Object} Data for the request - """ - path = "/tasks/%s" % (task) - return self.client.put(path, params, **options) - - def delete(self, task, params={}, **options): - """A specific, existing task can be deleted by making a DELETE request on the - URL for that task. Deleted tasks go into the "trash" of the user making - the delete request. Tasks can be recovered from the trash within a period - of 30 days; afterward they are completely removed from the system. - - Returns an empty data record. - - Parameters - ---------- - task : {Gid} The task to delete. - """ - path = "/tasks/%s" % (task) - return self.client.delete(path, params, **options) - - def duplicate_task(self, task, params={}, **options): - """Creates and returns a job that will asynchronously handle the duplication. - - Parameters - ---------- - task : {Gid} The task to duplicate. - [data] : {Object} Data for the request - - name : {String} The name of the new task. - - [include] : {Array} The fields that will be duplicated to the new task. - """ - path = "/tasks/%s/duplicate" % (task) - return self.client.post(path, params, **options) - - def find_by_project(self, project, params={}, **options): - """Returns the compact task records for all tasks within the given project, - ordered by their priority within the project. - - Parameters - ---------- - project : {Gid} The project in which to search for tasks. - [params] : {Object} Parameters for the request - """ - path = "/projects/%s/tasks" % (project) - return self.client.get_collection(path, params, **options) - - def find_by_tag(self, tag, params={}, **options): - """Returns the compact task records for all tasks with the given tag. - - Parameters - ---------- - tag : {Gid} The tag in which to search for tasks. - [params] : {Object} Parameters for the request - """ - path = "/tags/%s/tasks" % (tag) - return self.client.get_collection(path, params, **options) - - def find_by_section(self, section, params={}, **options): - """Board view only: Returns the compact section records for all tasks within the given section. - - Parameters - ---------- - section : {Gid} The section in which to search for tasks. - [params] : {Object} Parameters for the request - """ - path = "/sections/%s/tasks" % (section) - return self.client.get_collection(path, params, **options) - - def find_by_user_task_list(self, user_task_list, params={}, **options): - """Returns the compact list of tasks in a user's My Tasks list. The returned - tasks will be in order within each assignee status group of `Inbox`, - `Today`, and `Upcoming`. - - **Note:** tasks in `Later` have a different ordering in the Asana web app - than the other assignee status groups; this endpoint will still return - them in list order in `Later` (differently than they show up in Asana, - but the same order as in Asana's mobile apps). - - **Note:** Access control is enforced for this endpoint as with all Asana - API endpoints, meaning a user's private tasks will be filtered out if the - API-authenticated user does not have access to them. - - **Note:** Both complete and incomplete tasks are returned by default - unless they are filtered out (for example, setting `completed_since=now` - will return only incomplete tasks, which is the default view for "My - Tasks" in Asana.) - - Parameters - ---------- - user_task_list : {Gid} The user task list in which to search for tasks. - [params] : {Object} Parameters for the request - - [completed_since] : {String} Only return tasks that are either incomplete or that have been - completed since this time. - """ - path = "/user_task_lists/%s/tasks" % (user_task_list) - return self.client.get_collection(path, params, **options) - - def find_all(self, params={}, **options): - """Returns the compact task records for some filtered set of tasks. Use one - or more of the parameters provided to filter the tasks returned. You must - specify a `project`, `section`, `tag`, or `user_task_list` if you do not - specify `assignee` and `workspace`. - - Parameters - ---------- - [params] : {Object} Parameters for the request - - [assignee] : {String} The assignee to filter tasks on. - - [workspace] : {Gid} The workspace or organization to filter tasks on. - - [project] : {Gid} The project to filter tasks on. - - [section] : {Gid} The section to filter tasks on. - - [tag] : {Gid} The tag to filter tasks on. - - [user_task_list] : {Gid} The user task list to filter tasks on. - - [completed_since] : {String} Only return tasks that are either incomplete or that have been - completed since this time. - - [modified_since] : {String} Only return tasks that have been modified since the given time. - """ - return self.client.get_collection("/tasks", params, **options) - - def search_in_workspace(self, workspace, params={}, **options): - """The search endpoint allows you to build complex queries to find and fetch exactly the data you need from Asana. For a more comprehensive description of all the query parameters and limitations of this endpoint, see our [long-form documentation](/developers/documentation/getting-started/search-api) for this feature. - - Parameters - ---------- - workspace : {Gid} The workspace or organization in which to search for tasks. - [params] : {Object} Parameters for the request - - [resource_subtype] : {Enum} Filters results by the task's resource_subtype. - """ - path = "/workspaces/%s/tasks/search" % (workspace) - return self.client.get_collection(path, params, **options) - - def dependencies(self, task, params={}, **options): - """Returns the compact representations of all of the dependencies of a task. - - Parameters - ---------- - task : {Gid} The task to get dependencies on. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s/dependencies" % (task) - return self.client.get(path, params, **options) - - def dependents(self, task, params={}, **options): - """Returns the compact representations of all of the dependents of a task. - - Parameters - ---------- - task : {Gid} The task to get dependents on. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s/dependents" % (task) - return self.client.get(path, params, **options) - - def add_dependencies(self, task, params={}, **options): - """Marks a set of tasks as dependencies of this task, if they are not - already dependencies. *A task can have at most 15 dependencies.* - - Parameters - ---------- - task : {Gid} The task to add dependencies to. - [data] : {Object} Data for the request - - dependencies : {Array} An array of task IDs that this task should depend on. - """ - path = "/tasks/%s/addDependencies" % (task) - return self.client.post(path, params, **options) - - def add_dependents(self, task, params={}, **options): - """Marks a set of tasks as dependents of this task, if they are not already - dependents. *A task can have at most 30 dependents.* - - Parameters - ---------- - task : {Gid} The task to add dependents to. - [data] : {Object} Data for the request - - dependents : {Array} An array of task IDs that should depend on this task. - """ - path = "/tasks/%s/addDependents" % (task) - return self.client.post(path, params, **options) - - def remove_dependencies(self, task, params={}, **options): - """Unlinks a set of dependencies from this task. - - Parameters - ---------- - task : {Gid} The task to remove dependencies from. - [data] : {Object} Data for the request - - dependencies : {Array} An array of task IDs to remove as dependencies. - """ - path = "/tasks/%s/removeDependencies" % (task) - return self.client.post(path, params, **options) - - def remove_dependents(self, task, params={}, **options): - """Unlinks a set of dependents from this task. - - Parameters - ---------- - task : {Gid} The task to remove dependents from. - [data] : {Object} Data for the request - - dependents : {Array} An array of task IDs to remove as dependents. - """ - path = "/tasks/%s/removeDependents" % (task) - return self.client.post(path, params, **options) - - def add_followers(self, task, params={}, **options): - """Adds each of the specified followers to the task, if they are not already - following. Returns the complete, updated record for the affected task. - - Parameters - ---------- - task : {Gid} The task to add followers to. - [data] : {Object} Data for the request - - followers : {Array} An array of followers to add to the task. - """ - path = "/tasks/%s/addFollowers" % (task) - return self.client.post(path, params, **options) - - def remove_followers(self, task, params={}, **options): - """Removes each of the specified followers from the task if they are - following. Returns the complete, updated record for the affected task. - - Parameters - ---------- - task : {Gid} The task to remove followers from. - [data] : {Object} Data for the request - - followers : {Array} An array of followers to remove from the task. - """ - path = "/tasks/%s/removeFollowers" % (task) - return self.client.post(path, params, **options) - - def projects(self, task, params={}, **options): - """Returns a compact representation of all of the projects the task is in. - - Parameters - ---------- - task : {Gid} The task to get projects on. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s/projects" % (task) - return self.client.get_collection(path, params, **options) - - def add_project(self, task, params={}, **options): - """Adds the task to the specified project, in the optional location - specified. If no location arguments are given, the task will be added to - the end of the project. - - `addProject` can also be used to reorder a task within a project or section that - already contains it. - - At most one of `insert_before`, `insert_after`, or `section` should be - specified. Inserting into a section in an non-order-dependent way can be - done by specifying `section`, otherwise, to insert within a section in a - particular place, specify `insert_before` or `insert_after` and a task - within the section to anchor the position of this task. - - Returns an empty data block. - - Parameters - ---------- - task : {Gid} The task to add to a project. - [data] : {Object} Data for the request - - project : {Gid} The project to add the task to. - - [insert_after] : {Gid} A task in the project to insert the task after, or `null` to - insert at the beginning of the list. - - [insert_before] : {Gid} A task in the project to insert the task before, or `null` to - insert at the end of the list. - - [section] : {Gid} A section in the project to insert the task into. The task will be - inserted at the bottom of the section. - """ - path = "/tasks/%s/addProject" % (task) - return self.client.post(path, params, **options) - - def remove_project(self, task, params={}, **options): - """Removes the task from the specified project. The task will still exist - in the system, but it will not be in the project anymore. - - Returns an empty data block. - - Parameters - ---------- - task : {Gid} The task to remove from a project. - [data] : {Object} Data for the request - - project : {Gid} The project to remove the task from. - """ - path = "/tasks/%s/removeProject" % (task) - return self.client.post(path, params, **options) - - def tags(self, task, params={}, **options): - """Returns a compact representation of all of the tags the task has. - - Parameters - ---------- - task : {Gid} The task to get tags on. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s/tags" % (task) - return self.client.get_collection(path, params, **options) - - def add_tag(self, task, params={}, **options): - """Adds a tag to a task. Returns an empty data block. - - Parameters - ---------- - task : {Gid} The task to add a tag to. - [data] : {Object} Data for the request - - tag : {Gid} The tag to add to the task. - """ - path = "/tasks/%s/addTag" % (task) - return self.client.post(path, params, **options) - - def remove_tag(self, task, params={}, **options): - """Removes a tag from the task. Returns an empty data block. - - Parameters - ---------- - task : {Gid} The task to remove a tag from. - [data] : {Object} Data for the request - - tag : {Gid} The tag to remove from the task. - """ - path = "/tasks/%s/removeTag" % (task) - return self.client.post(path, params, **options) - - def subtasks(self, task, params={}, **options): - """Returns a compact representation of all of the subtasks of a task. - - Parameters - ---------- - task : {Gid} The task to get the subtasks of. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s/subtasks" % (task) - return self.client.get_collection(path, params, **options) - - def add_subtask(self, task, params={}, **options): - """Creates a new subtask and adds it to the parent task. Returns the full record - for the newly created subtask. - - Parameters - ---------- - task : {Gid} The task to add a subtask to. - [data] : {Object} Data for the request - """ - path = "/tasks/%s/subtasks" % (task) - return self.client.post(path, params, **options) - - def stories(self, task, params={}, **options): - """Returns a compact representation of all of the stories on the task. - - Parameters - ---------- - task : {Gid} The task containing the stories to get. - [params] : {Object} Parameters for the request - """ - path = "/tasks/%s/stories" % (task) - return self.client.get_collection(path, params, **options) - - def add_comment(self, task, params={}, **options): - """Adds a comment to a task. The comment will be authored by the - currently authenticated user, and timestamped when the server receives - the request. - - Returns the full record for the new story added to the task. - - Parameters - ---------- - task : {Id} Globally unique identifier for the task. - [data] : {Object} Data for the request - - text : {String} The plain text of the comment to add. - """ - path = "/tasks/%s/stories" % (task) - return self.client.post(path, params, **options) - - def insert_in_user_task_list(self, user_task_list, params={}, **options): - """Insert or reorder tasks in a user's My Tasks list. If the task was not - assigned to the owner of the user task list it will be reassigned when - this endpoint is called. If neither `insert_before` nor `insert_after` - are provided the task will be inserted at the top of the assignee's - inbox. - - Returns an empty data block. - - Parameters - ---------- - user_task_list : {Gid} Globally unique identifier for the user task list. - [data] : {Object} Data for the request - - task : {Gid} Globally unique identifier for the task. - - [insert_before] : {Gid} Insert the task before the task specified by this field. The inserted - task will inherit the `assignee_status` of this task. `insert_before` - and `insert_after` parameters cannot both be specified. - - [insert_after] : {Gid} Insert the task after the task specified by this field. The inserted - task will inherit the `assignee_status` of this task. `insert_before` - and `insert_after` parameters cannot both be specified. - """ - path = "/user_task_lists/%s/tasks/insert" % (user_task_list) - return self.client.post(path, params, **options) - diff --git a/asana/resources/team_memberships.py b/asana/resources/team_memberships.py deleted file mode 100644 index b3bba790..00000000 --- a/asana/resources/team_memberships.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.team_memberships import _TeamMemberships - -class TeamMemberships(_TeamMemberships): - """TeamMemberships resource""" - pass diff --git a/asana/resources/teams.py b/asana/resources/teams.py deleted file mode 100644 index 737f7374..00000000 --- a/asana/resources/teams.py +++ /dev/null @@ -1,86 +0,0 @@ - -from .gen.teams import _Teams - -class Teams(_Teams): - """Teams resource""" - def find_by_id(self, team, params={}, **options): - """Returns the full record for a single team. - - Parameters - ---------- - team : {Id} Globally unique identifier for the team. - [params] : {Object} Parameters for the request - """ - path = "/teams/%s" % (team) - return self.client.get(path, params, **options) - - def find_by_organization(self, organization, params={}, **options): - """Returns the compact records for all teams in the organization visible to - the authorized user. - - Parameters - ---------- - organization : {Id} Globally unique identifier for the workspace or organization. - [params] : {Object} Parameters for the request - """ - path = "/organizations/%s/teams" % (organization) - return self.client.get_collection(path, params, **options) - - def find_by_user(self, user, params={}, **options): - """Returns the compact records for all teams to which user is assigned. - - Parameters - ---------- - user : {String} An identifier for the user. Can be one of an email address, - the globally unique identifier for the user, or the keyword `me` - to indicate the current user making the request. - [params] : {Object} Parameters for the request - - [organization] : {Id} The workspace or organization to filter teams on. - """ - path = "/users/%s/teams" % (user) - return self.client.get_collection(path, params, **options) - - def users(self, team, params={}, **options): - """Returns the compact records for all users that are members of the team. - - Parameters - ---------- - team : {Id} Globally unique identifier for the team. - [params] : {Object} Parameters for the request - """ - path = "/teams/%s/users" % (team) - return self.client.get_collection(path, params, **options) - - def add_user(self, team, params={}, **options): - """The user making this call must be a member of the team in order to add others. - The user to add must exist in the same organization as the team in order to be added. - The user to add can be referenced by their globally unique user ID or their email address. - Returns the full user record for the added user. - - Parameters - ---------- - team : {Id} Globally unique identifier for the team. - [data] : {Object} Data for the request - - user : {String} An identifier for the user. Can be one of an email address, - the globally unique identifier for the user, or the keyword `me` - to indicate the current user making the request. - """ - path = "/teams/%s/addUser" % (team) - return self.client.post(path, params, **options) - - def remove_user(self, team, params={}, **options): - """The user to remove can be referenced by their globally unique user ID or their email address. - Removes the user from the specified team. Returns an empty data record. - - Parameters - ---------- - team : {Id} Globally unique identifier for the team. - [data] : {Object} Data for the request - - user : {String} An identifier for the user. Can be one of an email address, - the globally unique identifier for the user, or the keyword `me` - to indicate the current user making the request. - """ - path = "/teams/%s/removeUser" % (team) - return self.client.post(path, params, **options) - - diff --git a/asana/resources/time_periods.py b/asana/resources/time_periods.py deleted file mode 100644 index 1980735b..00000000 --- a/asana/resources/time_periods.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.time_periods import _TimePeriods - -class TimePeriods(_TimePeriods): - """TimePeriods resource""" - pass diff --git a/asana/resources/typeahead.py b/asana/resources/typeahead.py deleted file mode 100644 index bfb36814..00000000 --- a/asana/resources/typeahead.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.typeahead import _Typeahead - -class Typeahead(_Typeahead): - """Typeahead resource""" - pass diff --git a/asana/resources/user_task_lists.py b/asana/resources/user_task_lists.py deleted file mode 100644 index db4a3b70..00000000 --- a/asana/resources/user_task_lists.py +++ /dev/null @@ -1,60 +0,0 @@ - -from .gen.user_task_lists import _UserTaskLists - -class UserTaskLists(_UserTaskLists): - """User Task Lists resource""" - def find_by_user(self, user, params={}, **options): - """Returns the full record for the user task list for the given user - - Parameters - ---------- - user : {String} An identifier for the user. Can be one of an email address, - the globally unique identifier for the user, or the keyword `me` - to indicate the current user making the request. - [params] : {Object} Parameters for the request - - workspace : {Gid} Globally unique identifier for the workspace or organization. - """ - path = "/users/%s/user_task_list" % (user) - return self.client.get(path, params, **options) - - def find_by_id(self, user_task_list, params={}, **options): - """Returns the full record for a user task list. - - Parameters - ---------- - user_task_list : {Gid} Globally unique identifier for the user task list. - [params] : {Object} Parameters for the request - """ - path = "/user_task_lists/%s" % (user_task_list) - return self.client.get(path, params, **options) - - def tasks(self, user_task_list, params={}, **options): - """Returns the compact list of tasks in a user's My Tasks list. The returned - tasks will be in order within each assignee status group of `Inbox`, - `Today`, and `Upcoming`. - - **Note:** tasks in `Later` have a different ordering in the Asana web app - than the other assignee status groups; this endpoint will still return - them in list order in `Later` (differently than they show up in Asana, - but the same order as in Asana's mobile apps). - - **Note:** Access control is enforced for this endpoint as with all Asana - API endpoints, meaning a user's private tasks will be filtered out if the - API-authenticated user does not have access to them. - - **Note:** Both complete and incomplete tasks are returned by default - unless they are filtered out (for example, setting `completed_since=now` - will return only incomplete tasks, which is the default view for "My - Tasks" in Asana.) - - Parameters - ---------- - user_task_list : {Gid} The user task list in which to search for tasks. - [params] : {Object} Parameters for the request - - [completed_since] : {String} Only return tasks that are either incomplete or that have been - completed since this time. - """ - path = "/user_task_lists/%s/tasks" % (user_task_list) - return self.client.get_collection(path, params, **options) - - diff --git a/asana/resources/users.py b/asana/resources/users.py deleted file mode 100644 index 98ab7b97..00000000 --- a/asana/resources/users.py +++ /dev/null @@ -1,68 +0,0 @@ - -from .gen.users import _Users - -class Users(_Users): - """Users resource""" - def me(self, params={}, **options): - """Returns the full user record for the currently authenticated user. - - Parameters - ---------- - [params] : {Object} Parameters for the request - """ - return self.client.get("/users/me", params, **options) - - def find_by_id(self, user, params={}, **options): - """Returns the full user record for the single user with the provided ID. - - Parameters - ---------- - user : {String} An identifier for the user. Can be one of an email address, - the globally unique identifier for the user, or the keyword `me` - to indicate the current user making the request. - [params] : {Object} Parameters for the request - """ - path = "/users/%s" % (user) - return self.client.get(path, params, **options) - - def get_user_favorites(self, user, params={}, **options): - """Returns all of a user's favorites in the given workspace, of the given type. - Results are given in order (The same order as Asana's sidebar). - - Parameters - ---------- - user : {String} An identifier for the user. Can be one of an email address, - the globally unique identifier for the user, or the keyword `me` - to indicate the current user making the request. - [params] : {Object} Parameters for the request - - workspace : {Id} The workspace in which to get favorites. - - resource_type : {Enum} The resource type of favorites to be returned. - """ - path = "/users/%s/favorites" % (user) - return self.client.get_collection(path, params, **options) - - def find_by_workspace(self, workspace, params={}, **options): - """Returns the user records for all users in the specified workspace or - organization. - - Parameters - ---------- - workspace : {Id} The workspace in which to get users. - [params] : {Object} Parameters for the request - """ - path = "/workspaces/%s/users" % (workspace) - return self.client.get_collection(path, params, **options) - - def find_all(self, params={}, **options): - """Returns the user records for all users in all workspaces and organizations - accessible to the authenticated user. Accepts an optional workspace ID - parameter. - - Parameters - ---------- - [params] : {Object} Parameters for the request - - [workspace] : {Id} The workspace or organization to filter users on. - """ - return self.client.get_collection("/users", params, **options) - - diff --git a/asana/resources/webhooks.py b/asana/resources/webhooks.py deleted file mode 100644 index 25e79536..00000000 --- a/asana/resources/webhooks.py +++ /dev/null @@ -1,64 +0,0 @@ - -from .gen.webhooks import _Webhooks - -class Webhooks(_Webhooks): - """Webhooks resource""" - def create(self, params={}, **options): - """Establishing a webhook is a two-part process. First, a simple HTTP POST - similar to any other resource creation. Since you could have multiple - webhooks we recommend specifying a unique local id for each target. - - Next comes the confirmation handshake. When a webhook is created, we will - send a test POST to the `target` with an `X-Hook-Secret` header as - described in the - [Resthooks Security documentation](http://resthooks.org/docs/security/). - The target must respond with a `200 OK` and a matching `X-Hook-Secret` - header to confirm that this webhook subscription is indeed expected. - - If you do not acknowledge the webhook's confirmation handshake it will - fail to setup, and you will receive an error in response to your attempt - to create it. This means you need to be able to receive and complete the - webhook *while* the POST request is in-flight. - - Parameters - ---------- - resource : {Id} A resource ID to subscribe to. The resource can be a task or project. - target : {String} The URL to receive the HTTP POST. - [data] : {Object} Data for the request - """ - return self.client.post("/webhooks", params, **options) - - def get_all(self, params={}, **options): - """Returns the compact representation of all webhooks your app has - registered for the authenticated user in the given workspace. - - Parameters - ---------- - workspace : {Id} The workspace to query for webhooks in. - [params] : {Object} Parameters for the request - - [resource] : {Id} Only return webhooks for the given resource. - """ - return self.client.get_collection("/webhooks", params, **options) - - def get_by_id(self, webhook, params={}, **options): - """Returns the full record for the given webhook. - - Parameters - ---------- - webhook : {Id} The webhook to get. - [params] : {Object} Parameters for the request - """ - path = "/webhooks/%s" % (webhook) - return self.client.get(path, params, **options) - - def delete_by_id(self, webhook, params={}, **options): - """This method permanently removes a webhook. Note that it may be possible - to receive a request that was already in flight after deleting the - webhook, but no further requests will be issued. - - Parameters - ---------- - webhook : {Id} The webhook to delete. - """ - path = "/webhooks/%s" % (webhook) - return self.client.delete(path, params, **options) diff --git a/asana/resources/workspace_memberships.py b/asana/resources/workspace_memberships.py deleted file mode 100644 index daecf713..00000000 --- a/asana/resources/workspace_memberships.py +++ /dev/null @@ -1,6 +0,0 @@ - -from .gen.workspace_memberships import _WorkspaceMemberships - -class WorkspaceMemberships(_WorkspaceMemberships): - """WorkspaceMemberships resource""" - pass diff --git a/asana/resources/workspaces.py b/asana/resources/workspaces.py deleted file mode 100644 index c1fd2166..00000000 --- a/asana/resources/workspaces.py +++ /dev/null @@ -1,97 +0,0 @@ - -from .gen.workspaces import _Workspaces - -class Workspaces(_Workspaces): - """Workspaces resource""" - def find_by_id(self, workspace, params={}, **options): - """Returns the full workspace record for a single workspace. - - Parameters - ---------- - workspace : {Id} Globally unique identifier for the workspace or organization. - [params] : {Object} Parameters for the request - """ - path = "/workspaces/%s" % (workspace) - return self.client.get(path, params, **options) - - def find_all(self, params={}, **options): - """Returns the compact records for all workspaces visible to the authorized user. - - Parameters - ---------- - [params] : {Object} Parameters for the request - """ - return self.client.get_collection("/workspaces", params, **options) - - def update(self, workspace, params={}, **options): - """A specific, existing workspace can be updated by making a PUT request on - the URL for that workspace. Only the fields provided in the data block - will be updated; any unspecified fields will remain unchanged. - - Currently the only field that can be modified for a workspace is its `name`. - - Returns the complete, updated workspace record. - - Parameters - ---------- - workspace : {Id} The workspace to update. - [data] : {Object} Data for the request - """ - path = "/workspaces/%s" % (workspace) - return self.client.put(path, params, **options) - - def typeahead(self, workspace, params={}, **options): - """Retrieves objects in the workspace based on an auto-completion/typeahead - search algorithm. This feature is meant to provide results quickly, so do - not rely on this API to provide extremely accurate search results. The - result set is limited to a single page of results with a maximum size, - so you won't be able to fetch large numbers of results. - - Parameters - ---------- - workspace : {Id} The workspace to fetch objects from. - [params] : {Object} Parameters for the request - - resource_type : {Enum} The type of values the typeahead should return. You can choose from - one of the following: custom_field, project, tag, task, and user. - Note that unlike in the names of endpoints, the types listed here are - in singular form (e.g. `task`). Using multiple types is not yet supported. - - [type] : {Enum} **Deprecated: new integrations should prefer the resource_type field.** - - [query] : {String} The string that will be used to search for relevant objects. If an - empty string is passed in, the API will currently return an empty - result set. - - [count] : {Number} The number of results to return. The default is `20` if this - parameter is omitted, with a minimum of `1` and a maximum of `100`. - If there are fewer results found than requested, all will be returned. - """ - path = "/workspaces/%s/typeahead" % (workspace) - return self.client.get_collection(path, params, **options) - - def add_user(self, workspace, params={}, **options): - """The user can be referenced by their globally unique user ID or their email address. - Returns the full user record for the invited user. - - Parameters - ---------- - workspace : {Id} The workspace or organization to invite the user to. - [data] : {Object} Data for the request - - user : {String} An identifier for the user. Can be one of an email address, - the globally unique identifier for the user, or the keyword `me` - to indicate the current user making the request. - """ - path = "/workspaces/%s/addUser" % (workspace) - return self.client.post(path, params, **options) - - def remove_user(self, workspace, params={}, **options): - """The user making this call must be an admin in the workspace. - Returns an empty data record. - - Parameters - ---------- - workspace : {Id} The workspace or organization to invite the user to. - [data] : {Object} Data for the request - - user : {String} An identifier for the user. Can be one of an email address, - the globally unique identifier for the user, or the keyword `me` - to indicate the current user making the request. - """ - path = "/workspaces/%s/removeUser" % (workspace) - return self.client.post(path, params, **options) diff --git a/asana/session.py b/asana/session.py deleted file mode 100644 index 1d0276ce..00000000 --- a/asana/session.py +++ /dev/null @@ -1,20 +0,0 @@ -import requests -import requests_oauthlib - -class AsanaOAuth2Session(requests_oauthlib.OAuth2Session): - """Session class for making OAuth authenticated requests to Asana's API""" - - authorize_url = 'https://app.asana.com/-/oauth_authorize' - token_url = 'https://app.asana.com/-/oauth_token' - - def __init__(self, client_secret=None, **kwargs): - super(AsanaOAuth2Session, self).__init__(**kwargs) - self.client_secret = client_secret - - def authorization_url(self): - """Get a URL (and 'state' token) to redirect the user to for authentication""" - return super(AsanaOAuth2Session, self).authorization_url(self.authorize_url) - - def fetch_token(self, **kwargs): - """Exchange a code (and 'state' token) for a bearer token""" - return super(AsanaOAuth2Session, self).fetch_token(self.token_url, client_secret=self.client_secret, **kwargs) diff --git a/asana/version.py b/asana/version.py deleted file mode 100644 index 29e4a941..00000000 --- a/asana/version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '3.2.2' diff --git a/codegen/swagger/README.md b/codegen/swagger/README.md new file mode 100644 index 00000000..ca6b3110 --- /dev/null +++ b/codegen/swagger/README.md @@ -0,0 +1,74 @@ +# Swagger Codegen for the AsanaPythonClientCodegen library + +## Overview +This is a boiler-plate project to generate your own client library with Swagger. Its goal is +to get you started with the basic plumbing so you can put in your own logic. It won't work without +your changes applied. + +## What's Swagger? +The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service. + + +Check out [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the Swagger project, including additional libraries with support for other languages and more. + +## How do I use this? +At this point, you've likely generated a client setup. It will include something along these lines: + +``` +. +|- README.md // this file +|- pom.xml // build script +|-- src +|--- main +|---- java +|----- com.asana.codegen.AsanaPythonClientCodegenGenerator.java // generator file +|---- resources +|----- AsanaPythonClientCodegen // template files +|----- META-INF +|------ services +|------- io.swagger.codegen.CodegenConfig +``` + +You _will_ need to make changes in at least the following: + +`AsanaPythonClientCodegenGenerator.java` + +Templates in this folder: + +`src/main/resources/AsanaPythonClientCodegen` + +Once modified, you can run this: + +``` +mvn package +``` + +In your generator project. A single jar file will be produced in `target`. You can now use that with codegen: + +``` +java -cp /path/to/swagger-codegen-cli.jar:/path/to/your.jar io.swagger.codegen.v3.cli.SwaggerCodegen -l AsanaPythonClientCodegen -i /path/to/swagger.yaml -o ./test +``` + +Now your templates are available to the client generator and you can write output values + +## But how do I modify this? +The `ReadMe.java` has comments in it--lots of comments. There is no good substitute +for reading the code more, though. See how the `ReadMe` implements `CodegenConfig`. +That class has the signature of all values that can be overridden. + +For the templates themselves, you have a number of values available to you for generation. +You can execute the `java` command from above while passing different debug flags to show +the object you have available during client generation: + +``` +# The following additional debug options are available for all codegen targets: +# -DdebugSwagger prints the OpenAPI Specification as interpreted by the codegen +# -DdebugModels prints models passed to the template engine +# -DdebugOperations prints operations passed to the template engine +# -DdebugSupportingFiles prints additional data passed to the template engine + +java -DdebugOperations -cp /path/to/swagger-codegen-cli.jar:/path/to/your.jar io.swagger.codegen.Codegen -l AsanaPythonClientCodegen -i /path/to/swagger.yaml -o ./test +``` + +Will, for example, output the debug info for operations. You can use this info +in the `api.mustache` file. diff --git a/codegen/swagger/pom.xml b/codegen/swagger/pom.xml new file mode 100644 index 00000000..edd08158 --- /dev/null +++ b/codegen/swagger/pom.xml @@ -0,0 +1,129 @@ + + 4.0.0 + io.swagger + AsanaClientCodegen-swagger-codegen + jar + AsanaClientCodegen-swagger-codegen + 1.0.0 + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M1 + + + enforce-maven + + enforce + + + + + 2.2.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + ${build-helper-maven-plugin} + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + + + + + + + io.swagger.codegen.v3 + swagger-codegen + ${swagger-codegen-version} + provided + + + io.swagger.codegen.v3 + swagger-codegen-generators + ${swagger-codegen-generators-version} + provided + + + + UTF-8 + 3.0.44 + 1.0.41 + 1.0.0 + 4.13.1 + 3.0.0 + + diff --git a/codegen/swagger/src/main/java/com/asana/codegen/ExampleUtility.java b/codegen/swagger/src/main/java/com/asana/codegen/ExampleUtility.java new file mode 100644 index 00000000..634e95c0 --- /dev/null +++ b/codegen/swagger/src/main/java/com/asana/codegen/ExampleUtility.java @@ -0,0 +1,27 @@ +package com.asana.codegen; + +import org.json.*; +import io.swagger.codegen.v3.*; + +class ExampleUtility { + public static void tryToSetExample(CodegenParameter p) { + JSONObject obj = new JSONObject(p.jsonSchema); + + if (obj.has("example")) { + p.example = obj.get("example").toString(); + return; + } + + if (!obj.has("schema")) { + return; + } + + JSONObject schema = obj.getJSONObject("schema"); + + if (!schema.has("example")) { + return; + } + + p.example = schema.get("example").toString(); + } +} diff --git a/codegen/swagger/src/main/java/com/asana/codegen/PythonClientCodegenGenerator.java b/codegen/swagger/src/main/java/com/asana/codegen/PythonClientCodegenGenerator.java new file mode 100644 index 00000000..8b06b6dd --- /dev/null +++ b/codegen/swagger/src/main/java/com/asana/codegen/PythonClientCodegenGenerator.java @@ -0,0 +1,195 @@ +package com.asana.codegen; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.codegen.v3.*; +import io.swagger.codegen.v3.generators.python.*; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.Operation; +import io.swagger.v3.oas.models.media.Schema; + +public class PythonClientCodegenGenerator extends PythonClientCodegen { + public PythonClientCodegenGenerator() { + super(); + // Let the generator know about our code samples template so it can generate examples for our developer docs + apiDocTemplateFiles.put("code_samples.mustache", ".yaml"); + + // Remove model template files so that the generator does not generate models + modelTemplateFiles.remove("model.mustache"); + modelTestTemplateFiles.remove("model_test.mustache"); + modelDocTemplateFiles.remove("model_doc.mustache"); + } + + @Override + public void processOpts() { + // Custom generators do not set the CodegenConstants + additionalProperties.put(CodegenConstants.PACKAGE_NAME, "asana"); + setPackageName("asana"); + + additionalProperties.put(CodegenConstants.PROJECT_NAME, "asana"); + setProjectName("asana"); + + super.processOpts(); + + // Remove /models folder and /models/__init__.py file from generation + final String packageFolder = packageName.replace('.', File.separatorChar); + supportingFiles.remove(new SupportingFile("__init__model.mustache", packageFolder + File.separatorChar + "models", "__init__.py")); + + // Create a definition for collection to be used in pagination + supportingFiles.add(new SupportingFile("__init__pagination.mustache", packageFolder + File.separatorChar + "pagination", "__init__.py")); + supportingFiles.add(new SupportingFile("page_iterator.mustache", packageFolder + File.separatorChar + "pagination", "page_iterator.py")); + supportingFiles.add(new SupportingFile("event_iterator.mustache", packageFolder + File.separatorChar + "pagination", "event_iterator.py")); + } + + @Override + public String toVarName(String name) { + // Return the name as defined in the OAS rather than formatting it. EX: instead of returning modified_on_after -> modified_on.after + return name; + } + + @Override + public void setParameterExampleValue(CodegenParameter p) { + // Our example correction code must execute before super, to ensure that + // super does its special magic of determining the example type: + // https://github.com/swagger-api/swagger-codegen-generators/blob/master/src/main/java/io/swagger/codegen/v3/generators/python/PythonClientCodegen.java#L639 + ExampleUtility.tryToSetExample(p); + + String example; + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("String".equals(type) || "str".equalsIgnoreCase(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + // Change opt_fields example from ["param1", "param2"] -> "param1,param2" + String cleanedInput = example.replace("[", "").replace("]", "").replace("\"", ""); + String[] fields = cleanedInput.split(","); + String exampleOptFieldString = String.join(",", fields); + p.example = "\"" + exampleOptFieldString + "\""; + return; + } else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) { + // Fix boolean example showing wrong python boolean type EX: "false" instead of "False" + // p.example is a string "true" or "false". We'll need to capitalize the first letter so that the sample code in python show True or False value + p.example = p.example.substring(0, 1).toUpperCase() + p.example.substring(1); + return; + } + + // Update example value for requests that require a request body + if (!languageSpecificPrimitives.contains(type)) { + // Type is a model class, e.g. User + p.example = "{\"data\": {\"param1\": \"value1\", \"param2\": \"value2\",}}"; + p.dataType = "dict"; + return; + } + + super.setParameterExampleValue(p); + } + + @Override + public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map schemas, OpenAPI openAPI) { + CodegenOperation op = super.fromOperation(path, httpMethod, operation, schemas, openAPI); + // Set vendor-extension to be used in code_sample.mustache template to show how to use custom field query param in examples: + if(op.operationId.equalsIgnoreCase("search_tasks_for_workspace")) { + op.vendorExtensions.put("x-codegen-isSearchTasksForWorkspace", true); + } + + // Set vendor-extension to be used in api.mustache to import the event iterator if the endpoint is the /events endpoint + op.vendorExtensions.put("x-codegen-isGetEvents", op.operationId.equalsIgnoreCase("get_events")); + + // Convert operatioId from snake case to lower case string with no underscores. EX: get_custom_field_settings_for_project -> getcustomfieldsettingsforproject + // This will be used to build the link to link to the developer documentation for that particular operation + op.vendorExtensions.put("x-codegen-operationIdLowerCase", op.operationId.replace("_", "").toLowerCase()); + + // Check if the returnType has "Array" in the name EX: TaskResponseArray + // This will be used to check if an endpoint should return a collection object or not + op.vendorExtensions.put("x-codegen-isArrayResponse", op.returnType.contains("Array")); + + // Generate resource instance variable name from the tag. EX: custom_field_settings -> custom_field_settings_api_instance + String resourceInstanceName = generateResourceInstanceName(operation.getTags().get(0)); + op.vendorExtensions.put("x-codegen-resourceInstanceName", resourceInstanceName); + + // Fix PUT endpoints not adding comma in method request for sample docs. EX: .update_task(bodytask_gid, opts) -> .update_task(body, task_gid, opts) + // Make a copy of parameters to be used in the template (templateParams). This is a hacky work around. We noticed that the below code "p.vendorExtensions.put" + // does not update the parameter's vendorExtensions for POST and PUT endpoints so to work around this we created a new list that does have those + // vendorExtensions added + List templateParams = new ArrayList(); + CodegenParameter lastRequired = null; + CodegenParameter lastOptional = null; + for (CodegenParameter p : op.allParams) { + if (p.required) { + lastRequired = p; + } else { + lastOptional = p; + } + } + + // Set vendor-extension to be used in template: + // x-codegen-hasMoreRequired + // x-codegen-hasMoreOptional + // x-codegen-hasRequiredParams + for (CodegenParameter p : op.allParams) { + if (p == lastRequired) { + p.vendorExtensions.put("x-codegen-hasMoreRequired", false); + } else if (p == lastOptional) { + p.vendorExtensions.put("x-codegen-hasMoreOptional", false); + } else { + p.vendorExtensions.put("x-codegen-hasMoreRequired", true); + p.vendorExtensions.put("x-codegen-hasMoreOptional", true); + } + templateParams.add(p.copy()); + } + op.vendorExtensions.put("x-codegen-hasRequiredParams", lastRequired != null); + op.vendorExtensions.put("x-codegen-templateParams",templateParams); + + return op; + } + + static String generateResourceInstanceName(String inputString) { + String snakeCaseString = inputString.replaceAll("\\s+", "_").toLowerCase(); + + // Add "ApiInstance" to the end of the string + return snakeCaseString.toString() + "_api_instance"; + } + + @SuppressWarnings("unchecked") + @Override + public Map postProcessOperations(Map objs) { + // Generate and store argument list string of each operation into + // vendor-extension: x-codegen-arg-list. + Map operations = (Map) objs.get("operations"); + if (operations != null) { + List ops = (List) operations.get("operation"); + for (CodegenOperation operation : ops) { + List argList = new ArrayList(); + boolean hasOptionalParams = false; + for (CodegenParameter p : operation.allParams) { + if (p.required) { + argList.add(p.paramName); + } else { + hasOptionalParams = true; + } + } + if (hasOptionalParams) { + argList.add("opts"); + } + operation.vendorExtensions.put("x-codegen-arg-list", StringUtils.join(argList, ", ")); + } + } + return objs; + } +} diff --git a/codegen/swagger/src/main/java/com/asana/codegen/ReadMe.java b/codegen/swagger/src/main/java/com/asana/codegen/ReadMe.java new file mode 100644 index 00000000..749193ac --- /dev/null +++ b/codegen/swagger/src/main/java/com/asana/codegen/ReadMe.java @@ -0,0 +1,164 @@ +package com.asana.codegen; + +import io.swagger.codegen.v3.*; +import io.swagger.codegen.v3.generators.DefaultCodegenConfig; + +import java.util.*; +import java.io.File; + +public class ReadMe extends DefaultCodegenConfig { + + // source folder where to write the files + protected String sourceFolder = "src"; + protected String apiVersion = "1.0.0"; + + /** + * Configures the type of generator. + * + * @return the CodegenType for this generator + * @see io.swagger.codegen.CodegenType + */ + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + /** + * Configures a friendly name for the generator. This will be used by the generator + * to select the library with the -l flag. + * + * @return the friendly name for the generator + */ + public String getName() { + return "AsanaPythonClientCodegen"; + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with help + * tips, parameters here + * + * @return A string value for the help message + */ + public String getHelp() { + return "Generates a AsanaPythonClientCodegen client library."; + } + + public ReadMe() { + super(); + + // set the output folder here + outputFolder = "generated-code/AsanaPythonClientCodegen"; + + /** + * Models. You can write model files using the modelTemplateFiles map. + * if you want to create one template for file, you can do so here. + * for multiple files for model, just put another entry in the `modelTemplateFiles` with + * a different extension + */ + modelTemplateFiles.put( + "model.mustache", // the template to use + ".sample"); // the extension for each file to write + + /** + * Api classes. You can write classes for each Api file with the apiTemplateFiles map. + * as with models, add multiple entries with different extensions for multiple files per + * class + */ + apiTemplateFiles.put( + "api.mustache", // the template to use + ".sample"); // the extension for each file to write + + /** + * Template Location. This is the location which templates will be read from. The generator + * will use the resource stream to attempt to read the templates. + */ + templateDir = "AsanaPythonClientCodegen"; + + /** + * Api Package. Optional, if needed, this can be used in templates + */ + apiPackage = "io.swagger.client.api"; + + /** + * Model Package. Optional, if needed, this can be used in templates + */ + modelPackage = "io.swagger.client.model"; + + /** + * Reserved words. Override this with reserved words specific to your language + */ + reservedWords = new HashSet ( + Arrays.asList( + "sample1", // replace with static values + "sample2") + ); + + /** + * Additional Properties. These values can be passed to the templates and + * are available in models, apis, and supporting files + */ + additionalProperties.put("apiVersion", apiVersion); + + /** + * Supporting Files. You can write single files for the generator with the + * entire object tree available. If the input file has a suffix of `.mustache + * it will be processed by the template engine. Otherwise, it will be copied + */ + supportingFiles.add(new SupportingFile("myFile.mustache", // the input template or file + "", // the destination folder, relative `outputFolder` + "myFile.sample") // the output file + ); + + /** + * Language Specific Primitives. These types will not trigger imports by + * the client generator + */ + languageSpecificPrimitives = new HashSet( + Arrays.asList( + "Type1", // replace these with your types + "Type2") + ); + } + + /** + * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping + * those terms here. This logic is only called if a variable matches the reserved words + * + * @return the escaped term + */ + @Override + public String escapeReservedWord(String name) { + return "_" + name; // add an underscore to the name + } + + /** + * Location to write model files. You can use the modelPackage() as defined when the class is + * instantiated + */ + public String modelFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); + } + + /** + * Location to write api files. You can use the apiPackage() as defined when the class is + * instantiated + */ + @Override + public String apiFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); + } + + @Override + public String getArgumentsLocation() { + return null; + } + + @Override + protected String getTemplateDir() { + return templateDir; + } + + @Override + public String getDefaultTemplateDir() { + return templateDir; + } +} diff --git a/codegen/swagger/src/main/resources/META-INF/services/io.swagger.codegen.v3.CodegenConfig b/codegen/swagger/src/main/resources/META-INF/services/io.swagger.codegen.v3.CodegenConfig new file mode 100644 index 00000000..33505366 --- /dev/null +++ b/codegen/swagger/src/main/resources/META-INF/services/io.swagger.codegen.v3.CodegenConfig @@ -0,0 +1 @@ +com.asana.codegen.PythonClientCodegenGenerator diff --git a/codegen/templates/README.mustache b/codegen/templates/README.mustache new file mode 100644 index 00000000..ddb9e06b --- /dev/null +++ b/codegen/templates/README.mustache @@ -0,0 +1,651 @@ +# {{{projectName}}} [![GitHub release][release-image]]() [![PyPi Version][pypi-image]][pypi-url] + +> **Warning** +> Python client library version `>5.X.X` is currently in BETA and subject to change. Please use v3.2.X for stable / production environments `pip install asana==3.2.2`. If you have feedback on the new version, please your feedback [here](https://form.asana.com/?k=C4sELCq6hAUsoWEY0kJwAA&d=15793206719). + +> You can try out our new python beta by installing version [v{{packageVersion}}](https://github.com/Asana/python-asana/tree/v{{packageVersion}}) (`pip install asana=={{packageVersion}}`) + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} + +## Requirements. + +Python 3.4+ + +## Installation & Usage +### pip install from [PyPI](https://pypi.org/project/asana/) + +```sh +pip install asana +``` + +Then import the package: +```python +import {{{packageName}}} +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import {{{packageName}}} +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python +{{>code_sample_client}} + +# create an instance of the API class +users_api_instance = {{{packageName}}}.UsersApi(api_client) +user_gid = "me" +opts = {} + +try: + # Get a user + user = users_api_instance.get_user(user_gid, opts) + pprint(user) +except ApiException as e: + print("Exception when calling UsersApi->get_user: %s\n" % e) +``` + +### Example: GET, POST, PUT, DELETE on tasks + +#### GET - get multiple tasks +```python +{{>code_sample_client}} + +# create an instance of the API class +tasks_api_instance = {{{packageName}}}.TasksApi(api_client) +opts = { + 'limit': 50, + 'offset': "eyJ0eXAiOJiKV1iQLCJhbGciOiJIUzI1NiJ9", + 'assignee': "14641", + 'project': "321654", + 'section': "321654", + 'workspace': "321654", + 'completed_since': '2012-02-22T02:06:58.158Z', + 'modified_since': '2012-02-22T02:06:58.158Z', + 'opt_fields': "actual_time_minutes,approval_status,assignee,assignee.name,assignee_section,assignee_section.name,assignee_status,completed,completed_at,completed_by,completed_by.name,created_at,created_by,custom_fields,custom_fields.asana_created_field,custom_fields.created_by,custom_fields.created_by.name,custom_fields.currency_code,custom_fields.custom_label,custom_fields.custom_label_position,custom_fields.date_value,custom_fields.date_value.date,custom_fields.date_value.date_time,custom_fields.description,custom_fields.display_value,custom_fields.enabled,custom_fields.enum_options,custom_fields.enum_options.color,custom_fields.enum_options.enabled,custom_fields.enum_options.name,custom_fields.enum_value,custom_fields.enum_value.color,custom_fields.enum_value.enabled,custom_fields.enum_value.name,custom_fields.format,custom_fields.has_notifications_enabled,custom_fields.is_formula_field,custom_fields.is_global_to_workspace,custom_fields.is_value_read_only,custom_fields.multi_enum_values,custom_fields.multi_enum_values.color,custom_fields.multi_enum_values.enabled,custom_fields.multi_enum_values.name,custom_fields.name,custom_fields.number_value,custom_fields.people_value,custom_fields.people_value.name,custom_fields.precision,custom_fields.resource_subtype,custom_fields.text_value,custom_fields.type,dependencies,dependents,due_at,due_on,external,external.data,followers,followers.name,hearted,hearts,hearts.user,hearts.user.name,html_notes,is_rendered_as_separator,liked,likes,likes.user,likes.user.name,memberships,memberships.project,memberships.project.name,memberships.section,memberships.section.name,modified_at,name,notes,num_hearts,num_likes,num_subtasks,offset,parent,parent.created_by,parent.name,parent.resource_subtype,path,permalink_url,projects,projects.name,resource_subtype,start_at,start_on,tags,tags.name,uri,workspace,workspace.name" +} + +try: + # Get multiple tasks + tasks = tasks_api_instance.get_tasks(opts) + for task in tasks: + pprint(task) +except ApiException as e: + print("Exception when calling TasksApi->get_tasks: %s\n" % e) +``` + +#### POST - create a task +```python +{{>code_sample_client}} + +# create an instance of the API class +tasks_api_instance = {{{packageName}}}.TasksApi(api_client) +body = { + "data": { + "name": "New Task", + "projects": [""], + } +} +opts = {} + +try: + # Create a task + task = tasks_api_instance.create_task(body, opts) + pprint(task) +except ApiException as e: + print("Exception when calling TasksApi->create_task: %s\n" % e) +``` + +#### PUT - update a task +```python +{{>code_sample_client}} + +# create an instance of the API class +tasks_api_instance = {{{packageName}}}.TasksApi(api_client) +body = { + "data": { + "name": "Updated Task", + } +} +task_gid = "" +opts = {} + +try: + # Update a task + task = tasks_api_instance.update_task(body, task_gid, opts) + pprint(task) +except ApiException as e: + print("Exception when calling TasksApi->update_task: %s\n" % e) +``` + +#### DELETE - delete a task +```python +{{>code_sample_client}} + +# create an instance of the API class +tasks_api_instance = {{{packageName}}}.TasksApi(api_client) +task_gid = "" + +try: + # Delete a task + task = tasks_api_instance.delete_task(task_gid) + pprint(task) +except ApiException as e: + print("Exception when calling TasksApi->delete_task: %s\n" % e) +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**](https://github.com/Asana/python-asana/blob/v{{packageVersion}}/{{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Accessing repsonse data + +### Example: Accessing task data +```python +. +. +. +try: + task = tasks_api_instance.get_task(task_gid, opts) + task_name = task['name'] + task_notes = task['notes'] +except ApiException as e: + . + . + . +``` + +## Accessing response status code and headers + +In the scenario you want to access the response headers or the status code along with the response data you can +provide the `_return_http_data_only` parameter argument in the request method and set the value to `False` + +```python +{{>code_sample_client}} + +# create an instance of the API class +users_api_instance = {{{packageName}}}.UsersApi(api_client) +user_gid = 'me' # str | A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. +opts = {} + +try: + # Get a user - Add asana-enable in the request + (api_response, status, headers) = users_api_instance.get_user(user_gid, opts, _return_http_data_only=False) # returns a tuple: (response, status, headers) + pprint(api_response) + pprint(status) + pprint(headers) +except ApiException as e: + print("Exception when calling UsersApi->get_user: %s\n" % e) +``` + +## Adding deprecation flag: "asana-enable" or "asana-disable" header + +### On the client +```python +{{>code_sample_client}} + +# Add asana-enable header for the client +api_client.default_headers['asana-enable'] = 'string_ids' +``` + +OR + +### On the request +```python +{{>code_sample_client}} + +# create an instance of the API class +users_api_instance = {{{packageName}}}.UsersApi(api_client) +user_gid = 'me' # str | A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. +opts = {} + +try: + # Get a user - Add asana-enable in the request + api_response = users_api_instance.get_user(user_gid, opts, header_params={'asana-enable': 'string_ids'}) + pprint(api_response) +except ApiException as e: + print("Exception when calling UsersApi->get_user: %s\n" % e) +``` + +## Async requests with multithreading + +This client library uses multithreading to make async requests. To make async requests you can pass in `async_req=True` in the method call. + +NOTE: +- This feature disables our auto-pagination feature +- You will want to add logic to handle the Asana API rate limits + +The code belows is an example of how to make 15 async create task calls. It does not handle the Asana API rate limits. +You will have to implement your own solution for API rate limits based on your tier. + +```python +{{>code_sample_client}} + +tasks_api_instance = {{{packageName}}}.TasksApi(api_client) +threads = [] +for i in range(1, 15+1): + body = { + "data": { + "name": f"Task: {i}", + "projects": [""] + } + } + opts = {} + threads.append(tasks_api_instance.create_task(body, opts, async_req=True)) + +for thread in threads: + try: + pprint(thread.get()) + except ApiException as e: + print("Exception when calling TasksApi->create_task: %s\n" % e) +``` + +## Pagination + +The pagination feature is enabled by default. This means two things: + +1: Endpoints that return a single response (EX: [get_task](https://github.com/Asana/python-asana/blob/v{{packageVersion}}/{{apiDocPath}}TasksApi.md#get_task) ([Get a task](https://developers.asana.com/reference/gettask)), [get_project](https://github.com/Asana/python-asana/blob/v{{packageVersion}}/{{apiDocPath}}TasksApi.md#get_project) ([Get a project](https://developers.asana.com/reference/getproject)), etc...) +will return a response with the `"data"` key abstracted from the response. + +Instead of returning: +```python +{ + "data": { + "gid": "123", + "actual_time_minutes": null, + "assignee": null, + ... + "workspace": { + "gid": "1234567", + "name": "user@example.com", + "resource_type": "workspace" + } + } +} +``` + +It returns: +```python +{ + "gid": "123", + "actual_time_minutes": null, + "assignee": null, + ... + "workspace": { + "gid": "1234567", + "name": "user@example.com", + "resource_type": "workspace" + } +} +``` + +2: Endpoints that return an array of resources (EX: [get_tasks](https://github.com/Asana/python-asana/blob/v{{packageVersion}}/{{apiDocPath}}TasksApi.md#get_tasks) ([Get multiple tasks](https://developers.asana.com/reference/gettasks)), [get_projects](https://github.com/Asana/python-asana/blob/v{{packageVersion}}/{{apiDocPath}}ProjectsApi.md#get_projects) ([Get multiple projects](https://developers.asana.com/reference/getprojects)), etc...) +will return a generator object ([PageIterator.items](https://github.com/Asana/python-asana/blob/v{{packageVersion}}/{{packageName}}/paget_iterator.py)) that you can use to iterate through each result. + +Example usage 1: +```python +{{>code_sample_client}} + +tasks_api_instance = {{{packageName}}}.TasksApi(api_client) +opts = {"project": ""} + +try: + tasks = tasks_api_instance.get_tasks(opts) + for task in tasks: + pprint(task) + +except Exception as e: + print("Exception when calling TasksApi->get_tasks: %s\n" % e) +``` + +Example response: +```python +{'gid': '123', + 'name': 'Task 1', + 'resource_subtype': 'default_task', + 'resource_type': 'task'}, + . + . + . +``` + +Example usage 2: +```python +{{>code_sample_client}} + +tasks_api_instance = {{{packageName}}}.TasksApi(api_client) +opts = {"project": ""} + +try: + tasks = tasks_api_instance.get_tasks(opts) + pprint(list(tasks)) + +except Exception as e: + print("Exception when calling TasksApi->get_tasks: %s\n" % e) +``` + +Example response: +```python +[{'gid': '123', + 'name': 'Task 1', + 'resource_subtype': 'default_task', + 'resource_type': 'task'}, + . + . + .] +``` + +### Ending pagination early + +In the scenario where you want to end the pagination early, you can specify an `item_limit` in the method call. This will stop the iterator from going past that limit. + +**Example Scenario:** You have 1000 tasks in a project and are only interested in the first 2 tasks. Instead of letting the pagination code continue to run to get all those 1000 tasks you can specify that you only want the first X results with `item_limit`. + +**Without `item_limit` - The for loop will continue to run until it runs out of tasks:** + +```python + ... + tasks = tasks_api_instance.get_tasks(opts) + for task in tasks: + pprint(task) + ... +``` + +**Sample response:** + +```python +{'gid': '123', + 'name': 'Task 1', + 'resource_subtype': 'default_task', + 'resource_type': 'task'}, + . + . + . + <1000th_TASK> +``` + +**With `item_limit` - the for loop will stop at the `item_limit` you specified:** +```python + ... + tasks = tasks_api_instance.get_tasks(opts, item_limit=2) + for task in tasks: + pprint(task) + ... +``` + +**Sample response:** + +```python +{'gid': '123', + 'name': 'Task 1', + 'resource_subtype': 'default_task', + 'resource_type': 'task'}, +{'gid': '456', + 'name': 'Task 2', + 'resource_subtype': 'default_task', + 'resource_type': 'task'} +``` + +Alternatively, if you are iterating over the generator object in a for loop, you can also just break out of the loop. + +**EX:** +```python +... +opts = {'project': ""} + +try: + count = 0 + tasks = tasks_api_instance.get_tasks(opts) + for task in tasks: + if count == 2: + break + pprint(task) + count += 1 + ... +``` + +**Sample response:** + +```python +{'gid': '123', + 'name': 'Task 1', + 'resource_subtype': 'default_task', + 'resource_type': 'task'}, + {'gid': '456', + 'name': 'Task 2', + 'resource_subtype': 'default_task', + 'resource_type': 'task'} +``` + +### Disabling default pagination behaviour + +If you do not want to use the default pagination behaviour there are two ways to disbale it. + +1: Per request - Disable pagination behavior for a single request - pass in `full_payload=True` in the method request +```python +{{>code_sample_client}} + +tasks_api_instance = {{{packageName}}}.TasksApi(api_client) +opts = {"project": "", "limit": 2} + +try: + tasks = tasks_api_instance.get_tasks(opts, full_payload=True) + pprint(tasks) +except Exception as e: + print("Exception when calling TasksApi->get_tasks: %s\n" % e) +``` + +Sample response: +```python +{'data': [{'gid': '123', + 'name': 'Task 1', + 'resource_subtype': 'default_task', + 'resource_type': 'task'}, + {'gid': '456', + 'name': 'Task 2', + 'resource_subtype': 'default_task', + 'resource_type': 'task'}], + 'next_page': {'offset': 'eyJ0...', + 'path': '/tasks?project=789&limit=2&offset=eyJ0...', + 'uri': 'https://app.asana.com/api/1.0/tasks?project=789&limit=2&offset=eyJ0...'}} +``` + +2: Globally - Disable pagination behavior for all requests - Set `return_page_iterator` to False +```python +... +configuration = {{{packageName}}}.Configuration() +configuration.access_token = '' +configuration.return_page_iterator = False +api_client = {{{packageName}}}.ApiClient(configuration) +... +``` + +## Documentation for Using the `call_api` method + +Use this to make HTTP calls when the endpoint does not exist in the current library version or has bugs + +### Example: GET, POST, PUT, DELETE on tasks + +#### GET - get a task +```python +{{>code_sample_client}} + +try: + # GET - get a task + api_response = api_client.call_api( + "/tasks/{task_gid}", + "GET", + path_params={"task_gid": ""}, + query_params={}, + header_params={"Accept": "application/json; charset=utf-8"}, + body=None, + post_params=[], + files={}, + response_type=object, # You can specify one of the following types: float, bool, bytes, str, object + auth_settings=["token"], + async_req=None, + _return_http_data_only=True, + _preload_content=True, + _request_timeout=None, + collection_formats={}, + ) + pprint(api_response) +except ApiException as e: + print("Exception: %s\n" % e) +``` + +#### GET - get multiple tasks -> with opt_fields +```python +{{>code_sample_client}} + +try: + # GET - get multiple tasks + api_response = api_client.call_api( + "/tasks", + "GET", + path_params={}, + query_params={ + "project": "", + "opt_fields": "name,notes,projects", + }, + header_params={"Accept": "application/json; charset=utf-8"}, + body=None, + post_params=[], + files={}, + response_type=object, # You can specify one of the following types: float, bool, bytes, str, object + auth_settings=["token"], + async_req=None, + _return_http_data_only=True, + _preload_content=True, + _request_timeout=None, + collection_formats={}, + ) + pprint(api_response) +except ApiException as e: + print("Exception: %s\n" % e) +``` + +#### POST - create a task +```python +{{>code_sample_client}} + +try: + # POST - create a task + api_response = api_client.call_api( + "/tasks", + "POST", + path_params={}, + query_params={}, + header_params={ + "Accept": "application/json; charset=utf-8", + "Content-Type": "application/json; charset=utf-8", + }, + body={ + "data": { + "name": "New Task", + "projects": [""], + } + }, + post_params=[], + files={}, + response_type=object, # You can specify one of the following types: float, bool, bytes, str, object + auth_settings=["token"], + async_req=None, + _return_http_data_only=True, + _preload_content=True, + _request_timeout=None, + collection_formats={}, + ) + pprint(api_response) +except ApiException as e: + print("Exception: %s\n" % e) +``` + +#### PUT - update a task +```python +{{>code_sample_client}} + +try: + # PUT - update a task + api_response = api_client.call_api( + "/tasks/{task_gid}", + "PUT", + path_params={"task_gid": ""}, + query_params={}, + header_params={ + "Accept": "application/json; charset=utf-8", + "Content-Type": "application/json; charset=utf-8", + }, + body={ + "data": { + "name": "Updated Task", + } + }, + post_params=[], + files={}, + response_type=object, # You can specify one of the following types: float, bool, bytes, str, object + auth_settings=["token"], + async_req=None, + _return_http_data_only=True, + _preload_content=True, + _request_timeout=None, + collection_formats={}, + ) + pprint(api_response) +except ApiException as e: + print("Exception: %s\n" % e) +``` + +#### DELETE - delete a task +```python +{{>code_sample_client}} + +try: + # DELETE - delete a task + api_response = api_client.call_api( + "/tasks/{task_gid}", + "DELETE", + path_params={"task_gid": ""}, + query_params={}, + header_params={"Accept": "application/json; charset=utf-8"}, + body=None, + post_params=[], + files={}, + response_type=object, # You can specify one of the following types: float, bool, bytes, str, object + auth_settings=["token"], + async_req=None, + _return_http_data_only=True, + _preload_content=True, + _request_timeout=None, + collection_formats={}, + ) + pprint(api_response) +except ApiException as e: + print("Exception: %s\n" % e) +``` + +[release-image]: https://img.shields.io/github/release/asana/python-asana.svg + +[pypi-image]: https://img.shields.io/pypi/v/asana.svg?style=flat-square +[pypi-url]: https://pypi.python.org/pypi/asana/ diff --git a/codegen/templates/__init__package.mustache b/codegen/templates/__init__package.mustache new file mode 100644 index 00000000..cc7fec51 --- /dev/null +++ b/codegen/templates/__init__package.mustache @@ -0,0 +1,14 @@ +# coding: utf-8 + +# flake8: noqa + +{{>partial_header}} + +from __future__ import absolute_import + +# import apis into sdk package +{{#apiInfo}}{{#apis}}from {{importPath}} import {{classname}} +{{/apis}}{{/apiInfo}} +# import ApiClient +from {{packageName}}.api_client import ApiClient +from {{packageName}}.configuration import Configuration diff --git a/codegen/templates/__init__pagination.mustache b/codegen/templates/__init__pagination.mustache new file mode 100644 index 00000000..22480848 --- /dev/null +++ b/codegen/templates/__init__pagination.mustache @@ -0,0 +1,11 @@ +# coding: utf-8 + +# flake8: noqa + +{{>partial_header}} + +from __future__ import absolute_import + +# import pagination into pagination package +from {{packageName}}.pagination.page_iterator import PageIterator +from {{packageName}}.pagination.event_iterator import EventIterator diff --git a/codegen/templates/api.mustache b/codegen/templates/api.mustache new file mode 100644 index 00000000..fcaa8573 --- /dev/null +++ b/codegen/templates/api.mustache @@ -0,0 +1,306 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six +from {{packageName}}.api_client import ApiClient +from {{packageName}}.pagination.event_iterator import EventIterator +from {{packageName}}.pagination.page_iterator import PageIterator + +{{#operations}} +class {{classname}}(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client +{{#operation}} +{{#contents}} + + def {{operationId}}(self, {{vendorExtensions.x-codegen-arg-list}}, **kwargs): # noqa: E501 + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#parameters}}{{#required}}{{paramName}}, {{/required}}{{/parameters}}async_req=True) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#parameters}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/parameters}}async_req=True) +{{/sortParamsByRequiredFlag}} + >>> result = thread.get() + + :param async_req bool +{{#parameters}} + :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} +{{/parameters}} + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = kwargs.get("_return_http_data_only", True) + if kwargs.get('async_req'): + return self.{{operationId}}_with_http_info({{vendorExtensions.x-codegen-arg-list}}, **kwargs) # noqa: E501 + else: + (data) = self.{{operationId}}_with_http_info({{vendorExtensions.x-codegen-arg-list}}, **kwargs) # noqa: E501 + return data + + def {{operationId}}_with_http_info(self, {{vendorExtensions.x-codegen-arg-list}}, **kwargs): # noqa: E501 + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}_with_http_info({{#parameters}}{{#required}}{{paramName}}, {{/required}}{{/parameters}}async_req=True) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}_with_http_info({{#parameters}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/parameters}}async_req=True) +{{/sortParamsByRequiredFlag}} + >>> result = thread.get() + + :param async_req bool +{{#parameters}} + :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}} +{{/parameters}} + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, + returns the request thread. + """ + all_params = [] + all_params.append('async_req') + all_params.append('header_params') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('full_payload') + all_params.append('item_limit') + + params = locals() + {{#vendorExtensions.x-codegen-isSearchTasksForWorkspace}} + matchSnakeCase = '^custom_fields_(.*?)_.*$' + custom_fields_query_param_keys = [] + {{/vendorExtensions.x-codegen-isSearchTasksForWorkspace}} + for key, val in six.iteritems(params['kwargs']): + {{#vendorExtensions.x-codegen-isSearchTasksForWorkspace}} + # Do not throw an error if the user provides custom field query parameters + if (re.match(matchSnakeCase, key)): + custom_field_gid = re.search(matchSnakeCase, key).group(1) + custom_field_query_param_key = key.replace(f'custom_fields_{custom_field_gid}_', f'custom_fields.{custom_field_gid}.') + params[custom_field_query_param_key] = val + custom_fields_query_param_keys.append(custom_field_query_param_key) + continue + {{/vendorExtensions.x-codegen-isSearchTasksForWorkspace}} + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method {{operationId}}" % key + ) + params[key] = val + del params['kwargs'] +{{#parameters}} +{{#required}} + # verify the required parameter '{{paramName}}' is set + if ({{paramName}} is None): + raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 +{{/required}} +{{/parameters}} + +{{#parameters}} +{{#hasValidation}} + {{#maxLength}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) > {{maxLength}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 + {{/maxLength}} + {{#minLength}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) < {{minLength}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 + {{/minLength}} + {{#maximum}} + if '{{paramName}}' in params and params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 + {{/maximum}} + {{#minimum}} + if '{{paramName}}' in params and params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 + {{/minimum}} + {{#pattern}} + if '{{paramName}}' in params and not re.search(r'{{{vendorExtensions.x-regex}}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#@first}}, flags={{/@first}}re.{{.}}{{^@last}} | {{/@last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 + {{/pattern}} + {{#maxItems}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) > {{maxItems}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 + {{/maxItems}} + {{#minItems}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) < {{minItems}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 + {{/minItems}} +{{/hasValidation}} +{{#@last}} +{{/@last}} +{{/parameters}} + collection_formats = {} + + path_params = {} +{{#pathParams}} + path_params['{{baseName}}'] = {{paramName}}{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/pathParams}} + + query_params = [] + {{#hasOptionalParams}} + query_params = opts + {{/hasOptionalParams}} + {{#queryParams}}{{#required}} + query_params['{{baseName}}'] = {{paramName}} + {{/required}}{{/queryParams}} + +{{#vendorExtensions.x-codegen-isSearchTasksForWorkspace}} + # Checks if the user provided custom field query parameters and adds it to the request + for key in custom_fields_query_param_keys: + query_params[key] = params[key] # noqa: E501 +{{/vendorExtensions.x-codegen-isSearchTasksForWorkspace}} + + header_params = kwargs.get("header_params", {}) +{{#headerParams}} + if '{{paramName}}' in params: + header_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/headerParams}} + + form_params = [] + local_var_files = {} +{{#formParams}} + if '{{paramName}}' in opts: + {{^isBinary}}form_params.append(('{{baseName}}', opts['{{paramName}}'])){{/isBinary}}{{#isBinary}}local_var_files['{{baseName}}'] = opts['{{paramName}}']{{/isBinary}}{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 + + # Because form params and query params are both provided in the opts method parameter we need to remove the form params from the query params + query_params.pop('{{baseName}}') +{{/formParams}} + + body_params = {{#bodyParam}}{{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{/bodyParam}}{{^bodyParam}}None{{/bodyParam}} + + {{#hasProduces}} + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]) # noqa: E501 + + {{/hasProduces}} + {{#hasConsumes}} + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]) # noqa: E501 + + {{/hasConsumes}} + # Authentication setting + auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] # noqa: E501 + + # hard checking for True boolean value because user can provide full_payload or async_req with any data type + if kwargs.get("full_payload", False) == True or kwargs.get('async_req', False) == True: + return self.api_client.call_api( + '{{{path}}}', '{{httpMethod}}', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=object, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats + ) + elif self.api_client.configuration.return_page_iterator: + {{#vendorExtensions.x-codegen-isArrayResponse}} + query_params["limit"] = query_params.get("limit", self.api_client.configuration.page_limit) + {{#vendorExtensions.x-codegen-isGetEvents}} + return EventIterator( + {{/vendorExtensions.x-codegen-isGetEvents}} + {{^vendorExtensions.x-codegen-isGetEvents}} + return PageIterator( + {{/vendorExtensions.x-codegen-isGetEvents}} + self.api_client, + { + "resource_path": '{{&path}}', + "method": '{{httpMethod}}', + "path_params": path_params, + "query_params": query_params, + "header_params": header_params, + "body": body_params, + "post_params": form_params, + "files": local_var_files, + "response_type": object, + "auth_settings": auth_settings, + "async_req": params.get('async_req'), + "_return_http_data_only": params.get('_return_http_data_only'), + "_preload_content": params.get('_preload_content', True), + "_request_timeout": params.get('_request_timeout'), + "collection_formats": collection_formats + }, + **kwargs + ).items() + {{/vendorExtensions.x-codegen-isArrayResponse}} + {{^vendorExtensions.x-codegen-isArrayResponse}} + (data) = self.api_client.call_api( + '{{{path}}}', '{{httpMethod}}', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=object, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats + ) + if params.get('_return_http_data_only') == False: + return data + return data["data"] if data else data + {{/vendorExtensions.x-codegen-isArrayResponse}} + else: + return self.api_client.call_api( + '{{{path}}}', '{{httpMethod}}', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=object, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) +{{/contents}} +{{/operation}} +{{/operations}} diff --git a/codegen/templates/api_client.mustache b/codegen/templates/api_client.mustache new file mode 100644 index 00000000..9b287d7e --- /dev/null +++ b/codegen/templates/api_client.mustache @@ -0,0 +1,633 @@ +# coding: utf-8 +{{>partial_header}} +from __future__ import absolute_import + +import logging +import datetime +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import platform +import re +import tempfile + +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import quote +{{#tornado}} +import tornado.gen +{{/tornado}} + +from {{packageName}}.configuration import Configuration +from {{packageName}} import rest + +from urllib.parse import urlencode + + +class ApiClient(object): + """Generic API client for Swagger client library builds. + + Swagger generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the Swagger + templates. + + NOTE: This class is auto generated by the swagger code generator program. + Ref: https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int if six.PY3 else long, # noqa: F821 + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, + } + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None): + if configuration is None: + configuration = Configuration() + self.configuration = configuration + + try: + self.pool = ThreadPool() + except OSError: + logging.warning('Looks like your system does not support ThreadPool but it will try without it if you do not use async requests') + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/python{{/httpUserAgent}}' + # Add custom header + self.default_headers['X-Asana-Client-Lib'] = urlencode( + { + 'language': 'Python', + 'version': '{{{packageVersion}}}', + 'language_version': platform.python_version(), + 'os': platform.system(), + 'os_version': platform.release() + } + ) + + def __del__(self): + if hasattr(self, "pool"): + self.pool.close() + self.pool.join() + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + {{#tornado}} + @tornado.gen.coroutine + {{/tornado}} + {{#asyncio}}async {{/asyncio}}def __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_type=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + query_params = self.parameters_to_tuples(query_params, + collection_formats) + + # post parameters + if post_params or files: + post_params = self.prepare_post_parameters(post_params, files) + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + + # auth setting + self.update_params_for_auth(header_params, query_params, auth_settings) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + url = self.configuration.host + resource_path + + # perform request and return response + response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + + self.last_response = response_data + + return_data = response_data + if _preload_content: + # deserialize response data + if response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + +{{^tornado}} + if _return_http_data_only: + return (return_data) + else: + return (return_data, response_data.status, + response_data.getheaders()) +{{/tornado}} +{{#tornado}} + if _return_http_data_only: + raise tornado.gen.Return(return_data) + else: + raise tornado.gen.Return((return_data, response_data.status, + response_data.getheaders())) +{{/tornado}} + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is swagger model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) + for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + if isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `swagger_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.swagger_types) + if getattr(obj, attr) is not None} + + return {key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict)} + + def deserialize(self, response, response_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + # Decode the byte string and replace non-breaking space characters with regular + # spaces then parse the json bytes into a python dict + data = json.loads(response.data.decode('utf8').replace('\xa0', ' ')) + except ValueError: + data = response.data + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if type(klass) == str: + if klass.startswith('list['): + sub_kls = re.match(r'list\[(.*)\]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('dict('): + sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in six.iteritems(data)} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datatime(data) + else: + return data + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_type=None, auth_settings=None, async_req=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data without head status code + and headers + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + + # Convert query params dict into a list of query param tuples. + # This step was previous implemented in the api.mustache but we needed + # to modify the query params dict for pagination so we move this conversion step here + query_params = [(k, v) for k, v in query_params.items()] + + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout) + else: + thread = self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, query_params, + header_params, body, + post_params, files, + response_type, auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, _request_timeout)) + return thread + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.GET(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.HEAD(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "POST": + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def prepare_post_parameters(self, post_params=None, files=None): + """Builds form parameters. + + :param post_params: Normal form parameters. + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if post_params: + params = post_params + + if files: + for k, v in six.iteritems(files): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([k, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + accepts = [x.lower() for x in accepts] + + if 'application/json' in accepts: + return 'application/json' + else: + return ', '.join(accepts) + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return 'application/json' + + content_types = [x.lower() for x in content_types] + + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' + else: + return content_types[0] + + def update_params_for_auth(self, headers, querys, auth_settings): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + """ + if not auth_settings: + return + + for auth in auth_settings: + # In the OAS we define "personalAccessToken" but for the SDK we want users to use the term "token" + # this logic will get the auth_settings for "token" settings that we've added + if auth == 'personalAccessToken': + auth_setting = self.configuration.auth_settings().get('token') + else: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + if not auth_setting['value']: + continue + elif auth_setting['in'] == 'header': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise ValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + response_data = response.data + with open(path, "wb") as f: + if isinstance(response_data, str): + # change str to bytes so we can write it + response_data = response_data.encode('utf-8') + f.write(response_data) + else: + f.write(response_data) + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return six.text_type(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return a original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + from dateutil.parser import parse + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datatime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + from dateutil.parser import parse + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __hasattr(self, object, name): + return name in object.__class__.__dict__ diff --git a/codegen/templates/api_doc.mustache b/codegen/templates/api_doc.mustache new file mode 100644 index 00000000..1987dbfd --- /dev/null +++ b/codegen/templates/api_doc.mustache @@ -0,0 +1,49 @@ +# {{packageName}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +{{#contents}} +{{#@first}} +# **{{{operationId}}}** + +{{summary}}{{#notes}} + +{{{notes}}}{{/notes}} + +([more information](https://developers.asana.com/reference/{{{vendorExtensions.x-codegen-operationIdLowerCase}}})) + +### Example +```python +{{>code_sample}} +``` + +### Parameters +{{^parameters}}This endpoint does not need any parameter.{{/parameters}}{{#parameters}}{{#@last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/@last}}{{/parameters}} +{{#parameters}} **{{paramName}}** | {{#isBinary}}**{{dataType}}**{{/isBinary}}{{^isBinary}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}**Dict**{{/isPrimitiveType}}{{/isBinary}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/parameters}} + +### Return type + +{{#vendorExtensions.x-codegen-isArrayResponse}}generator{{/vendorExtensions.x-codegen-isArrayResponse}}{{^vendorExtensions.x-codegen-isArrayResponse}}dict{{/vendorExtensions.x-codegen-isArrayResponse}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/@first}} +{{/contents}} +{{/operation}} +{{/operations}} diff --git a/codegen/templates/code_sample.mustache b/codegen/templates/code_sample.mustache new file mode 100644 index 00000000..e51a2fc1 --- /dev/null +++ b/codegen/templates/code_sample.mustache @@ -0,0 +1,36 @@ +{{>code_sample_client}}{{#hasAuthMethods}} + +# create an instance of the API class +{{{vendorExtensions.x-codegen-resourceInstanceName}}} = {{{packageName}}}.{{{classname}}}(api_client){{#hasParams}} +{{#vendorExtensions.x-codegen-hasRequiredParams}}{{#parameters}}{{#required}} +{{{paramName}}} = {{{example}}} # {{{dataType}}} | {{{description}}} +{{/required}}{{/parameters}}{{/vendorExtensions.x-codegen-hasRequiredParams}}{{#hasOptionalParams}} +opts = { {{#parameters}}{{^required}} + '{{{paramName}}}': {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} # {{{dataType}}} | {{{description}}}{{/required}}{{/parameters}} +}{{/hasOptionalParams}}{{/hasParams}} +{{/hasAuthMethods}} +{{^hasAuthMethods}} + +# create an instance of the API class +{{{vendorExtensions.x-codegen-resourceInstanceName}}} = {{{packageName}}}.{{{classname}}}() +{{#parameters}} +{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/parameters}} +{{/hasAuthMethods}} +{{#vendorExtensions.x-codegen-isSearchTasksForWorkspace}} +opts['custom_fields.123.is_set'] = True # bool | Filiter to tasks with custom field set or unset. Note: searching for multiple exact matches of a custom field, searching for multi-enum custom field +opts['custom_fields.123.value'] = '456' # str or bool or Enum option ID | Filter to tasks with custom field that matches the provided value. Note: searching for multiple exact matches of a custom field, searching for multi-enum custom field +opts['custom_fields.123.starts_with'] = 'start' # string | Filter to tasks with custom field that starts with provided string. Note: searching for multiple exact matches of a custom field, searching for multi-enum custom field +opts['custom_fields.123.ends_with'] = 'end' # string | Filter to tasks with custom field that ends in provided string. Note: searching for multiple exact matches of a custom field, searching for multi-enum custom field +opts['custom_fields.123.contains'] = 'first' # string | Filter to tasks with custom field that contains the provided string. Note: searching for multiple exact matches of a custom field, searching for multi-enum custom field +opts['custom_fields.123.less_than'] = 10 # number | Filter to tasks with custom field with number value less than the provided number. Note: searching for multiple exact matches of a custom field, searching for multi-enum custom field +opts['custom_fields.123.greater_than'] = 100 # number | Filter to tasks with custom field with number value greater than the provided number. Note: searching for multiple exact matches of a custom field, searching for multi-enum custom field +{{/vendorExtensions.x-codegen-isSearchTasksForWorkspace}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}{{{vendorExtensions.x-codegen-resourceInstanceName}}}.{{{operationId}}}({{#vendorExtensions.x-codegen-templateParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/vendorExtensions.x-codegen-templateParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{#returnType}} + {{#vendorExtensions.x-codegen-isArrayResponse}}for data in api_response: + pprint(data){{/vendorExtensions.x-codegen-isArrayResponse}}{{/returnType}}{{^vendorExtensions.x-codegen-isArrayResponse}}pprint(api_response){{/vendorExtensions.x-codegen-isArrayResponse}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) diff --git a/codegen/templates/code_sample_client.mustache b/codegen/templates/code_sample_client.mustache new file mode 100644 index 00000000..51255f04 --- /dev/null +++ b/codegen/templates/code_sample_client.mustache @@ -0,0 +1,20 @@ +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.username = 'YOUR_USERNAME' +configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.access_token = ''{{/isOAuth}}{{#isBearer}} +configuration = {{{packageName}}}.Configuration() +configuration.access_token = '' +{{/isBearer}}{{/authMethods}} +api_client = {{{packageName}}}.ApiClient(configuration){{/hasAuthMethods}} diff --git a/codegen/templates/code_samples.mustache b/codegen/templates/code_samples.mustache new file mode 100644 index 00000000..63275fda --- /dev/null +++ b/codegen/templates/code_samples.mustache @@ -0,0 +1,11 @@ +{{classname}}: +{{#operations}} +{{#operation}} +{{#contents}} +{{#@first}} + {{operationId}}: |- + {{>code_sample}} +{{/@first}} +{{/contents}} +{{/operation}} +{{/operations}} diff --git a/codegen/templates/configuration.mustache b/codegen/templates/configuration.mustache new file mode 100644 index 00000000..1074e77e --- /dev/null +++ b/codegen/templates/configuration.mustache @@ -0,0 +1,284 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +import six +from six.moves import http_client as httplib + + +class TypeWithDefault(type): + def __init__(cls, name, bases, dct): + super(TypeWithDefault, cls).__init__(name, bases, dct) + cls._default = None + + def __call__(cls): + if cls._default is None: + cls._default = type.__call__(cls) + return copy.copy(cls._default) + + def set_default(cls, default): + cls._default = copy.copy(default) + + +class Configuration(six.with_metaclass(TypeWithDefault, object)): + """NOTE: This class is auto generated by the swagger code generator program. + + Ref: https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + """ + + def __init__(self): + """Constructor""" + # Default Base url + self.host = "{{{basePath}}}" + # Temp file folder for downloading files + self.temp_folder_path = None + + # Authentication Settings + # dict to store API key(s) + self.api_key = {} + # dict to store API prefix (e.g. Bearer) + self.api_key_prefix = {} + # function to refresh API key if expired + self.refresh_api_key_hook = None + # Username for HTTP basic authentication + self.username = "" + # Password for HTTP basic authentication + self.password = "" +{{#authMethods}}{{#isOAuth}} + # access token for OAuth + self.access_token = "" +{{/isOAuth}}{{/authMethods}} + # Logging Settings + self.logger = {} + self.logger["package_logger"] = logging.getLogger("{{packageName}}") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + # Log format + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + # Log stream handler + self.logger_stream_handler = None + # Log file handler + self.logger_file_handler = None + # Debug file location + self.logger_file = None + # Debug switch + self.debug = False + + # SSL/TLS verification + # Set this to false to skip verifying SSL certificate when calling API + # from https server. + self.verify_ssl = True + # Set this to customize the certificate file to verify the peer. + self.ssl_ca_cert = None + # client certificate file + self.cert_file = None + # client key file + self.key_file = None + # Set this to True/False to enable/disable SSL hostname verification. + self.assert_hostname = None + + # urllib3 connection pool's maximum number of connections saved + # per pool. urllib3 uses 1 connection as default value, but this is + # not the best value when you are making a lot of possibly parallel + # requests to the same host, which is often the case here. + # cpu_count * 5 is used as default value to increase performance. + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + + # Proxy URL + self.proxy = None + # Safe chars for path_param + self.safe_chars_for_path_param = '' + + # Collection + # by default we return a collection object to be used for pagination. + # If the user wants to turn this off they can set this to False + self.return_page_iterator = True + + # The default limit query parameter value for api endpoints that return multiple resources + self.page_limit = 100 + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in six.iteritems(self.logger): + logger.addHandler(self.logger_file_handler) + if self.logger_stream_handler: + logger.removeHandler(self.logger_stream_handler) + else: + # If not set logging file, + # then add stream handler and remove file handler. + self.logger_stream_handler = logging.StreamHandler() + self.logger_stream_handler.setFormatter(self.logger_formatter) + for _, logger in six.iteritems(self.logger): + logger.addHandler(self.logger_stream_handler) + if self.logger_file_handler: + logger.removeHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in six.iteritems(self.logger): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in six.iteritems(self.logger): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook: + self.refresh_api_key_hook(self) + + key = self.api_key.get(identifier) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + return urllib3.util.make_headers( + basic_auth=self.username + ':' + self.password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + return { +{{#authMethods}} +{{#isApiKey}} + '{{name}}': + { + 'type': 'api_key', + 'in': {{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, + 'key': '{{keyParamName}}', + 'value': self.get_api_key_with_prefix('{{keyParamName}}') + }, +{{/isApiKey}} +{{#isBasic}} + '{{name}}': + { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + }, +{{/isBasic}}{{#isOAuth}} + '{{name}}': + { + 'type': 'oauth2', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + }, +{{/isOAuth}}{{#isBearer}} + # Add a case for OAS bearer token definition + 'token': + { + 'type': 'token', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + }, +{{/isBearer}}{{/authMethods}} + } + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: {{version}}\n"\ + "SDK Package Version: {{packageVersion}}".\ + format(env=sys.platform, pyversion=sys.version) diff --git a/codegen/templates/event_iterator.mustache b/codegen/templates/event_iterator.mustache new file mode 100644 index 00000000..1d5644ae --- /dev/null +++ b/codegen/templates/event_iterator.mustache @@ -0,0 +1,38 @@ +import json +from {{packageName}}.pagination.page_iterator import PageIterator +from {{packageName}}.rest import ApiException + +class EventIterator(PageIterator): + def __init__(self, api_client, api_request_data, **kwargs): + super().__init__(api_client, api_request_data, **kwargs) + self.sync = False + self.has_more = True + + def __next__(self): + if not self.has_more: + raise StopIteration + + result = {} + + try: + result = self.call_api() + except ApiException as e: + if (e.status == 412): + errors = json.loads(e.body.decode("utf-8")) + self.sync = errors["sync"] + else: + raise e + + if (self.sync): + self.api_request_data["query_params"]["sync"] = self.sync + else: + self.sync = result.get('sync', None) + + if not result: + try: + result = self.call_api() + except ApiException as e: + raise e + + self.has_more = result.get('has_more', False) + return result["data"] diff --git a/codegen/templates/gitignore.mustache b/codegen/templates/gitignore.mustache new file mode 100644 index 00000000..447b9425 --- /dev/null +++ b/codegen/templates/gitignore.mustache @@ -0,0 +1,67 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.python-version + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints + +.travis.yml +git_push.sh diff --git a/codegen/templates/page_iterator.mustache b/codegen/templates/page_iterator.mustache new file mode 100644 index 00000000..6f09dbcc --- /dev/null +++ b/codegen/templates/page_iterator.mustache @@ -0,0 +1,64 @@ +from {{packageName}}.rest import ApiException + +class PageIterator(object): + def __init__(self, api_client, api_request_data, **kwargs): + self.__api_client = api_client + self.api_request_data = api_request_data + self.next_page = False + self.item_limit = float('inf') if kwargs.get('item_limit', None) == None else kwargs.get('item_limit') + self.count = 0 + + def __iter__(self): + """Iterator interface, self is an iterator""" + return self + + def __next__(self): + limit = self.api_request_data["query_params"].get("limit", None) + if limit: + self.api_request_data["query_params"]["limit"] = min(limit, self.item_limit - self.count) + + if self.next_page is None or self.api_request_data["query_params"].get("limit", None) == 0: + raise StopIteration + + try: + result = self.call_api() + except ApiException as e: + raise e + + # If the response has a next_page add the offset to the api_request_data for the next request + self.next_page = result.get('next_page', None) + if (self.next_page): + self.api_request_data["query_params"]["offset"] = self.next_page["offset"] + data = result['data'] + if data != None: + self.count += len(data) + return data + + def next(self): + """Alias for __next__""" + return self.__next__() + + def items(self): + """Returns an iterator for each item in each page""" + for page in self: + for item in page: + yield item + + def call_api(self): + return self.__api_client.call_api( + self.api_request_data["resource_path"], + self.api_request_data["method"], + self.api_request_data["path_params"], + self.api_request_data["query_params"], + self.api_request_data["header_params"], + self.api_request_data["body"], + self.api_request_data["post_params"], + self.api_request_data["files"], + self.api_request_data["response_type"], + self.api_request_data["auth_settings"], + self.api_request_data["async_req"], + self.api_request_data["_return_http_data_only"], + self.api_request_data["collection_formats"], + self.api_request_data["_preload_content"], + self.api_request_data["_request_timeout"] + ) diff --git a/codegen/templates/setup.mustache b/codegen/templates/setup.mustache new file mode 100644 index 00000000..0e52d6e1 --- /dev/null +++ b/codegen/templates/setup.mustache @@ -0,0 +1,52 @@ +# coding: utf-8 + +{{>partial_header}} + +import os +from setuptools import setup, find_packages # noqa: H301 + +NAME = "{{{projectName}}}" +VERSION = "{{packageVersion}}" +with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme: + LONG_DESCRIPTION = readme.read() +{{#apiInfo}} +{{#apis}} +{{^hasMore}} +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = [ + "certifi>=2017.4.17", + "python-dateutil>=2.1", + "six>=1.10", + "urllib3>=1.23" +] + +{{#asyncio}} +REQUIRES.append("aiohttp") +{{/asyncio}} +{{#tornado}} +REQUIRES.append("tornado") +{{/tornado}} + +setup( + name=NAME, + version=VERSION, + description="{{appName}}", + long_description=LONG_DESCRIPTION, + long_description_content_type='text/markdown', + author='Asana, Inc', + url="http://github.com/asana/python-asana", + keywords=["asana", "{{appName}}"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + license='MIT', +) +{{/hasMore}} +{{/apis}} +{{/apiInfo}} diff --git a/deploy.py b/deploy.py deleted file mode 100755 index a1bd496a..00000000 --- a/deploy.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python - -""" -Script for deploying a new version of the python-asana library. -""" - -from __future__ import print_function - -import argparse -import subprocess - -if __name__ == '__main__': - # Setup parser for command line arguments - parser = argparse.ArgumentParser() - parser.add_argument( - 'part', - choices=['major', 'minor', 'patch'], - help='The part of the version to be bumped' - ) - args = parser.parse_args() - - # Get the current version from asana/version.py - current_version = {} - with open('asana/version.py') as fp: - exec(fp.read(), current_version) - major, minor, patch = current_version['__version__'].split('.') - - # Bump version part based on argument provided - if args.part == 'major': - major = str(int(major) + 1) - minor = 0 - patch = 0 - if args.part == 'minor': - minor = str(int(minor) + 1) - patch = 0 - if args.part == 'patch': - patch = str(int(patch) + 1) - - # Overwrite the version in VERSION and asana/version.py - updated_version = "{}.{}.{}".format(major, minor, patch) - with open('VERSION', 'w') as version_file: - version_file.write("{}".format(updated_version)) - with open('asana/version.py', 'w') as version_file: - version_file.write("__version__ = '{}'\n".format(updated_version)) - - # Add, commit and push version changes to GitHub and tag release - subprocess.call('git add VERSION asana/version.py', shell=True) - subprocess.call( - 'git commit -m "Releasing version {}"'.format(updated_version), shell=True - ) - subprocess.call('git tag v{}'.format(updated_version), shell=True) - subprocess.call('git push --tags origin master:master', shell=True) - - print('Successfully deployed version {}'.format(updated_version)) diff --git a/examples/example-create-task.py b/examples/example-create-task.py deleted file mode 100644 index 29312344..00000000 --- a/examples/example-create-task.py +++ /dev/null @@ -1,46 +0,0 @@ -import sys -import os -import json - -sys.path.append(os.path.dirname(os.path.dirname(__file__))) - -import asana - -# Instructions -# -# 1. Set your ASANA_ACCESS_TOKEN environment variable to a Personal Access Token obtained in your Asana Account Settings -# -# This simple script asks the user to choose from their available Workspaces and then the first page (if more than a -# single page exists) of available projects in order to create a task in that project. -# - -def user_select_option(message, options): - option_lst = list(options) - print_(message) - for i, val in enumerate(option_lst): - print_(i, ': ' + val['name']) - index = int(input("Enter choice (default 0): ") or 0) - return option_lst[index] - - -if 'ASANA_ACCESS_TOKEN' in os.environ: - # create a client with a Personal Access Token - client = asana.Client.access_token(os.environ['ASANA_ACCESS_TOKEN']) - workspaces = client.workspaces.get_workspaces() - - workspace = user_select_option("Please choose a workspace", workspaces) - - projects = client.projects.get_projects({'workspace': workspace['gid']}) - - project = user_select_option("Please choose a project", projects) - - result = client.tasks.create_task( - workspace['gid'], - { - 'name': 'Learn to use Nunchucks', - 'notes': 'Note: This is a test task created with the python-asana client.', - 'projects': [project['gid']] - } - ) - - print(json.dumps(result, indent=4)) diff --git a/examples/example-script.py b/examples/example-script.py deleted file mode 100644 index 72e23e45..00000000 --- a/examples/example-script.py +++ /dev/null @@ -1,85 +0,0 @@ -import sys, os -sys.path.append(os.path.dirname(os.path.dirname(__file__))) - -import asana -import json - -# OAuth Instructions: -# -# 1. create a new application in your Asana Account Settings ("App" panel) -# 2. set the redirect URL to "urn:ietf:wg:oauth:2.0:oob" -# 3. set your ASANA_CLIENT_ID and ASANA_CLIENT_SECRET environment variables -# -# Personal Access Token Instructions: -# -# 1. set your ASANA_ACCESS_TOKEN environment variable to a Personal Access Token obtained in your Asana Account Settings -# - -if 'ASANA_CLIENT_ID' in os.environ: - # create a client with the OAuth credentials: - client = asana.Client.oauth( - client_id=os.environ['ASANA_CLIENT_ID'], - client_secret=os.environ['ASANA_CLIENT_SECRET'], - # this special redirect URI will prompt the user to copy/paste the code. - # useful for command line scripts and other non-web apps - redirect_uri='urn:ietf:wg:oauth:2.0:oob' - ) - print("authorized=", client.session.authorized) - - # get an authorization URL: - (url, state) = client.session.authorization_url() - try: - # in a web app you'd redirect the user to this URL when they take action to - # login with Asana or connect their account to Asana - import webbrowser - webbrowser.open(url) - except Exception as e: - print("Open the following URL in a browser to authorize:") - print(url) - - print("Copy and paste the returned code from the browser and press enter:") - - code = sys.stdin.readline().strip() - # exchange the code for a bearer token - token = client.session.fetch_token(code=code) - - print("token=", json.dumps(token)) - print("authorized=", client.session.authorized) - print("me=", client.users.get_user('me')) - - # normally you'd persist this token somewhere - os.environ['ASANA_TOKEN'] = json.dumps(token) # (see below) - -if 'ASANA_TOKEN' in os.environ: - # create a client with your OAuth client ID and a previously obtained bearer token - client = asana.Client.oauth( - client_id=os.environ['ASANA_CLIENT_ID'], - token=json.loads(os.environ['ASANA_TOKEN']) - ) - print("authorized=", client.session.authorized) - print("me=", client.users.get_user('me')) - -if 'ASANA_ACCESS_TOKEN' in os.environ: - # create a client with a Personal Access Token - client = asana.Client.access_token(os.environ['ASANA_ACCESS_TOKEN']) - me = client.users.get_user('me') - print("me=" + json.dumps(me, indent=2)) - - # find your "Personal Projects" workspace - personal_projects = next(workspace for workspace in me['workspaces'] if workspace['name'] == 'Personal Projects') - projects = client.projects.get_projects(personal_projects['id'], iterator_type=None) - print("personal projects=" + json.dumps(projects, indent=2)) - - # create a "demo project" if it doesn't exist - try: - project = next(project for project in projects if project['name'] == 'demo project') - except: - print("creating 'demo project'") - project = client.projects.create_in_workspace(personal_projects['id'], { 'name': 'demo project' }) - print("project=", project) - - # start streaming modifications to the demo project. - # make some changes in Asana to see this working - print("starting streaming events for " + project['name']) - for event in client.events.get_iterator({ 'resource': project['id'] }): - print("event", event) diff --git a/examples/example-server.py b/examples/example-server.py deleted file mode 100644 index b9ce8385..00000000 --- a/examples/example-server.py +++ /dev/null @@ -1,77 +0,0 @@ -import sys, os -sys.path.append(os.path.dirname(os.path.dirname(__file__))) - -from flask import Flask, request, session, redirect, render_template_string -import asana -import json - -# OAuth Instructions: -# -# 1. create a new application in your Asana Account Settings ("App" panel) -# 2. set the redirect URL to "http://localhost:5000/auth/asana/callback" (or whichever port you choose) -# 3. set your ASANA_CLIENT_ID and ASANA_CLIENT_SECRET environment variables - -# convience method to create a client with your credentials, and optionally a 'token' -def Client(**kwargs): - return asana.Client.oauth( - client_id=os.environ['ASANA_CLIENT_ID'], - client_secret=os.environ['ASANA_CLIENT_SECRET'], - redirect_uri='http://localhost:5000/auth/asana/callback', - **kwargs - ) - -app = Flask(__name__) - -# main page (http://localhost:5000/) -@app.route("/") -def main(): - token = session.get('token', False) - # if the user has a token they're logged in - if token: - # example request gets information about logged in user - me = Client(token=token).users.get_user('me') - return render_template_string(''' - -

Hello {{ name }}.

-

{{ dump }}

-

Logout

''', - name=me['name'], - dump=json.dumps(me, indent=2) - ) - # if we don't have a token show a "Sign in with Asana" button - else: - # get an authorization URL and anti-forgery "state" token - (auth_url, state) = Client().session.authorization_url() - # persist the state token in the user's session - session['state'] = state - # link the button to the authorization URL - return render_template_string(''' -

''', - auth_url=auth_url - ) - -# logout endpoint -@app.route("/logout") -def logout(): - # delete the session token and redirect back to the main page - del session['token'] - return redirect('/') - -# OAuth callback endpoint -@app.route("/auth/asana/callback") -def auth_callback(): - # verify the state token matches to prevent CSRF attacks - if request.args.get('state') == session['state']: - del session['state'] - # exchange the code for a bearer token and persist it in the user's session or database - session['token'] = Client().session.fetch_token(code=request.args.get('code')) - return redirect('/') - else: - return "state doesn't match!" - -app.secret_key = 'set this to something secret' - -if __name__ == "__main__": - app.run(debug=True) diff --git a/examples/example-summary-task.py b/examples/example-summary-task.py deleted file mode 100755 index 66cb860e..00000000 --- a/examples/example-summary-task.py +++ /dev/null @@ -1,106 +0,0 @@ -import asana -import json -from datetime import date -import argparse -import sys, os -sys.path.append(os.path.dirname(os.path.dirname(__file__))) - -def summarize(client, project_id, post_project): - """ - Collect data from project_id, and create a summary task in the post_project. - """ - # Get info on the project - project = client.projects.get_project(project_id) - - # Loop through the tasks, collecting data - all_tasks = 0 - tasks_completed = 0 - tasks = client.tasks.get_tasks_for_project(project_id, opt_fields=['completed']) - for task in tasks: - all_tasks += 1 - if task['completed']: - tasks_completed += 1 - - # Make the summary task - summary_task_fields = { - 'projects': [post_project], - 'name': "{} Summary of \"{}\"".format( - date.today().isoformat(), project['name']), - 'notes': "{} tasks\n{} ({:.0%}) tasks completed".format( - all_tasks, tasks_completed, tasks_completed / all_tasks) - } - client.tasks.create_task(**summary_task_fields) - -def main(): - """ - Parse arguments, authorize user, and summarize each given project. - """ - parser = argparse.ArgumentParser() - parser.add_argument("project_to_summarize", - help="project id of project to summarize") - parser.add_argument("summary_project", - help="project id of summary project to post to") - args = parser.parse_args() - - # Use OAuth - # check if the user has an existing token stored. - authorized = False - client = None - if 'ASANA_CLIENT_ID' in os.environ and 'ASANA_TOKEN' in os.environ: - # create a client with your OAuth client ID and a previously obtained - # bearer token - client = asana.Client.oauth( - client_id=os.environ['ASANA_CLIENT_ID'], - token=json.loads(os.environ['ASANA_TOKEN']) - ) - print("authorized=", client.session.authorized) - - # try to get something to see if token has not expired. - try: - client.users.get_user('me') - authorized = True - except: - print("token expired. please update ASANA_TOKEN") - - # check if the user has the secret - if not authorized and 'ASANA_CLIENT_ID' in os.environ and 'ASANA_CLIENT_SECRET' in os.environ: - # create a client with the OAuth credentials: - client = asana.Client.oauth( - client_id=os.environ['ASANA_CLIENT_ID'], - client_secret=os.environ['ASANA_CLIENT_SECRET'], - # this special redirect URI will prompt the user to copy/paste the code - # useful for command line scripts and other non-web apps - redirect_uri='urn:ietf:wg:oauth:2.0:oob' - ) - - # get an authorization URL: - (url, state) = client.session.authorization_url() - try: - # in a web app you'd redirect the user to this URL when they take - # action to login with Asana or connect their account to Asana - import webbrowser - webbrowser.open(url) - except Exception as e: - print("Open the following URL in a browser to authorize:") - print(url) - - print("Copy and paste the returned code from the browser and press enter:") - - code = sys.stdin.readline().strip() - # exchange the code for a bearer token will fail on incorrect code - token = client.session.fetch_token(code=code) - - print("token=", json.dumps(token)) - - # normally you'd persist this token somewhere - os.environ['ASANA_TOKEN'] = json.dumps(token) # (see below) - - if not client or not client.session.authorized: - print("COULD NOT AUTHORIZE") - exit(1) - - # Summarize the project. - summarize(client, args.project_to_summarize, args.summary_project) - -if __name__ == '__main__': - main() diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index fd138620..00000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -pytest~=7.2 -requests_oauthlib~=1.3 -requests~=2.28 -responses~=0.22 diff --git a/samples/attachments_sample.yaml b/samples/attachments_sample.yaml deleted file mode 100644 index 06d430e2..00000000 --- a/samples/attachments_sample.yaml +++ /dev/null @@ -1,33 +0,0 @@ -attachments: - create_attachment_for_object: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.attachments.create_attachment_for_object({'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_attachment: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.attachments.delete_attachment(attachment_gid, opt_pretty=True) - get_attachment: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.attachments.get_attachment(attachment_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_attachments_for_object: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.attachments.get_attachments_for_object({'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/audit_log_api_sample.yaml b/samples/audit_log_api_sample.yaml deleted file mode 100644 index 8dbcccf5..00000000 --- a/samples/audit_log_api_sample.yaml +++ /dev/null @@ -1,9 +0,0 @@ -auditlogapi: - get_audit_log_events: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.audit_log_api.get_audit_log_events(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/batch_api_sample.yaml b/samples/batch_api_sample.yaml deleted file mode 100644 index a4a1b1b3..00000000 --- a/samples/batch_api_sample.yaml +++ /dev/null @@ -1,9 +0,0 @@ -batchapi: - create_batch_request: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.batch_api.create_batch_request({'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/custom_field_settings_sample.yaml b/samples/custom_field_settings_sample.yaml deleted file mode 100644 index ded3bf82..00000000 --- a/samples/custom_field_settings_sample.yaml +++ /dev/null @@ -1,17 +0,0 @@ -customfieldsettings: - get_custom_field_settings_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_field_settings.get_custom_field_settings_for_portfolio(portfolio_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_custom_field_settings_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_field_settings.get_custom_field_settings_for_project(project_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/custom_fields_sample.yaml b/samples/custom_fields_sample.yaml deleted file mode 100644 index e3b48a1b..00000000 --- a/samples/custom_fields_sample.yaml +++ /dev/null @@ -1,65 +0,0 @@ -customfields: - create_custom_field: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_fields.create_custom_field({'field': 'value', 'field': 'value'}, opt_pretty=True) - create_enum_option_for_custom_field: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_fields.create_enum_option_for_custom_field(custom_field_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_custom_field: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_fields.delete_custom_field(custom_field_gid, opt_pretty=True) - get_custom_field: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_fields.get_custom_field(custom_field_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_custom_fields_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_fields.get_custom_fields_for_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - insert_enum_option_for_custom_field: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_fields.insert_enum_option_for_custom_field(custom_field_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_custom_field: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_fields.update_custom_field(custom_field_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_enum_option: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.custom_fields.update_enum_option(enum_option_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/events_sample.yaml b/samples/events_sample.yaml deleted file mode 100644 index 951bede8..00000000 --- a/samples/events_sample.yaml +++ /dev/null @@ -1,9 +0,0 @@ -events: - get_events: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.events.get_events({'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/goal_relationships_sample.yaml b/samples/goal_relationships_sample.yaml deleted file mode 100644 index 74384947..00000000 --- a/samples/goal_relationships_sample.yaml +++ /dev/null @@ -1,41 +0,0 @@ -goalrelationships: - add_supporting_relationship: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goal_relationships.add_supporting_relationship(goal_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - get_goal_relationship: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goal_relationships.get_goal_relationship(goal_relationship_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_goal_relationships: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goal_relationships.get_goal_relationships({'param': 'value', 'param': 'value'}, opt_pretty=True) - remove_supporting_relationship: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goal_relationships.remove_supporting_relationship(goal_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_goal_relationship: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goal_relationships.update_goal_relationship(goal_relationship_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/goals_sample.yaml b/samples/goals_sample.yaml deleted file mode 100644 index 100819cc..00000000 --- a/samples/goals_sample.yaml +++ /dev/null @@ -1,81 +0,0 @@ -goals: - add_followers: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.add_followers(goal_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - create_goal: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.create_goal({'field': 'value', 'field': 'value'}, opt_pretty=True) - create_goal_metric: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.create_goal_metric(goal_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_goal: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.delete_goal(goal_gid, opt_pretty=True) - get_goal: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.get_goal(goal_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_goals: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.get_goals({'param': 'value', 'param': 'value'}, opt_pretty=True) - get_parent_goals_for_goal: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.get_parent_goals_for_goal(goal_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - remove_followers: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.remove_followers(goal_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_goal: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.update_goal(goal_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_goal_metric: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.goals.update_goal_metric(goal_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/jobs_sample.yaml b/samples/jobs_sample.yaml deleted file mode 100644 index 1d97b5ea..00000000 --- a/samples/jobs_sample.yaml +++ /dev/null @@ -1,9 +0,0 @@ -jobs: - get_job: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.jobs.get_job(job_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/memberships_sample.yaml b/samples/memberships_sample.yaml deleted file mode 100644 index c60224b7..00000000 --- a/samples/memberships_sample.yaml +++ /dev/null @@ -1,33 +0,0 @@ -memberships: - create_membership: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.memberships.create_membership({'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_membership: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.memberships.delete_membership(membership_gid, opt_pretty=True) - get_memberships: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.memberships.get_memberships({'param': 'value', 'param': 'value'}, opt_pretty=True) - update_membership: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.memberships.update_membership(membership_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/message_sample.yaml b/samples/message_sample.yaml deleted file mode 100644 index 89e5df77..00000000 --- a/samples/message_sample.yaml +++ /dev/null @@ -1,9 +0,0 @@ -message: - get_message: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.message.get_message(message_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/organization_exports_sample.yaml b/samples/organization_exports_sample.yaml deleted file mode 100644 index 1e1414c6..00000000 --- a/samples/organization_exports_sample.yaml +++ /dev/null @@ -1,17 +0,0 @@ -organizationexports: - create_organization_export: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.organization_exports.create_organization_export({'field': 'value', 'field': 'value'}, opt_pretty=True) - get_organization_export: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.organization_exports.get_organization_export(organization_export_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/portfolio_memberships_sample.yaml b/samples/portfolio_memberships_sample.yaml deleted file mode 100644 index ca32a779..00000000 --- a/samples/portfolio_memberships_sample.yaml +++ /dev/null @@ -1,25 +0,0 @@ -portfoliomemberships: - get_portfolio_membership: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolio_memberships.get_portfolio_membership(portfolio_membership_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_portfolio_memberships: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolio_memberships.get_portfolio_memberships({'param': 'value', 'param': 'value'}, opt_pretty=True) - get_portfolio_memberships_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolio_memberships.get_portfolio_memberships_for_portfolio(portfolio_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/portfolios_sample.yaml b/samples/portfolios_sample.yaml deleted file mode 100644 index 4bbc0f6a..00000000 --- a/samples/portfolios_sample.yaml +++ /dev/null @@ -1,97 +0,0 @@ -portfolios: - add_custom_field_setting_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.add_custom_field_setting_for_portfolio(portfolio_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - add_item_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.add_item_for_portfolio(portfolio_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - add_members_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.add_members_for_portfolio(portfolio_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - create_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.create_portfolio({'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.delete_portfolio(portfolio_gid, opt_pretty=True) - get_items_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.get_items_for_portfolio(portfolio_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.get_portfolio(portfolio_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_portfolios: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.get_portfolios({'param': 'value', 'param': 'value'}, opt_pretty=True) - remove_custom_field_setting_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.remove_custom_field_setting_for_portfolio(portfolio_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_item_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.remove_item_for_portfolio(portfolio_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_members_for_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.remove_members_for_portfolio(portfolio_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_portfolio: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.portfolios.update_portfolio(portfolio_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/project_briefs_sample.yaml b/samples/project_briefs_sample.yaml deleted file mode 100644 index af64d5a7..00000000 --- a/samples/project_briefs_sample.yaml +++ /dev/null @@ -1,33 +0,0 @@ -projectbriefs: - create_project_brief: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_briefs.create_project_brief(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_project_brief: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_briefs.delete_project_brief(project_brief_gid, opt_pretty=True) - get_project_brief: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_briefs.get_project_brief(project_brief_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - update_project_brief: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_briefs.update_project_brief(project_brief_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/project_memberships_sample.yaml b/samples/project_memberships_sample.yaml deleted file mode 100644 index 32539a28..00000000 --- a/samples/project_memberships_sample.yaml +++ /dev/null @@ -1,17 +0,0 @@ -projectmemberships: - get_project_membership: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_memberships.get_project_membership(project_membership_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_project_memberships_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_memberships.get_project_memberships_for_project(project_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/project_statuses_sample.yaml b/samples/project_statuses_sample.yaml deleted file mode 100644 index 4b9703d6..00000000 --- a/samples/project_statuses_sample.yaml +++ /dev/null @@ -1,33 +0,0 @@ -projectstatuses: - create_project_status_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_statuses.create_project_status_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_project_status: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_statuses.delete_project_status(project_status_gid, opt_pretty=True) - get_project_status: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_statuses.get_project_status(project_status_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_project_statuses_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_statuses.get_project_statuses_for_project(project_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/project_templates_sample.yaml b/samples/project_templates_sample.yaml deleted file mode 100644 index ae4b37d5..00000000 --- a/samples/project_templates_sample.yaml +++ /dev/null @@ -1,33 +0,0 @@ -projecttemplates: - get_project_template: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_templates.get_project_template(project_template_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_project_templates: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_templates.get_project_templates({'param': 'value', 'param': 'value'}, opt_pretty=True) - get_project_templates_for_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_templates.get_project_templates_for_team(team_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - instantiate_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.project_templates.instantiate_project(project_template_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/projects_sample.yaml b/samples/projects_sample.yaml deleted file mode 100644 index 30fd7d09..00000000 --- a/samples/projects_sample.yaml +++ /dev/null @@ -1,153 +0,0 @@ -projects: - add_custom_field_setting_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.add_custom_field_setting_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - add_followers_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.add_followers_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - add_members_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.add_members_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - create_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.create_project({'field': 'value', 'field': 'value'}, opt_pretty=True) - create_project_for_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.create_project_for_team(team_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - create_project_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.create_project_for_workspace(workspace_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.delete_project(project_gid, opt_pretty=True) - duplicate_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.duplicate_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - get_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.get_project(project_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_projects: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.get_projects({'param': 'value', 'param': 'value'}, opt_pretty=True) - get_projects_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.get_projects_for_task(task_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_projects_for_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.get_projects_for_team(team_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_projects_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.get_projects_for_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_task_counts_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.get_task_counts_for_project(project_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - project_save_as_template: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.project_save_as_template(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_custom_field_setting_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.remove_custom_field_setting_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_followers_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.remove_followers_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_members_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.remove_members_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.projects.update_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/sections_sample.yaml b/samples/sections_sample.yaml deleted file mode 100644 index c6e7eeca..00000000 --- a/samples/sections_sample.yaml +++ /dev/null @@ -1,57 +0,0 @@ -sections: - add_task_for_section: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.sections.add_task_for_section(section_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - create_section_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.sections.create_section_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_section: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.sections.delete_section(section_gid, opt_pretty=True) - get_section: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.sections.get_section(section_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_sections_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.sections.get_sections_for_project(project_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - insert_section_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.sections.insert_section_for_project(project_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_section: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.sections.update_section(section_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/status_updates_sample.yaml b/samples/status_updates_sample.yaml deleted file mode 100644 index 9da2ba90..00000000 --- a/samples/status_updates_sample.yaml +++ /dev/null @@ -1,33 +0,0 @@ -statusupdates: - create_status_for_object: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.status_updates.create_status_for_object({'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_status: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.status_updates.delete_status(status_gid, opt_pretty=True) - get_status: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.status_updates.get_status(status_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_statuses_for_object: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.status_updates.get_statuses_for_object({'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/stories_sample.yaml b/samples/stories_sample.yaml deleted file mode 100644 index c6d858fb..00000000 --- a/samples/stories_sample.yaml +++ /dev/null @@ -1,41 +0,0 @@ -stories: - create_story_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.stories.create_story_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_story: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.stories.delete_story(story_gid, opt_pretty=True) - get_stories_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.stories.get_stories_for_task(task_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_story: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.stories.get_story(story_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - update_story: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.stories.update_story(story_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/tags_sample.yaml b/samples/tags_sample.yaml deleted file mode 100644 index fdf954cb..00000000 --- a/samples/tags_sample.yaml +++ /dev/null @@ -1,65 +0,0 @@ -tags: - create_tag: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tags.create_tag({'field': 'value', 'field': 'value'}, opt_pretty=True) - create_tag_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tags.create_tag_for_workspace(workspace_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_tag: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tags.delete_tag(tag_gid, opt_pretty=True) - get_tag: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tags.get_tag(tag_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_tags: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tags.get_tags({'param': 'value', 'param': 'value'}, opt_pretty=True) - get_tags_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tags.get_tags_for_task(task_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_tags_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tags.get_tags_for_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - update_tag: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tags.update_tag(tag_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/tasks_sample.yaml b/samples/tasks_sample.yaml deleted file mode 100644 index b551a3dc..00000000 --- a/samples/tasks_sample.yaml +++ /dev/null @@ -1,209 +0,0 @@ -tasks: - add_dependencies_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.add_dependencies_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - add_dependents_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.add_dependents_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - add_followers_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.add_followers_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - add_project_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.add_project_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - add_tag_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.add_tag_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - create_subtask_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.create_subtask_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - create_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.create_task({'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.delete_task(task_gid, opt_pretty=True) - duplicate_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.duplicate_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - get_dependencies_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_dependencies_for_task(task_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_dependents_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_dependents_for_task(task_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_subtasks_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_subtasks_for_task(task_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_task(task_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_tasks: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_tasks({'param': 'value', 'param': 'value'}, opt_pretty=True) - get_tasks_for_project: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_tasks_for_project(project_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_tasks_for_section: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_tasks_for_section(section_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_tasks_for_tag: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_tasks_for_tag(tag_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_tasks_for_user_task_list: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.get_tasks_for_user_task_list(user_task_list_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - remove_dependencies_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.remove_dependencies_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_dependents_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.remove_dependents_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_follower_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.remove_follower_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_project_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.remove_project_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - remove_tag_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.remove_tag_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - search_tasks_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.search_tasks_for_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - set_parent_for_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.set_parent_for_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_task: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.tasks.update_task(task_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/team_memberships_sample.yaml b/samples/team_memberships_sample.yaml deleted file mode 100644 index 2b30cfb1..00000000 --- a/samples/team_memberships_sample.yaml +++ /dev/null @@ -1,33 +0,0 @@ -teammemberships: - get_team_membership: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.team_memberships.get_team_membership(team_membership_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_team_memberships: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.team_memberships.get_team_memberships({'param': 'value', 'param': 'value'}, opt_pretty=True) - get_team_memberships_for_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.team_memberships.get_team_memberships_for_team(team_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_team_memberships_for_user: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.team_memberships.get_team_memberships_for_user(user_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/teams_sample.yaml b/samples/teams_sample.yaml deleted file mode 100644 index d2e09aca..00000000 --- a/samples/teams_sample.yaml +++ /dev/null @@ -1,57 +0,0 @@ -teams: - add_user_for_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.teams.add_user_for_team(team_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - create_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.teams.create_team({'field': 'value', 'field': 'value'}, opt_pretty=True) - get_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.teams.get_team(team_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_teams_for_user: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.teams.get_teams_for_user(user_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_teams_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.teams.get_teams_for_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - remove_user_for_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.teams.remove_user_for_team(team_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.teams.update_team({'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/time_periods_sample.yaml b/samples/time_periods_sample.yaml deleted file mode 100644 index e9c7e415..00000000 --- a/samples/time_periods_sample.yaml +++ /dev/null @@ -1,17 +0,0 @@ -timeperiods: - get_time_period: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.time_periods.get_time_period(time_period_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_time_periods: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.time_periods.get_time_periods({'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/typeahead_sample.yaml b/samples/typeahead_sample.yaml deleted file mode 100644 index 37b55e19..00000000 --- a/samples/typeahead_sample.yaml +++ /dev/null @@ -1,9 +0,0 @@ -typeahead: - typeahead_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.typeahead.typeahead_for_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/user_task_lists_sample.yaml b/samples/user_task_lists_sample.yaml deleted file mode 100644 index 8c73f216..00000000 --- a/samples/user_task_lists_sample.yaml +++ /dev/null @@ -1,17 +0,0 @@ -usertasklists: - get_user_task_list: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.user_task_lists.get_user_task_list(user_task_list_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_user_task_list_for_user: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.user_task_lists.get_user_task_list_for_user(user_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/users_sample.yaml b/samples/users_sample.yaml deleted file mode 100644 index dfbae326..00000000 --- a/samples/users_sample.yaml +++ /dev/null @@ -1,41 +0,0 @@ -users: - get_favorites_for_user: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.users.get_favorites_for_user(user_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_user: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.users.get_user(user_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_users: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.users.get_users({'param': 'value', 'param': 'value'}, opt_pretty=True) - get_users_for_team: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.users.get_users_for_team(team_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_users_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.users.get_users_for_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/webhooks_sample.yaml b/samples/webhooks_sample.yaml deleted file mode 100644 index 7cd66242..00000000 --- a/samples/webhooks_sample.yaml +++ /dev/null @@ -1,41 +0,0 @@ -webhooks: - create_webhook: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.webhooks.create_webhook({'field': 'value', 'field': 'value'}, opt_pretty=True) - delete_webhook: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.webhooks.delete_webhook(webhook_gid, opt_pretty=True) - get_webhook: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.webhooks.get_webhook(webhook_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_webhooks: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.webhooks.get_webhooks({'param': 'value', 'param': 'value'}, opt_pretty=True) - update_webhook: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.webhooks.update_webhook(webhook_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/samples/workspace_memberships_sample.yaml b/samples/workspace_memberships_sample.yaml deleted file mode 100644 index 0901c48f..00000000 --- a/samples/workspace_memberships_sample.yaml +++ /dev/null @@ -1,25 +0,0 @@ -workspacememberships: - get_workspace_membership: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.workspace_memberships.get_workspace_membership(workspace_membership_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_workspace_memberships_for_user: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.workspace_memberships.get_workspace_memberships_for_user(user_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_workspace_memberships_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.workspace_memberships.get_workspace_memberships_for_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) diff --git a/samples/workspaces_sample.yaml b/samples/workspaces_sample.yaml deleted file mode 100644 index cff9a078..00000000 --- a/samples/workspaces_sample.yaml +++ /dev/null @@ -1,41 +0,0 @@ -workspaces: - add_user_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.workspaces.add_user_for_workspace(workspace_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - get_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.workspaces.get_workspace(workspace_gid, {'param': 'value', 'param': 'value'}, opt_pretty=True) - get_workspaces: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.workspaces.get_workspaces({'param': 'value', 'param': 'value'}, opt_pretty=True) - remove_user_for_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.workspaces.remove_user_for_workspace(workspace_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) - update_workspace: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.workspaces.update_workspace(workspace_gid, {'field': 'value', 'field': 'value'}, opt_pretty=True) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ed8a958e..00000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[bdist_wheel] -universal = 1 - -[metadata] -license_file = LICENSE diff --git a/setup.py b/setup.py deleted file mode 100755 index b695d5d9..00000000 --- a/setup.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python - -import sys -import os -from setuptools import setup, find_packages - -assert sys.version_info >= (3, 7), 'We only support Python 3.7+' - -sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'asana')) - -# Safely read the version number from the version.py file -version = {} -with open('asana/version.py') as fp: - exec(fp.read(), version) - -with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme: - long_description = readme.read() - -setup( - name='asana', - version=version['__version__'], - description='Asana API client', - long_description=long_description, - long_description_content_type='text/markdown', - license='MIT', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7' - ], - install_requires=[ - 'requests >= 2.20.0, == 2.*', - 'requests_oauthlib >= 0.8.0, <2.0', - ], - author='Asana, Inc', - # author_email='', - url='http://github.com/asana/python-asana', - packages=find_packages(exclude=('tests', 'examples')), - keywords='asana', - zip_safe=True, - test_suite='tests') diff --git a/swagger_templates/api.mustache b/swagger_templates/api.mustache deleted file mode 100644 index 52d17b33..00000000 --- a/swagger_templates/api.mustache +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -{{#operations}} -class _{{classname}}: - - def __init__(self, client=None): - self.client = client -{{#operation}}{{^formParams}} -{{#contents}} - - def {{operationId}}(self, {{#pathParams}}{{paramName}}, {{/pathParams}}params=None, **options): - """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} - {{#pathParams}} - :param {{dataType}} {{paramName}}:{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}{{#description}} {{{description}}}{{/description}} - {{/pathParams}} - :param Object params: Parameters for the request{{#queryParams}}{{#neq baseName 'opt_pretty' 'opt_fields' 'offset' 'limit'}} - - {{paramName}} { {{~dataType~}} }: {{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}{{#description}} {{{description}}}{{/description}}{{/neq}}{{/queryParams}} - :param **options{{#queryParams}}{{#eq baseName 'opt_pretty' 'opt_fields' 'offset' 'limit'}} - - {{paramName}} { {{~dataType~}} }: {{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}{{#description}} {{{description}}}{{/description}}{{/eq}}{{/queryParams}} - :return: Object - """ - if params is None: - params = {} - path = "{{path}}"{{#pathParams}}.replace("{ {{~baseName~}} }", {{paramName}}){{/pathParams}} - return self.client.{{#neq "GET" httpMethod}}{{toLowerCase httpMethod}}{{/neq}}{{#eq "GET" httpMethod}}{{returnContainer}}{{/eq}}(path, params, **options) -{{/contents}} -{{/formParams}}{{/operation}} -{{/operations}} diff --git a/swagger_templates/api_doc.mustache b/swagger_templates/api_doc.mustache deleted file mode 100644 index 46e46411..00000000 --- a/swagger_templates/api_doc.mustache +++ /dev/null @@ -1,10 +0,0 @@ -{{#operations}}{{toLowerCase classname}}: {{#operation}}{{#contents}} - {{operationId}}: >- - import asana - - - client = asana.Client.access_token('PERSONAL_ACCESS_TOKEN') - - - result = client.{{toLowerCase baseName}}.{{operationId}}({{#pathParams}}{{paramName}}, {{/pathParams}}{{#neq "GET" httpMethod}}{{#neq "DELETE" httpMethod}}{'field': 'value', 'field': 'value'}, {{/neq}}{{/neq}}{{#eq "GET" httpMethod}}{'param': 'value', 'param': 'value'}, {{/eq}}opt_pretty=True){{/contents}}{{/operation}} -{{/operations}} diff --git a/swagger_templates/python-config.json b/swagger_templates/python-config.json deleted file mode 100644 index af0ec379..00000000 --- a/swagger_templates/python-config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "packageName" : "asana", - "templateDir": "swagger_templates", - "hideGenerationTimestamp": true, - "apiTests": false -} diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/helpers.py b/tests/helpers.py deleted file mode 100644 index 5167c04b..00000000 --- a/tests/helpers.py +++ /dev/null @@ -1,40 +0,0 @@ -import json -import unittest - -import asana -import requests -import responses -from responses import GET, PUT, POST, DELETE - -# Define JSON primitives so we can just copy in JSON: -false = False -true = True -null = None - - -def create_decorating_metaclass(decorators, prefix='test_'): - class DecoratingMethodsMetaclass(type): - def __new__(cls, name, bases, namespace): - namespace_items = tuple(namespace.items()) - for key, val in namespace_items: - if key.startswith(prefix) and callable(val): - for dec in decorators: - val = dec(val) - namespace[key] = val - return type.__new__(cls, name, bases, dict(namespace)) - - return DecoratingMethodsMetaclass - - -# TestCase subclass that automatically decorates test methods with -# responses.activate and sets up a client instance -class ClientTestCase(unittest.TestCase, metaclass=create_decorating_metaclass((responses.activate,))): - - def setUp(self): - self.client = asana.Client( - base_url='http://app', - # no delay when polling to speed up tests - poll_interval=0, - # disable iterator and limit to match existing tests for now - iterator_type=None, - ) diff --git a/tests/test_client.py b/tests/test_client.py deleted file mode 100644 index 9dd1c62f..00000000 --- a/tests/test_client.py +++ /dev/null @@ -1,407 +0,0 @@ -import warnings -try: - from mock import patch, call -except ImportError: - from unittest.mock import patch, call - -from .helpers import * - -class TestClient(ClientTestCase): - - def test_version_values(self): - values = self.client._version_values() - self.assertEqual('Python', values['language']) - self.assertRegex(values['version'], r'[0-9]+[.][0-9]+[.][0-9]+') - self.assertSetEqual( - {'language', 'version', 'language_version', 'os', 'os_version'}, - set(values.keys())) - - def test_version_header(self): - self.assertRegex( - self.client._version_header(), r'language=Python') - - def test_default_headers(self): - self.client.headers['key'] = 'value' - responses.add(GET, 'http://app/users/me', status=200, body='{"data":{}}') - self.client.users.get_user('me') - self.assertLessEqual( - set({'key': 'value'}.items()), - set(responses.calls[0].request.headers.items()) - ) - - def test_request_headers(self): - responses.add(GET, 'http://app/users/me', status=200, body='{"data":{}}') - self.client.users.get_user('me', headers={'key': 'value'}) - self.assertLessEqual( - set({'key': 'value'}.items()), - set(responses.calls[0].request.headers.items()) - ) - - def test_overriding_headers(self): - self.client.headers['key'] = 'value' - self.client.headers['key2'] = 'value2' - responses.add(GET, 'http://app/users/me', status=200, body='{"data":{}}') - self.client.users.get_user('me', headers={'key2': 'value3'}) - self.assertLessEqual( - set({'key': 'value', 'key2': 'value3'}.items()), - set(responses.calls[0].request.headers.items()) - ) - - def test_content_type_headers(self): - self.client.headers['key'] = 'value' - responses.add(POST, 'http://app/tasks/123/addProject', status=200, - body='{"data":{}}') - self.client.tasks.add_project(123, project=456, headers={'key2': 'value2'}) - self.assertLessEqual( - set({'content-type': 'application/json'}.items()), - set(responses.calls[0].request.headers.items()) - ) - - def test_users_me_not_authorized(self): - res = { - "errors": [ - { "message": "Not Authorized" } - ] - } - responses.add(GET, 'http://app/users/me', status=401, body=json.dumps(res), match_querystring=True) - self.assertRaises(asana.error.NoAuthorizationError, self.client.users.get_user, 'me') - - def test_tasks_get_tasks_invalid_request(self): - res = { - "errors": [ - { "message": "workspace: Missing input" } - ] - } - responses.add(GET, 'http://app/tasks', status=400, body=json.dumps(res), match_querystring=True) - self.assertRaises(asana.error.InvalidRequestError, self.client.tasks.get_tasks) - - def test_users_me_server_error(self): - res = { - "errors": [ - { - "message": "Server Error", - "phrase": "6 sad squid snuggle softly" - } - ] - } - responses.add(GET, 'http://app/users/me', status=500, body=json.dumps(res), match_querystring=True) - self.assertRaises(asana.error.ServerError, self.client.users.get_user, 'me', max_retries=0) - - def test_users_me_unfriendly_server_error(self): - res = "Crappy Response" - responses.add(GET, 'http://app/users/me', status=504, body=res, match_querystring=True) - self.assertRaises(asana.error.ServerError, self.client.users.get_user, 'me', max_retries=0) - - def test_users_get_user_not_found(self): - res = { - "errors": [ - { "message": "user: Unknown object: 1234124312341" } - ] - } - responses.add(GET, 'http://app/users/1234', status=404, body=json.dumps(res), match_querystring=True) - self.assertRaises(asana.error.NotFoundError, self.client.users.get_user, ('1234')) - - def test_users_get_user_forbidden(self): - res = { - "errors": [ - { "message": "user: Forbidden" } - ] - } - responses.add(GET, 'http://app/users/1234', status=403, body=json.dumps(res), match_querystring=True) - self.assertRaises(asana.error.ForbiddenError, self.client.users.get_user, ('1234')) - - def test_option_pretty(self): - res = { - "data": { "email": "sanchez@...", "id": 999, "name": "Greg Sanchez" } - } - responses.add(GET, 'http://app/users/me?opt_pretty=true', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.users.get_user('me', pretty=True), res['data']) - - def test_option_fields(self): - res = { - "data": { "name": "Make a list", "notes": "Check it twice!", "id": 1224 } - } - responses.add(GET, 'http://app/tasks/1224?opt_fields=name%2Cnotes', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.get_task('1224', fields=['name','notes']), res['data']) - - def test_option_expand(self): - req = { - 'data': { 'assignee': 1234 }, - 'options': { 'expand' : ['projects'] } - } - res = { - "data": { - "id": 1001, - "projects": [ - { - "archived": false, - "created_at": "", - "followers": [], - "modified_at": "", - "notes": "", - "id": 1331, - "name": "Things to buy" - } - ] - # ... - } - } - responses.add(PUT, 'http://app/tasks/1001', status=200, body=json.dumps(res), match_querystring=True) - # -d "assignee=1234" \ - # -d "options.expand=%2Aprojects%2A" - self.assertEqual(self.client.tasks.update_task('1001', req['data'], expand=['projects']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_pagination(self): - res = { - "data": [ - { "id": 1000, "name": "Task 1" } - ], - "next_page": { - "offset": "yJ0eXAiOiJKV1QiLCJhbGciOiJIRzI1NiJ9", - "path": "/tasks?project=1337&limit=5&offset=yJ0eXAiOiJKV1QiLCJhbGciOiJIRzI1NiJ9", - "uri": "https://app.asana.com/api/1.0/tasks?project=1337&limit=5&offset=yJ0eXAiOiJKV1QiLCJhbGciOiJIRzI1NiJ9" - } - } - responses.add(GET, 'http://app/projects/1337/tasks?limit=5&offset=eyJ0eXAiOJiKV1iQLCJhbGciOiJIUzI1NiJ9', status=200, body=json.dumps(res), match_querystring=True) - - self.assertEqual(self.client.tasks.get_tasks_for_project('1337', { 'limit': 5, 'offset': 'eyJ0eXAiOJiKV1iQLCJhbGciOiJIUzI1NiJ9'}), res['data']) - - @unittest.skip("iterator_type='pages' disabled") - def test_page_iterator_item_limit_lt_items(self): - responses.add(GET, 'http://app/projects/1337/tasks?limit=2', status=200, body=json.dumps({ 'data': ['a', 'b'], 'next_page': { 'offset': 'a', 'path': '/projects/1337/tasks?limit=2&offset=a' } }), match_querystring=True) - responses.add(GET, 'http://app/projects/1337/tasks?limit=2&offset=a', status=200, body=json.dumps({ 'data': ['c'], 'next_page': null }), match_querystring=True) - - iterator = self.client.tasks.get_tasks_for_project('1337', item_limit=2, page_size=2, iterator_type='pages') - self.assertEqual(next(iterator), ['a', 'b']) - self.assertRaises(StopIteration, next, (iterator)) - - @unittest.skip("iterator_type='pages' disabled") - def test_page_iterator_item_limit_eq_items(self): - responses.add(GET, 'http://app/projects/1337/tasks?limit=2', status=200, body=json.dumps({ 'data': ['a', 'b'], 'next_page': { 'offset': 'a', 'path': '/projects/1337/tasks?limit=2&offset=a' } }), match_querystring=True) - responses.add(GET, 'http://app/projects/1337/tasks?limit=1&offset=a', status=200, body=json.dumps({ 'data': ['c'], 'next_page': null }), match_querystring=True) - - iterator = self.client.tasks.get_tasks_for_project('1337', item_limit=3, page_size=2, iterator_type='pages') - self.assertEqual(next(iterator), ['a', 'b']) - self.assertEqual(next(iterator), ['c']) - self.assertRaises(StopIteration, next, (iterator)) - - @unittest.skip("iterator_type='pages' disabled") - def test_page_iterator_item_limit_gt_items(self): - responses.add(GET, 'http://app/projects/1337/tasks?limit=2', status=200, body=json.dumps({ 'data': ['a', 'b'], 'next_page': { 'offset': 'a', 'path': '/projects/1337/tasks?limit=2&offset=a' } }), match_querystring=True) - responses.add(GET, 'http://app/projects/1337/tasks?limit=2&offset=a', status=200, body=json.dumps({ 'data': ['c'], 'next_page': null }), match_querystring=True) - - iterator = self.client.tasks.get_tasks_for_project('1337', item_limit=4, page_size=2, iterator_type='pages') - self.assertEqual(next(iterator), ['a', 'b']) - self.assertEqual(next(iterator), ['c']) - self.assertRaises(StopIteration, next, (iterator)) - - def test_item_iterator_item_limit_lt_items(self): - responses.add(GET, 'http://app/projects/1337/tasks?limit=2', status=200, body=json.dumps({ 'data': ['a', 'b'], 'next_page': { 'offset': 'a', 'path': '/projects/1337/tasks?limit=2&offset=a' } }), match_querystring=True) - - iterator = self.client.tasks.get_tasks_for_project('1337', item_limit=2, page_size=2, iterator_type='items') - self.assertEqual(next(iterator), 'a') - self.assertEqual(next(iterator), 'b') - self.assertRaises(StopIteration, next, (iterator)) - - def test_item_iterator_item_limit_eq_items(self): - responses.add(GET, 'http://app/projects/1337/tasks?limit=2', status=200, body=json.dumps({ 'data': ['a', 'b'], 'next_page': { 'offset': 'a', 'path': '/projects/1337/tasks?limit=2&offset=a' } }), match_querystring=True) - responses.add(GET, 'http://app/projects/1337/tasks?limit=1&offset=a', status=200, body=json.dumps({ 'data': ['c'], 'next_page': null }), match_querystring=True) - - iterator = self.client.tasks.get_tasks_for_project('1337', item_limit=3, page_size=2, iterator_type='items') - self.assertEqual(next(iterator), 'a') - self.assertEqual(next(iterator), 'b') - self.assertEqual(next(iterator), 'c') - self.assertRaises(StopIteration, next, (iterator)) - - def test_item_iterator_item_limit_gt_items(self): - responses.add(GET, 'http://app/projects/1337/tasks?limit=2', status=200, body=json.dumps({ 'data': ['a', 'b'], 'next_page': { 'offset': 'a', 'path': '/projects/1337/tasks?limit=2&offset=a' } }), match_querystring=True) - responses.add(GET, 'http://app/projects/1337/tasks?limit=2&offset=a', status=200, body=json.dumps({ 'data': ['c'], 'next_page': null }), match_querystring=True) - - iterator = self.client.tasks.get_tasks_for_project('1337', item_limit=4, page_size=2, iterator_type='items') - self.assertEqual(next(iterator), 'a') - self.assertEqual(next(iterator), 'b') - self.assertEqual(next(iterator), 'c') - self.assertRaises(StopIteration, next, (iterator)) - - def test_item_iterator_preserve_opt_fields(self): - responses.add(GET, 'http://app/projects/1337/tasks?limit=2&opt_fields=foo', status=200, body=json.dumps({ 'data': ['a', 'b'], 'next_page': { 'offset': 'a', 'path': '/projects/1337/tasks?limit=2&offset=a' } }), match_querystring=True) - responses.add(GET, 'http://app/projects/1337/tasks?limit=1&opt_fields=foo&offset=a', status=200, body=json.dumps({ 'data': ['c'], 'next_page': null }), match_querystring=True) - - iterator = self.client.tasks.get_tasks_for_project('1337', item_limit=3, page_size=2, fields=['foo'], iterator_type='items') - self.assertEqual(next(iterator), 'a') - self.assertEqual(next(iterator), 'b') - self.assertEqual(next(iterator), 'c') - self.assertRaises(StopIteration, next, (iterator)) - - @patch('time.sleep') - def test_rate_limiting(self, time_sleep): - res = [ - (429, { 'Retry-After': '10' }, '{}'), - (200, {}, json.dumps({ 'data': 'me' })) - ] - responses.add_callback(responses.GET, 'http://app/users/me', callback=lambda r: res.pop(0), content_type='application/json') - - self.assertEqual(self.client.users.get_user('me'), 'me') - self.assertEqual(len(responses.calls), 2) - self.assertEqual(time_sleep.mock_calls, [call(10.0)]) - - @patch('time.sleep') - def test_rate_limited_twice(self, time_sleep): - res = [ - (429, { 'Retry-After': '10' }, '{}'), - (429, { 'Retry-After': '1' }, '{}'), - (200, {}, json.dumps({ 'data': 'me' })) - ] - responses.add_callback(responses.GET, 'http://app/users/me', callback=lambda r: res.pop(0), content_type='application/json') - - self.assertEqual(self.client.users.get_user('me'), 'me') - self.assertEqual(len(responses.calls), 3) - self.assertEqual(time_sleep.mock_calls, [call(10.0), call(1.0)]) - - @patch('time.sleep') - def test_server_error_retry(self, time_sleep): - res = [ - (500, {}, '{}'), - (500, {}, '{}'), - (500, {}, '{}'), - (200, {}, json.dumps({ 'data': 'me' })) - ] - responses.add_callback(responses.GET, 'http://app/users/me', callback=lambda r: res.pop(0), content_type='application/json') - - self.assertRaises(asana.error.ServerError, self.client.users.get_user, 'me', max_retries=2) - self.assertEqual(time_sleep.mock_calls, [call(1.0), call(2.0)]) - - @patch('time.sleep') - def test_server_error_retry_backoff(self, time_sleep): - res = [ - (500, {}, '{}'), - (500, {}, '{}'), - (500, {}, '{}'), - (200, {}, json.dumps({ 'data': 'me' })) - ] - responses.add_callback(responses.GET, 'http://app/users/me', callback=lambda r: res.pop(0), content_type='application/json') - - self.assertEqual(self.client.users.get_user('me'), 'me') - self.assertEqual(time_sleep.mock_calls, [call(1.0), call(2.0), call(4.0)]) - - - def test_get_named_parameters(self): - responses.add(GET, 'http://app/tasks?workspace=14916&assignee=me', status=200, body=json.dumps({ 'data': 'dummy data' }), match_querystring=True) - - self.assertEqual(self.client.tasks.get_tasks(workspace=14916, assignee="me"), 'dummy data') - - def test_post_named_parameters(self): - responses.add(POST, 'http://app/tasks', status=201, body='{ "data": "dummy data" }', match_querystring=True) - - self.assertEqual(self.client.tasks.create_task(assignee=1235, followers=[5678], name="Hello, world."), 'dummy data') - self.assertEqual(json.loads(responses.calls[0].request.body), { - "data": { - "assignee": 1235, - "followers": [5678], - "name": "Hello, world." - } - }) - - def test_put_named_parameters(self): - responses.add(PUT, 'http://app/tasks/1001', status=200, body='{ "data": "dummy data" }', match_querystring=True) - - self.assertEqual(self.client.tasks.update_task('1001', assignee=1235, followers=[5678], name="Hello, world."), 'dummy data') - self.assertEqual(json.loads(responses.calls[0].request.body), { - "data": { - "assignee": 1235, - "followers": [5678], - "name": "Hello, world." - } - }) - - def test_asana_change_header_logging(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - requestHeaders = {} - responseHeaders = { - 'asana-change': 'name=string_ids;info=something;affected=true' - } - self.client._log_asana_change_header(requestHeaders, responseHeaders) - - assert len(w) == 1 - - def test_asana_change_header_logging_turned_off(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - requestHeaders = {} - responseHeaders = { - 'asana-change': 'name=string_ids;info=something;affected=true' - } - self.client.LOG_ASANA_CHANGE_WARNINGS = false - self.client._log_asana_change_header(requestHeaders, responseHeaders) - - assert len(w) == 0 - - def test_asana_change_header_ignore_case(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - requestHeaders = {} - responseHeaders = { - 'asANa-chANge': 'name=string_ids;info=something;affected=true' - } - self.client._log_asana_change_header(requestHeaders, responseHeaders) - - assert len(w) == 1 - - def test_asana_change_header_enable(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - requestHeaders = { - 'asana-enable': 'string_ids' - } - responseHeaders = { - 'asana-change': 'name=string_ids;info=something;affected=true' - } - self.client._log_asana_change_header(requestHeaders, responseHeaders) - - assert len(w) == 0 - - def test_asana_change_header_disable(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - requestHeaders = { - 'asana-disable': 'string_ids' - } - responseHeaders = { - 'asana-change': 'name=string_ids;info=something;affected=true' - } - self.client._log_asana_change_header(requestHeaders, responseHeaders) - - assert len(w) == 0 - - def test_asana_change_header_multiple(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - requestHeaders = {} - responseHeaders = { - 'asana-change': 'name=string_ids;info=something;affected=true,name=new_sections;info=something;affected=true' - } - self.client._log_asana_change_header(requestHeaders, responseHeaders) - - assert len(w) == 2 - - def test_asana_change_header_multiple_disable(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - requestHeaders = { - 'asana-disable': 'string_ids,new_sections' - } - responseHeaders = { - 'asana-change': 'name=string_ids;info=something;affected=true,name=new_sections;info=something;affected=true' - } - self.client._log_asana_change_header(requestHeaders, responseHeaders) - - assert len(w) == 0 diff --git a/tests/test_client_attachments.py b/tests/test_client_attachments.py deleted file mode 100644 index 6affeb81..00000000 --- a/tests/test_client_attachments.py +++ /dev/null @@ -1,46 +0,0 @@ -import io -import cgi - -from .helpers import * - - -class TestClientAttachments(ClientTestCase): - - def test_attachments_get_attachment(self): - res = { - "data": { - "created_at": "", - "download_url": "https://www.dropbox.com/s/1234567890abcdef/Screenshot.png?dl=1", - "host": "dropbox", - "id": 5678, - "name": "Screenshot.png", - "parent": { "id": 1337, "name": "My Task" }, - "view_url": "https://www.dropbox.com/s/1234567890abcdef/Screenshot.png" - } - } - responses.add(GET, 'http://app/attachments/5678', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.attachments.get_attachment('5678'), res['data']) - - def test_attachments_find_by_task(self): - res = { - "data": [ - { "id": 5678, "name": "Background.png" }, - { "id": 9012, "name": "New Design Draft.pdf" } - ] - } - responses.add(GET, 'http://app/tasks/1234/attachments', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.attachments.find_by_task('1234'), res['data']) - - def test_attachments_create_on_task(self): - res = { "data": { "id": 5678, "name": "file.txt" } } - responses.add(POST, 'http://app/tasks/1337/attachments', status=200, body=json.dumps(res), match_querystring=True) - - self.assertEqual(self.client.attachments.create_on_task('1337', 'file content', 'file name', 'file content-type'), res['data']) - - request_content_type, pdict = cgi.parse_header(responses.calls[0].request.headers['Content-Type']) - self.assertEqual(request_content_type, 'multipart/form-data') - - content_file = io.BytesIO(responses.calls[0].request.body) - multipart = cgi.parse_multipart(content_file, { 'boundary': bytes(pdict['boundary'], "UTF-8") }) - self.assertEqual(multipart['file'][0], bytes('file content', 'UTF-8')) - # TODO: verify filename and content-type, possibly using a different multipart decoder diff --git a/tests/test_client_audit_log_api.py b/tests/test_client_audit_log_api.py deleted file mode 100644 index ca0dc9fe..00000000 --- a/tests/test_client_audit_log_api.py +++ /dev/null @@ -1,152 +0,0 @@ -from .helpers import * - - -class TestClientAuditLogAPI(ClientTestCase): - - def test_get_audit_log_events(self): - res = { - "data": [ - { - "actor": { - "actor_type": "user", - "email": "gregsanchez@example.com", - "gid": "1111", - "name": "Greg Sanchez" - }, - "context": { - "api_authentication_method": "cookie", - "client_ip_address": "1.1.1.1", - "context_type": "web", - "oauth_app_name": "string", - "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" - }, - "created_at": "2021-01-01T00:00:00.000Z", - "details": {}, - "event_category": "deletion", - "event_type": "task_deleted", - "gid": "12345", - "resource": { - "email": "string", - "gid": "1111", - "name": "Example Task", - "resource_subtype": "milestone", - "resource_type": "task" - } - } - ], - "next_page": { - "offset": "a", - "path": "/workspaces/1337/audit_log_events?offset=a", - "uri": "https://app.asana.com/api/1.0/workspaces/1337/audit_log_events?offset=a" - } - } - responses.add(GET, 'http://app/workspaces/1337/audit_log_events?', - status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual( - self.client.audit_log_api.get_audit_log_events("1337"), res['data']) - - def test_get_audit_log_events_iterator(self): - res1 = { - "data": [ - { - "actor": { - "actor_type": "user", - "email": "gregsanchez@example.com", - "gid": "1111", - "name": "Greg Sanchez" - }, - "context": { - "api_authentication_method": "cookie", - "client_ip_address": "1.1.1.1", - "context_type": "web", - "oauth_app_name": "string", - "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" - }, - "created_at": "2021-01-01T00:00:00.000Z", - "details": {}, - "event_category": "deletion", - "event_type": "task_deleted", - "gid": "12345", - "resource": { - "email": "string", - "gid": "1111", - "name": "Example Task", - "resource_subtype": "milestone", - "resource_type": "task" - } - } - ], - "next_page": { - "offset": "a", - "path": "/workspaces/1337/audit_log_events?limit=1&offset=a", - "uri": "https://app.asana.com/api/1.0/workspaces/1337/audit_log_events?limit=1&offset=a" - } - } - res2 = { - "data": [ - { - "actor": { - "actor_type": "user", - "email": "tbizarro@example.com", - "gid": "1234", - "name": "Tim Bizarro" - }, - "context": { - "api_authentication_method": "cookie", - "client_ip_address": "1.1.1.1", - "context_type": "web", - "oauth_app_name": "string", - "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" - }, - "created_at": "2021-01-01T00:00:00.000Z", - "details": {}, - "event_category": "deletion", - "event_type": "task_deleted", - "gid": "12345", - "resource": { - "email": "string", - "gid": "1111", - "name": "Example Task", - "resource_subtype": "milestone", - "resource_type": "task" - } - } - ], - "next_page": { - "offset": "b", - "path": "/workspaces/1337/audit_log_events?limit=1&offset=b", - "uri": "https://app.asana.com/api/1.0/workspaces/1337/audit_log_events?limit=1&offset=b" - } - } - res3 = { - "data": [], - "next_page": { - "offset": "c", - "path": "/workspaces/1337/audit_log_events?limit=1&offset=c", - "uri": "https://app.asana.com/api/1.0/workspaces/1337/audit_log_events?limit=1&offset=c" - } - } - res4 = { - "data": [], - "next_page": { - "offset": "d", - "path": "/workspaces/1337/audit_log_events?limit=1&offset=d", - "uri": "https://app.asana.com/api/1.0/workspaces/1337/audit_log_events?limit=1&offset=d" - } - } - responses.add(GET, 'http://app/workspaces/1337/audit_log_events?limit=1', - status=200, body=json.dumps(res1), match_querystring=True) - responses.add(GET, 'http://app/workspaces/1337/audit_log_events?limit=1&offset=a', - status=200, body=json.dumps(res2), match_querystring=True) - responses.add(GET, 'http://app/workspaces/1337/audit_log_events?limit=1&offset=b', - status=200, body=json.dumps(res3), match_querystring=True) - responses.add(GET, 'http://app/workspaces/1337/audit_log_events?limit=1&offset=c', - status=200, body=json.dumps(res4), match_querystring=True) - # Set iterator_type to 'items' to return an iterator - iterator = self.client.audit_log_api.get_audit_log_events( - "1337", page_size=1, iterator_type='items' - ) - # Iterator should stop on third call - self.assertEqual(next(iterator), res1['data'][0]) - self.assertEqual(next(iterator), res2['data'][0]) - self.assertRaises(StopIteration, next, (iterator)) diff --git a/tests/test_client_custom_field_settings.py b/tests/test_client_custom_field_settings.py deleted file mode 100644 index 506ccc2b..00000000 --- a/tests/test_client_custom_field_settings.py +++ /dev/null @@ -1,43 +0,0 @@ -from .helpers import * - -class TestClientCustomFieldSettings(ClientTestCase): - def test_custom_field_settings_get_custom_field_settings_for_project(self): - res = { - "data": [ - { - "id": 258147, - "custom_field": [ - { - "id": 124578, - "name": "Priority", - "type": "enum" - } - ], - "project": [ - { - "id": 1331, - "name": "Things to buy" - } - ] - }, - { - "id": 369852, - "custom_field": [ - { - "id": 235689, - "name": "Cost", - "type": "enum" - } - ], - "project": [ - { - "id": 1331, - "name": "Things to buy" - } - ] - }, - ] - } - responses.add(GET, 'http://app/projects/1331/custom_field_settings', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.custom_field_settings.get_custom_field_settings_for_project('1331'), res['data']) - diff --git a/tests/test_client_custom_fields.py b/tests/test_client_custom_fields.py deleted file mode 100644 index e7b0d0a8..00000000 --- a/tests/test_client_custom_fields.py +++ /dev/null @@ -1,65 +0,0 @@ -from .helpers import * - -class TestClientCustomFields(ClientTestCase): - def test_custom_fields_get_custom_field_text(self): - res = { - "data": [ - { - "id": 134679, - "created_at": "2016-07-11T14:29:23.249Z", - "name": "Owner", - "type": "text" - } - ] - } - responses.add(GET, 'http://app/custom_fields/134679', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.custom_fields.get_custom_field('134679'), res['data']) - - def test_custom_fields_get_custom_field_enum(self): - res = { - "data": [ - { - "id": 124578, - "created_at": "2016-07-11T14:29:23.249Z", - "name": "Priority", - "type": "enum", - "enum_options": [ - { - "id": 789, - "name": "Low", - "enabled": true, - "color": "blue" - }, - { - "id": 208, - "name": "Medium", - "enabled": false, - "color": "yellow" - }, - { - "id": 439, - "name": "High", - "enabled": true, - "color": "red" - } - ] - } - ] - } - responses.add(GET, 'http://app/custom_fields/124578', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.custom_fields.get_custom_field('124578'), res['data']) - - def test_custom_fields_get_custom_field_number(self): - res = { - "data": [ - { - "id": 938271, - "created_at": "2016-07-11T14:29:23.249Z", - "name": "Price", - "type": "number", - "precision": 2 - } - ] - } - responses.add(GET, 'http://app/custom_fields/938271', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.custom_fields.get_custom_field('938271'), res['data']) diff --git a/tests/test_client_events.py b/tests/test_client_events.py deleted file mode 100644 index 145a97d6..00000000 --- a/tests/test_client_events.py +++ /dev/null @@ -1,78 +0,0 @@ -from .helpers import * - -class TestClientEvents(ClientTestCase): - - def test_events_get(self): - res = { - "data": [ - { - "action": "changed", - "created_at": "2013-08-21T18:20:37.972Z", - "parent": null, - "resource": { "id": 1337, "name": "My Task" }, - "type": "task", - "user": { "id": 1123, "name": "Tom Bizarro" } - }, - { - "action": "changed", - "created_at": "2013-08-21T18:22:45.421Z", - "parent": null, - "resource": { "id": 1338, "name": "My Other Task" }, - "type": "task", - "user": { "id": 1428, "name": "Greg Sanchez" } - } - ], - "sync": "edfc0896b370b7a479886d316131bf5c:0" - } - responses.add(GET, 'http://app/events?resource=14321&sync=de4774f6915eae04714ca93bb2f5ee81%3A3', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.events.get({ 'resource': 14321, 'sync': 'de4774f6915eae04714ca93bb2f5ee81:3' }), res) - - def test_project_events_get_invalid_token(self): - res = { - "message": "Sync token invalid or too old. If you are attemping to keep resources in sync, you must re-fetch the full dataset for this query now.", - "sync": "edfc0896b370b7a479886d316131bf5c:0" - } - responses.add(GET, 'http://app/events?resource=3214312&sync=de4774f6915eae04714ca93bb2f5ee81%3A3', status=412, body=json.dumps(res), match_querystring=True) - # responses.add(GET, 'http://app/project/3214312/events?sync=de4774f6915eae04714ca93bb2f5ee81%3A3', status=412, body=json.dumps(res), match_querystring=True) - self.assertRaises(asana.error.InvalidTokenError, self.client.events.get, ({ 'resource': 3214312, 'sync': 'de4774f6915eae04714ca93bb2f5ee81:3' })) - # self.assertEqual(self.client.events.get({ 'resource': 3214312, 'sync': 'de4774f6915eae04714ca93bb2f5ee81:3' }), res) - - def test_project_events_get_next(self): - responses.add(GET, 'http://app/events?resource=1', status=412, body=json.dumps({ "sync": "1" }), match_querystring=True) - responses.add(GET, 'http://app/events?resource=1&sync=1', status=200, body=json.dumps({ "data": [], "sync": "2" }), match_querystring=True) - responses.add(GET, 'http://app/events?resource=1&sync=2', status=200, body=json.dumps({ "data": [{}, {}, {}], "sync": "3" }), match_querystring=True) - - self.assertEqual(len(self.client.events.get_next({ "resource": "1" })[0]), 3) - - def test_project_events_get_next_unknown_object(self): - responses.add(GET, 'http://app/events?resource=1', status=400, body=json.dumps({ "sync": "1" }), match_querystring=True) - - self.assertRaises(asana.error.InvalidRequestError, self.client.events.get_next, ({ "resource": 1 })) - - def test_project_events_get_next_invalid_token(self): - responses.add(GET, 'http://app/events?resource=1&sync=invalid', status=412, body=json.dumps({ "sync": "1" }), match_querystring=True) - - self.assertRaises(asana.error.InvalidTokenError, self.client.events.get_next, ({ "resource": 1, "sync": "invalid" })) - - def test_project_events_get_iterator(self): - responses.add(GET, 'http://app/events?resource=1', status=412, body=json.dumps({ "sync": "1" }), match_querystring=True) - responses.add(GET, 'http://app/events?resource=1&sync=1', status=200, body=json.dumps({ "data": [], "sync": "2" }), match_querystring=True) - responses.add(GET, 'http://app/events?resource=1&sync=2', status=200, body=json.dumps({ "data": ['a', 'b'], "sync": "3" }), match_querystring=True) - responses.add(GET, 'http://app/events?resource=1&sync=3', status=200, body=json.dumps({ "data": ['c'], "sync": "4" }), match_querystring=True) - - iterator = self.client.events.get_iterator({ "resource": "1" }) - self.assertEqual(next(iterator), 'a') - self.assertEqual(next(iterator), 'b') - self.assertEqual(next(iterator), 'c') - - def test_project_events_get_iterator_unknown_object(self): - responses.add(GET, 'http://app/events?resource=1', status=400, body=json.dumps({ "sync": "1" }), match_querystring=True) - - iterator = self.client.events.get_iterator({ "resource": 1 }) - self.assertRaises(asana.error.InvalidRequestError, next, (iterator)) - - def test_project_events_get_iterator_invalid_token(self): - responses.add(GET, 'http://app/events?resource=1&sync=invalid', status=412, body=json.dumps({ "sync": "1" }), match_querystring=True) - - iterator = self.client.events.get_iterator({ "resource": 1, "sync": "invalid" }) - self.assertRaises(asana.error.InvalidTokenError, next, (iterator)) diff --git a/tests/test_client_jobs.py b/tests/test_client_jobs.py deleted file mode 100644 index bbd69588..00000000 --- a/tests/test_client_jobs.py +++ /dev/null @@ -1,13 +0,0 @@ -from .helpers import * - -class TestClientJobs(ClientTestCase): - def test_jobs_get_job(self): - res = { - "data": { - "id": 1331, - "name": "Things to Buy" - } - } - responses.add(GET, 'http://app/jobs/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.jobs.get_job('1331'), res['data']) - diff --git a/tests/test_client_organization_exports.py b/tests/test_client_organization_exports.py deleted file mode 100644 index b768c2c3..00000000 --- a/tests/test_client_organization_exports.py +++ /dev/null @@ -1,40 +0,0 @@ -import json - -import responses - -from .helpers import ClientTestCase, GET, DELETE, POST, PUT - - -class TestClientOrganizationExports(ClientTestCase): - def test_organization_exports_get_organization_export(self): - resp = { - "data": { - "id": 1234, - "created_at": '2012-02-22T02:06:58.147Z', - "download_url": - 'https://asana-export.s3.amazonaws.com/export-1.json.gz', - "state": "pending", - "organization": { - "id": 14916, "name": "My Workspace" - } - } - } - - responses.add( - GET, 'http://app/organization_exports/1234', status=200, - body=json.dumps(resp), match_querystring=True) - self.assertEqual( - self.client.organization_exports.get_organization_export('1234'), resp['data']) - - def test_organization_exports_create_organization_export(self): - resp = { - "data": { - "organization": 14916 - } - } - - responses.add( - POST, 'http://app/organization_exports', status=200, - body=json.dumps(resp), match_querystring=True) - self.assertEqual( - self.client.organization_exports.create_organization_export(), resp['data']) diff --git a/tests/test_client_portfolio_memberships.py b/tests/test_client_portfolio_memberships.py deleted file mode 100644 index 84293080..00000000 --- a/tests/test_client_portfolio_memberships.py +++ /dev/null @@ -1,34 +0,0 @@ -from .helpers import * - -class TestClientPortfolioMemberships(ClientTestCase): - def test_portfolio_memberships_get_portfolio_membership(self): - res = { - "data": { - "id": 1331, - "name": "Things to Buy" - } - } - responses.add(GET, 'http://app/portfolio_memberships/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolio_memberships.get_portfolio_membership('1331'), res['data']) - - def test_portfolio_memberships_get_portfolio_memberships_for_portfolio(self): - res = { - "data": [ - { - "id": 1331, - "name": "Things to Buy" - } - ] - } - responses.add(GET, 'http://app/portfolios/1331/portfolio_memberships', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolio_memberships.get_portfolio_memberships_for_portfolio('1331'), res['data']) - - def test_portfolio_memberships_get_portfolio_memberships(self): - res = { - "data": [ - { "id": 1331, "name": "Things to buy" }, - { "id": 14641, "name": "Cat Stuff" } - ] - } - responses.add(GET, 'http://app/portfolio_memberships', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolio_memberships.get_portfolio_memberships(), res['data']) diff --git a/tests/test_client_portfolios.py b/tests/test_client_portfolios.py deleted file mode 100644 index d9627413..00000000 --- a/tests/test_client_portfolios.py +++ /dev/null @@ -1,95 +0,0 @@ -from .helpers import * - -class TestClientPortfolios(ClientTestCase): - def test_portfolios_create_portfolio(self): - req = { - "data": { - "name": "Things to Buy", - "notes": "These are things we want to purchase.", - "workspace": 14916 - } - } - res = { - "data": { - "id": 1331, - "name": "Things to Buy", - "notes": "These are things we want to purchase." - } - } - responses.add(POST, 'http://app/portfolios', status=201, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolios.create_portfolio(req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_portfolios_get_portfolio(self): - res = { - "data": { - "id": 1331, - "name": "Things to Buy", - "notes": "These are things we want to purchase." - } - } - responses.add(GET, 'http://app/portfolios/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolios.get_portfolio('1331'), res['data']) - - def test_portfolios_update_portfolio(self): - req = { - "data": { - "notes": "These are things we NEED to purchase." - } - } - res = { - "data": { - "id": 1331, - "name": "Things to Buy", - "notes": "These are things we NEED to purchase." - } - } - responses.add(PUT, 'http://app/portfolios/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolios.update_portfolio('1331', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_portfolios_delete_portfolio(self): - res = { "data": {} } - responses.add(DELETE, 'http://app/portfolios/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolios.delete_portfolio('1331'), res['data']) - - def test_portfolios_get_portfolios(self): - res = { - "data": [ - { "id": 1331, "name": "Things to buy" }, - { "id": 14641, "name": "Cat Stuff" } - ] - } - responses.add(GET, 'http://app/portfolios', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolios.get_portfolios(), res['data']) - - def test_portfolios_add_custom_field_settings(self): - req = { - "data": { - "custom_field":124578, - "is_important": true - } - } - res = { - "data": {} - } - - responses.add(POST, 'http://app/portfolios/1331/addCustomFieldSetting', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolios.add_custom_field_setting(1331, req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - - def test_portfolios_remove_custom_field_settings(self): - req = { - "data": { - "custom_field":124578, - } - } - res = { - "data": {} - } - - responses.add(POST, 'http://app/portfolios/1331/addCustomFieldSetting', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.portfolios.add_custom_field_setting('1331', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - diff --git a/tests/test_client_projects.py b/tests/test_client_projects.py deleted file mode 100644 index 7932e688..00000000 --- a/tests/test_client_projects.py +++ /dev/null @@ -1,104 +0,0 @@ -from .helpers import * - -class TestClientProjects(ClientTestCase): - def test_projects_create_project(self): - req = { - "data": { - "name": "Things to Buy", - "notes": "These are things we want to purchase.", - "workspace": 14916 - } - } - res = { - "data": { - "id": 1331, - "name": "Things to Buy", - "notes": "These are things we want to purchase." - } - } - responses.add(POST, 'http://app/projects', status=201, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.projects.create_project(req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_projects_get_project(self): - res = { - "data": { - "id": 1331, - "name": "Things to Buy", - "notes": "These are things we want to purchase." - } - } - responses.add(GET, 'http://app/projects/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.projects.get_project('1331'), res['data']) - - def test_projects_update_project(self): - req = { - "data": { - "notes": "These are things we NEED to purchase." - } - } - res = { - "data": { - "id": 1331, - "name": "Things to Buy", - "notes": "These are things we NEED to purchase." - } - } - responses.add(PUT, 'http://app/projects/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.projects.update_project('1331', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_projects_delete_project(self): - res = { "data": {} } - responses.add(DELETE, 'http://app/projects/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.projects.delete_project('1331'), res['data']) - - def test_projects_get_projects_for_workspace(self): - res = { - "data": [ - { "id": 1331, "name": "Things to buy" }, - { "id": 14641, "name": "Cat Stuff" } - ] - } - responses.add(GET, 'http://app/workspaces/14916/projects', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.projects.get_projects_for_workspace('14916'), res['data']) - - def test_projects_get_projects(self): - res = { - "data": [ - { "id": 1331, "name": "Things to buy" }, - { "id": 14641, "name": "Cat Stuff" } - ] - } - responses.add(GET, 'http://app/projects', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.projects.get_projects(), res['data']) - - def test_projects_add_custom_field_setting_for_project(self): - req = { - "data": { - "custom_field":124578, - "is_important": true - } - } - res = { - "data": {} - } - - responses.add(POST, 'http://app/projects/1331/addCustomFieldSetting', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.projects.add_custom_field_setting_for_project('1331', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - - def test_projects_remove_custom_field_setting_for_project(self): - req = { - "data": { - "custom_field":124578, - } - } - res = { - "data": {} - } - - responses.add(POST, 'http://app/projects/1331/removeCustomFieldSetting', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.projects.remove_custom_field_setting_for_project('1331', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) diff --git a/tests/test_client_sections.py b/tests/test_client_sections.py deleted file mode 100644 index 1026cf19..00000000 --- a/tests/test_client_sections.py +++ /dev/null @@ -1,114 +0,0 @@ -import json - -import responses - -from .helpers import ClientTestCase, GET, DELETE, POST, PUT - - -class TestClientSections(ClientTestCase): - - def test_sections_create_section_for_project(self): - resp = { - "data": { - "id": 2001, - "name": "High Priority:", - "created_at": "2017-01-17T22:06:39.249Z", - "project": { - "id": 1331, - "name": "Things to buy" - } - } - } - - responses.add( - POST, 'http://app/projects/1331/sections', status=200, - body=json.dumps(resp), match_querystring=True) - self.assertEqual( - self.client.sections.create_section_for_project('1331'), resp['data']) - - def test_sections_get_sections_for_project(self): - resp = { - "data": [ - { - "id": 2001, - "name": "High Priority:" - }, - { - "id": 2002, - "name": "Low Priority:" - }, - ] - } - - responses.add( - GET, 'http://app/projects/1331/sections', status=200, - body=json.dumps(resp), match_querystring=True) - self.assertEqual( - self.client.sections.get_sections_for_project('1331'), resp['data']) - - def test_sections_get_section(self): - resp = { - "data": { - "id": 2001, - "name": "High Priority:", - "created_at": "2017-01-17T22:06:39.249Z", - "project": { - "id": 1331, - "name": "Things to buy" - } - } - } - - responses.add( - GET, 'http://app/sections/2001', status=200, - body=json.dumps(resp), match_querystring=True) - self.assertEqual( - self.client.sections.get_section('2001'), resp['data']) - - def test_sections_update_section(self): - req = { - "name": "High Priority, renamed:" - } - resp = { - "data": { - "id": 2001, - "name": "High Priority, renamed:", - "created_at": "2017-01-17T22:06:39.249Z", - "project": { - "id": 1331, - "name": "Things to buy" - } - } - } - - responses.add( - PUT, 'http://app/sections/2001', status=200, - body=json.dumps(resp), match_querystring=True) - self.assertEqual( - self.client.sections.update_section('2001', req), resp['data']) - - def test_sections_delete_section(self): - resp = { - "data": {} - } - - responses.add( - DELETE, 'http://app/sections/2001', status=200, - body=json.dumps(resp), match_querystring=True) - self.assertEqual( - self.client.sections.delete_section('2001'), resp['data']) - - def test_sections_insert_section_for_project(self): - resp = { - "data": { - "section": 2001, - "project": 1331, - "before_section": 1330 - } - } - - responses.add( - POST, 'http://app/projects/1331/sections/insert', status=200, - body=json.dumps(resp), match_querystring=True) - self.assertEqual( - self.client.sections.insert_section_for_project('1331'), resp['data']) diff --git a/tests/test_client_stories.py b/tests/test_client_stories.py deleted file mode 100644 index 8f37df53..00000000 --- a/tests/test_client_stories.py +++ /dev/null @@ -1,57 +0,0 @@ -from .helpers import * - -class TestClientStories(ClientTestCase): - - def test_stories_get_stories_for_task(self): - res = { - "data": [ - { - "created_at": "2011-12-21T23:23:01.259Z", - "created_by": { "id": 5678, "name": "Greg Sanchez" }, - "id": 2001, - "text": "added to Things To Buy", - "type": "system" - }, - { - "created_at": "2012-01-02T21:32:40.112Z", - "created_by": { "id": 1234, "name": "Tim Bizarro" }, - "id": 2002, - "text": "Again? Wow, we really go through this stuff fast.", - "type": "comment" - } - ] - } - responses.add(GET, 'http://app/tasks/1001/stories', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.stories.get_stories_for_task('1001'), res['data']) - - def test_stories_get_story(self): - res = { - "data": { - "created_at": "2012-02-22T02:06:58.147Z", - "created_by": { "id": 1123, "name": "Mittens" }, - "id": 2001, - "source": "web", - "target": { "id": 1234, "name": "Buy catnip" }, - "text": "Yes, please!", - "type": "comment" - } - } - responses.add(GET, 'http://app/stories/2001', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.stories.get_story('2001'), res['data']) - - def test_stories_create_story_for_task(self): - req = { "data": { "text": "This is a very nice comment." } } - res = { - "data": { - "created_at": "2011-12-21T23:23:01.259Z", - "created_by": { "id": 5678, "name": "Greg Sanchez" }, - "id": 2001, - "source": "api", - "target": { "id": 1001, "name": "Buy catnip" }, - "text": "This is a very nice comment.", - "type": "comment" - } - } - responses.add(POST, 'http://app/tasks/1001/stories', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.stories.create_story_for_task('1001', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) diff --git a/tests/test_client_tags.py b/tests/test_client_tags.py deleted file mode 100644 index 553fa960..00000000 --- a/tests/test_client_tags.py +++ /dev/null @@ -1,37 +0,0 @@ -from .helpers import * - -class TestClientTags(ClientTestCase): - def test_tags_create_tag(self): - req = { "data": { "name": "fluffy", "workspace": 14916 } } - res = { "data": { "id": 1771, "name": "fluffy" } } - responses.add(POST, 'http://app/tags', status=201, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tags.create_tag(req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tags_get_tag(self): - res = { - "data": { - "id": 1331, - "name": "Things to Buy", - "notes": "These are things we want to purchase." - } - } - responses.add(GET, 'http://app/tags/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tags.get_tag('1331'), res['data']) - - def test_tags_update_tag(self): - req = { "data": { "name": "Things to Sell" } } - res = { "data": { "id": 1331, "name": "Things to Sell" } } - responses.add(PUT, 'http://app/tags/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tags.update_tag('1331', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tags_get_tags_for_workspace(self): - res = { - "data": [ - { "id": 1331, "name": "Things to buy" }, - { "id": 14641, "name": "Cat Stuff" } - ] - } - responses.add(GET, 'http://app/workspaces/14916/tags', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tags.get_tags_for_workspace('14916'), res['data']) diff --git a/tests/test_client_tasks.py b/tests/test_client_tasks.py deleted file mode 100644 index 343b5653..00000000 --- a/tests/test_client_tasks.py +++ /dev/null @@ -1,239 +0,0 @@ -from .helpers import * - -class TestClientTasks(ClientTestCase): - - def test_tasks_create_task(self): - req = { - "data": { - "assignee": 1235, - "followers": [5678], - "name": "Hello, world.", - "notes": "How are you today?", - "workspace": 14916 - } - } - res = { - "data": { - "assignee": { "id": 1235, "name": "Tim Bizarro" }, - "assignee_status": "inbox", - "completed": false, - "completed_at": null, - "created_at": "2012-02-22T02:06:58.158Z", - "due_on": null, - "followers": [{ "id": 5678, "name": "Greg Sanchez" } ], - "id": 1001, - "modified_at": "2012-02-22T02:06:58.158Z", - "name": "Hello, world!", - "notes": "How are you today?", - "parent": null, - "projects": [{ "id": 14641, "name": "Cat Stuff" }], - "workspace": { "id": 14916, "name": "My Favorite Workspace" } - } - } - responses.add(POST, 'http://app/tasks', status=201, body=json.dumps(res), match_querystring=True) - - self.assertEqual(self.client.tasks.create_task(req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_get_task(self): - res = { - "data": { - "assignee": { "id": 1234, "name": "Tim Bizarro" }, - "created_at": "2012-02-22T02:06:58.158Z" - } - } - responses.add(GET, 'http://app/tasks/1001', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.get_task('1001'), res['data']) - - def test_tasks_get_tasks_for_project(self): - res = { - "data": [ - { "id": 2001, "name": "Catnip" }, - { "id": 2002, "name": "Kitty litter" } - ] - } - responses.add(GET, 'http://app/projects/1331/tasks', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.get_tasks_for_project('1331'), res['data']) - - def test_tasks_update_task(self): - req = { "data": { "assignee": "me" } } - res = { - "data": { - "assignee": { "id": 1234, "name": "Tim Bizarro" }, - "id": 1001 - } - } - responses.add(PUT, 'http://app/tasks/1001', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.update_task('1001', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_delete_task(self): - res = { "data": {} } - responses.add(DELETE, 'http://app/tasks/1001', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.delete_task('1001'), res['data']) - - def test_tasks_get_tasks(self): - res = { - "data": [ - { "id": 1248, "name": "Buy catnip" }, - { "id": 24816, "name": "Reflect on role of kittens in society" } - ] - } - responses.add(GET, 'http://app/tasks?workspace=14916&assignee=me', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.get_tasks({ 'workspace': 14916, 'assignee': 'me' }), res['data']) - - def test_tasks_add_subtask(self): - req = { - "data": { - "assignee": 1235, - "followers": [5678], - "name": "Tell Luke", - "notes": "He's going to be upset." - } - } - res = { - "data": { - "assignee": { "id": 1235, "name": "Darth Vader" }, - "assignee_status": "inbox", - "completed": false, - "completed_at": null, - "created_at": "2012-02-22T02:06:58.158Z", - "due_on": null, - "followers": [{ "id": 5678, "name": "Emperor Palpatine" } ], - "id": 1001, - "modified_at": "2012-02-22T02:06:58.158Z", - "name": "Tell Luke", - "notes": "He's going to be upset.", - "parent": { "id": 2272, "name": "Tell kids I am their father." }, - "projects": [], - "workspace": { "id": 14916, "name": "Star Wars" } - } - } - responses.add(POST, 'http://app/tasks/2272/subtasks', status=201, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.add_subtask('2272', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_subtasks(self): - res = { - "data": [ - { "id": 5005, "name": "Steal Underwear" }, - { "id": 6709, "name": "???" }, - { "id": 9812, "name": "Profit" } - ] - } - responses.add(GET, 'http://app/tasks/7331/subtasks', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.subtasks(7331), res['data']) - - def test_tasks_set_parent(self): - req = { "data": { "parent": 1331 } } - res = { - "data": { - "id": 2272, - "name": "Tell Luke", - "parent": [{ "id": 1331, "name": "Tell kids I am their father" }] - } - } - responses.add(POST, 'http://app/tasks/2272/setParent', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.set_parent('2272', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_projects(self): - res = { - "data": [ - { "id": 1331, "name": "Things To Buy" }, - { "id": 14641, "name": "Cat Stuff" } - ] - } - responses.add(GET, 'http://app/tasks/1001/projects', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.projects('1001'), res['data']) - - def test_tasks_add_project(self): - req = { "data": { "project": 14641 } } - res = { "data": {} } - responses.add(POST, 'http://app/tasks/1001/addProject', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.add_project('1001', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_remove_project(self): - req = { "data": { "project": 14641 } } - res = { "data": {} } - responses.add(POST, 'http://app/tasks/1001/removeProject', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.remove_project('1001', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_tags(self): - res = { - "data": [ - { "id": 1331, "name": "orange" }, - { "id": 1771, "name": "fluffy" } - ] - } - responses.add(GET, 'http://app/tasks/1001/tags', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.tags('1001'), res['data']) - - def test_tasks_1001_addTag(self): - req = { "data": { "tag": 1771 } } - res = { "data": {} } - responses.add(POST, 'http://app/tasks/1001/addTag', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.add_tag('1001', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_removeTag(self): - req = { "data": { "tag": 1771 } } - res = { "data": {} } - responses.add(POST, 'http://app/tasks/1001/removeTag', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.remove_tag('1001', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_add_followers(self): - req = { "data": { "followers": [1235] } } - res = { - "data": { - "followers": [{ "id": 1235, "name": "Darth Vader" }], - "id": 1001 - } - } - responses.add(POST, 'http://app/tasks/1001/addFollowers', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.add_followers('1001', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_remove_followers(self): - req = { "data": { "followers": [1235] } } - res = { "data": { "followers": [], "id": 1001 } } - responses.add(POST, 'http://app/tasks/1001/removeFollowers', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.remove_followers('1001', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) - - def test_tasks_get_tasks_for_tag(self): - res = { - "data": [ - { "id": 2001, "name": "Catnip" }, - { "id": 2002, "name": "Kitty litter" } - ] - } - responses.add(GET, 'http://app/tags/1331/tasks', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.get_tasks_for_tag('1331'), res['data']) - - def test_tasks_custom_field_data(self): - res = { - "data": { - "id": 1001, - "name": "Hello, world!", - "completed": false, - "custom_fields": [ - { - "id": 124578, - "name": "Priority", - "type": "enum", - "enum_value": { - "id": 789, - "name": "Low", - "enabled": true, - "color": "blue" - } - } - ] - } - } - responses.add(GET, 'http://app/tasks/1001', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.get_task('1001'), res['data']) diff --git a/tests/test_client_teams.py b/tests/test_client_teams.py deleted file mode 100644 index 7a6a2e0c..00000000 --- a/tests/test_client_teams.py +++ /dev/null @@ -1,13 +0,0 @@ -from .helpers import * - -class TestClientTeams(ClientTestCase): - - def test_teams_get_teams_for_workspace(self): - res = { - "data": [ - { "id": 5832, "name": "Atlanta Braves" }, - { "id": 15923, "name": "New York Yankees" } - ] - } - responses.add(GET, 'http://app/workspaces/13523/teams', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.teams.get_teams_for_workspace('13523'), res['data']) diff --git a/tests/test_client_user_task_lists.py b/tests/test_client_user_task_lists.py deleted file mode 100644 index 1576122d..00000000 --- a/tests/test_client_user_task_lists.py +++ /dev/null @@ -1,33 +0,0 @@ -from .helpers import * - -class TestClientUserTaskLists(ClientTestCase): - def test_user_task_lists_get_user_task_list(self): - res = { - "data": { - "id": 1331, - "name": "Things to Buy" - } - } - responses.add(GET, 'http://app/user_task_lists/1331', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.user_task_lists.get_user_task_list('1331'), res['data']) - - def test_user_task_lists_get_user_task_list_for_user(self): - res = { - "data": { - "id": 1331, - "name": "Things to Buy" - } - } - responses.add(GET, 'http://app/users/1331/user_task_list', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.user_task_lists.get_user_task_list_for_user('1331'), res['data']) - - def test_task_get_tasks_for_user_task_list(self): - res = { - "data": [ - { "id": 1331, "name": "Things to buy" }, - { "id": 14641, "name": "Cat Stuff" } - ] - } - responses.add(GET, 'http://app/user_task_lists/1335/tasks', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.tasks.get_tasks_for_user_task_list('1335'), res['data']) - diff --git a/tests/test_client_users.py b/tests/test_client_users.py deleted file mode 100644 index f905256b..00000000 --- a/tests/test_client_users.py +++ /dev/null @@ -1,42 +0,0 @@ -from .helpers import * - -class TestClientUsers(ClientTestCase): - - def test_users_me(self): - res = { - "data": { "email":"sanchez@...", "id": 999, "name":"Greg Sanchez" } - } - responses.add(GET, 'http://app/users/me', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.users.get_user('me'), res['data']) - - def test_users_get_user(self): - res = { - "data": { - "email": "gsanchez@example.com", - "id": 5678, - "name": "Greg Sanchez", - "workspaces": [{ "id": 1337, "name": "My Favorite Workspace" }] - } - } - responses.add(GET, 'http://app/users/5678', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.users.get_user('5678'), res['data']) - - def test_users_get_users(self): - res = { - "data": [ - { "email": "tbizarro@example.com", "id": 1234, "name": "Tim Bizarro" }, - { "email": "gsanchez@example.com", "id": 5678, "name": "Greg Sanchez" } - ] - } - # responses.add(GET, 'http://app/users?opt_fields=name,email', status=200, body=json.dumps(res), match_querystring=True) - responses.add(GET, 'http://app/users', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.users.get_users(), res['data']) - - def test_users_get_users_for_workspace(self): - res = { - "data": [ - { "id": 5678, "name": "Greg Sanchez" } - ] - } - responses.add(GET, 'http://app/workspaces/1337/users', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.users.get_users_for_workspace('1337'), res['data']) diff --git a/tests/test_client_webhooks.py b/tests/test_client_webhooks.py deleted file mode 100644 index 9efd5556..00000000 --- a/tests/test_client_webhooks.py +++ /dev/null @@ -1,38 +0,0 @@ -from .helpers import * - - -class TestClientWebhooks(ClientTestCase): - - def setUp(self): - ClientTestCase.setUp(self) - self.webhook_data = { - "id": 222, - "resource": { - "id": 111, - "name": "the resource" - }, - "target": "https://foo/123", - "active": true - } - - def test_webhooks_create_webhook(self): - req = { "resource": 111, "target": "https://foo/123" } - res = { "data": self.webhook_data } - responses.add(POST, 'http://app/webhooks', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.webhooks.create_webhook(req), self.webhook_data) - - def test_webhooks_get_webhooks(self): - req = { "workspace": 1337 } - res = { "data": [self.webhook_data] } - responses.add(GET, 'http://app/webhooks?workspace=1337', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.webhooks.get_webhooks(req), [self.webhook_data]) - - def test_webhooks_get_webhook(self): - res = { "data": self.webhook_data } - responses.add(GET, 'http://app/webhooks/222', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.webhooks.get_webhook('222'), self.webhook_data) - - def test_webhooks_delete_webhook(self): - res = { "data": {} } - responses.add(DELETE, 'http://app/webhooks/222', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.webhooks.delete_webhook('222'), {}) diff --git a/tests/test_client_workspaces.py b/tests/test_client_workspaces.py deleted file mode 100644 index 6226a242..00000000 --- a/tests/test_client_workspaces.py +++ /dev/null @@ -1,20 +0,0 @@ -from .helpers import * - -class TestClientWorkspaces(ClientTestCase): - - def test_workspaces_get_workspaces(self): - res = { "data": [{ "id": 1337, "name": "My Favorite Workspace" }]} - responses.add(GET, 'http://app/workspaces', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.workspaces.get_workspaces(), res['data']) - - def test_workspaces_get_workspace(self): - res = { "data": [{ "id": 1337, "name": "My Favorite Workspace" }]} - responses.add(GET, 'http://app/workspaces/222', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.workspaces.get_workspace('222'), res['data']) - - def test_workspaces_update_workspace(self): - req = { "data": { "name": "Everyone's Favorite Workspace" } } - res = { "data": { "id": 1337, "name": "Everyone's Favorite Workspace" } } - responses.add(PUT, 'http://app/workspaces/1337', status=200, body=json.dumps(res), match_querystring=True) - self.assertEqual(self.client.workspaces.update_workspace('1337', req['data']), res['data']) - self.assertEqual(json.loads(responses.calls[0].request.body), req) diff --git a/tests/test_errors.py b/tests/test_errors.py deleted file mode 100644 index 162ce08d..00000000 --- a/tests/test_errors.py +++ /dev/null @@ -1,24 +0,0 @@ -import json - -import responses - -from .helpers import asana, ClientTestCase - - -class TestErrors(ClientTestCase): - def test_premium_only_402(self): - resp_json = { - "errors": [ - { - "message": ( - "Custom Fields are not available for free " - "users or guests.") - } - ] - } - responses.add( - responses.GET, - 'http://app/workspaces/12345/custom_fields', status=402, - body=json.dumps(resp_json), match_querystring=True) - with self.assertRaises(asana.error.PremiumOnlyError): - self.client.custom_fields.get_custom_fields_for_workspace('12345')