├── .env.example ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── black.yml │ ├── codeql.yaml │ ├── copy_right_headers_check.yml │ ├── pylint.yml │ └── pytest.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── PRIVACY.txt ├── README.md ├── SECURITY.md ├── SUPPORT.md ├── azure-pipelines.yml ├── example.py ├── requirements.txt ├── samples ├── __init__.py ├── rest │ ├── __init__.py │ ├── bing_auto_suggest_v7.py │ ├── bing_custom_search_v7.py │ ├── bing_entity_search_v7.py │ ├── bing_image_search_v7.py │ ├── bing_news_search_v7.py │ ├── bing_spell_check_v7.py │ ├── bing_video_search_v7.py │ ├── bing_visual_search_v7.py │ └── bing_web_search_v7.py └── sdk │ ├── README.md │ ├── TestImages │ └── image.jpg │ ├── autosuggest_samples.py │ ├── custom_image_search_samples.py │ ├── custom_search_samples.py │ ├── entity_search_samples.py │ ├── image-search-quickstart.py │ ├── image_search_samples.py │ ├── news_search_samples.py │ ├── spellcheck_samples.py │ ├── video_search_samples.py │ ├── visual_search_samples.py │ └── web_search_samples.py ├── sdk ├── Autosuggest │ ├── LICENSE.txt │ ├── README.md │ ├── autosuggest_client │ │ ├── __init__.py │ │ ├── _auto_suggest_client.py │ │ ├── _configuration.py │ │ ├── aio │ │ │ ├── __init__.py │ │ │ ├── _auto_suggest_client.py │ │ │ ├── _configuration.py │ │ │ └── operations │ │ │ │ ├── __init__.py │ │ │ │ └── _auto_suggest_client_operations.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── _auto_suggest_client_enums.py │ │ │ └── _models.py │ │ └── operations │ │ │ ├── __init__.py │ │ │ └── _auto_suggest_client_operations.py │ ├── pyproject.toml │ ├── setup.cfg │ └── setup.py ├── CustomImageSearch │ ├── LICENSE.txt │ ├── README.md │ ├── custom_image_search_client │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _custom_image_search_client.py │ │ ├── aio │ │ │ ├── __init__.py │ │ │ ├── _configuration.py │ │ │ ├── _custom_image_search_client.py │ │ │ └── operations │ │ │ │ ├── __init__.py │ │ │ │ └── _custom_instance_operations.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── _custom_image_search_client_enums.py │ │ │ ├── _models.py │ │ │ └── _models_py3.py │ │ ├── operations │ │ │ ├── __init__.py │ │ │ └── _custom_instance_operations.py │ │ └── py.typed │ ├── pyproject.toml │ ├── setup.cfg │ └── setup.py ├── CustomWebSearch │ ├── LICENSE.txt │ ├── README.md │ ├── custom_search_client │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _custom_search_client.py │ │ ├── aio │ │ │ ├── __init__.py │ │ │ ├── _configuration.py │ │ │ ├── _custom_search_client.py │ │ │ └── operations │ │ │ │ ├── __init__.py │ │ │ │ └── _custom_instance_operations.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── _custom_search_client_enums.py │ │ │ ├── _models.py │ │ │ └── _models_py3.py │ │ ├── operations │ │ │ ├── __init__.py │ │ │ └── _custom_instance_operations.py │ │ └── py.typed │ ├── pyproject.toml │ ├── setup.cfg │ └── setup.py ├── EntitySearch │ ├── LICENSE.txt │ ├── README.md │ ├── entity_search_client │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _entity_search_client.py │ │ ├── aio │ │ │ ├── __init__.py │ │ │ ├── _configuration.py │ │ │ ├── _entity_search_client.py │ │ │ └── operations │ │ │ │ ├── __init__.py │ │ │ │ └── _entities_operations.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── _entity_search_client_enums.py │ │ │ ├── _models.py │ │ │ └── _models_py3.py │ │ ├── operations │ │ │ ├── __init__.py │ │ │ └── _entities_operations.py │ │ └── py.typed │ ├── pyproject.toml │ ├── setup.cfg │ └── setup.py ├── ImageSearch │ ├── LICENSE.txt │ ├── README.md │ ├── image_search_client │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _image_search_client.py │ │ ├── aio │ │ │ ├── __init__.py │ │ │ ├── _configuration.py │ │ │ ├── _image_search_client.py │ │ │ └── operations │ │ │ │ ├── __init__.py │ │ │ │ └── _images_operations.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── _image_search_client_enums.py │ │ │ ├── _models.py │ │ │ └── _models_py3.py │ │ ├── operations │ │ │ ├── __init__.py │ │ │ └── _images_operations.py │ │ └── py.typed │ ├── pyproject.toml │ ├── setup.cfg │ └── setup.py ├── NewsSearch │ ├── LICENSE.txt │ ├── README.md │ ├── news_search_client │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _news_search_client.py │ │ ├── aio │ │ │ ├── __init__.py │ │ │ ├── _configuration.py │ │ │ ├── _news_search_client.py │ │ │ └── operations │ │ │ │ ├── __init__.py │ │ │ │ └── _news_operations.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── _models.py │ │ │ ├── _models_py3.py │ │ │ └── _news_search_client_enums.py │ │ ├── operations │ │ │ ├── __init__.py │ │ │ └── _news_operations.py │ │ └── py.typed │ ├── pyproject.toml │ ├── setup.cfg │ └── setup.py ├── SpellCheck │ ├── LICENSE.txt │ ├── README.md │ ├── pyproject.toml │ ├── setup.cfg │ ├── setup.py │ └── spell_check_client │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _spell_check_client.py │ │ ├── aio │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _spell_check_client.py │ │ └── operations │ │ │ ├── __init__.py │ │ │ └── _spell_check_client_operations.py │ │ ├── models │ │ ├── __init__.py │ │ ├── _models.py │ │ ├── _models_py3.py │ │ └── _spell_check_client_enums.py │ │ ├── operations │ │ ├── __init__.py │ │ └── _spell_check_client_operations.py │ │ └── py.typed ├── VideoSearch │ ├── LICENSE.txt │ ├── README.md │ ├── pyproject.toml │ ├── setup.cfg │ ├── setup.py │ └── video_search_client │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _video_search_client.py │ │ ├── aio │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _video_search_client.py │ │ └── operations │ │ │ ├── __init__.py │ │ │ └── _videos_operations.py │ │ ├── models │ │ ├── __init__.py │ │ ├── _models.py │ │ ├── _models_py3.py │ │ └── _video_search_client_enums.py │ │ ├── operations │ │ ├── __init__.py │ │ └── _videos_operations.py │ │ └── py.typed ├── VisualSearch │ ├── LICENSE.txt │ ├── README.md │ ├── pyproject.toml │ ├── setup.cfg │ ├── setup.py │ └── visual_search_client │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _visual_search_client.py │ │ ├── aio │ │ ├── __init__.py │ │ ├── _configuration.py │ │ ├── _visual_search_client.py │ │ └── operations │ │ │ ├── __init__.py │ │ │ └── _images_operations.py │ │ ├── models │ │ ├── __init__.py │ │ ├── _models.py │ │ ├── _models_py3.py │ │ └── _visual_search_client_enums.py │ │ ├── operations │ │ ├── __init__.py │ │ └── _images_operations.py │ │ └── py.typed └── WebSearch │ ├── LICENSE.txt │ ├── README.md │ ├── pyproject.toml │ ├── setup.cfg │ ├── setup.py │ └── web_search_client │ ├── __init__.py │ ├── _configuration.py │ ├── _web_search_client.py │ ├── aio │ ├── __init__.py │ ├── _configuration.py │ ├── _web_search_client.py │ └── operations │ │ ├── __init__.py │ │ └── _web_operations.py │ ├── models │ ├── __init__.py │ ├── _models.py │ ├── _models_py3.py │ └── _web_search_client_enums.py │ ├── operations │ ├── __init__.py │ └── _web_operations.py │ └── py.typed ├── tests ├── README.md ├── rest │ ├── __init__.py │ ├── test_samples_auto_suggest.py │ ├── test_samples_custom_search.py │ ├── test_samples_entity_search.py │ ├── test_samples_image_search.py │ ├── test_samples_news_search.py │ ├── test_samples_spell_check.py │ ├── test_samples_video_search.py │ ├── test_samples_visual_search.py │ └── test_samples_web_search.py ├── test-requirements.txt ├── test_example.py └── testsettings.cfg └── tools.py /.env.example: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Subscription Keys 5 | BING_SEARCH_V7_WEB_SEARCH_SUBSCRIPTION_KEY= 6 | BING_SEARCH_V7_NEWS_SEARCH_SUBSCRIPTION_KEY= 7 | BING_SEARCH_V7_IMAGE_SEARCH_SUBSCRIPTION_KEY= 8 | BING_SEARCH_V7_VIDEO_SEARCH_SUBSCRIPTION_KEY= 9 | BING_SEARCH_V7_ENTITY_SEARCH_SUBSCRIPTION_KEY= 10 | BING_SEARCH_V7_VISUAL_SEARCH_SUBSCRIPTION_KEY= 11 | BING_SEARCH_V7_SPELL_CHECK_SUBSCRIPTION_KEY= 12 | BING_SEARCH_V7_AUTO_SUGGEST_SUBSCRIPTION_KEY= 13 | BING_SEARCH_V7_CUSTOM_SEARCH_SUBSCRIPTION_KEY= 14 | 15 | # Optional 16 | BING_CUSTOM_SEARCH_CONFIG= 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 3 | 6 | # Please provide us with the following information 7 | 8 | 9 | 10 | ## Please search issues before submitting 11 | 12 | - [ ] I've searched existing issues for solutions to my situation. 13 | 14 | ## Meta 15 | 16 | ### This issue is about 17 | 18 | 19 | - [ ] bug report 20 | - [x] feature request 21 | - [ ] documentation issue or request 22 | - [ ] regression (a behavior that used to work and stopped in a new release) 23 | 24 | ### Related Issues 25 | 26 | 27 | 28 | 29 | ## Use Case 30 | 31 | ### Motiviation 32 | 33 | 34 | 35 | ### Minimal steps to reproduce 36 | 37 | 38 | 39 | ### Any log messages given by the failure 40 | 41 | ### Expected/desired behavior 42 | 43 | ### Actual behavior 44 | 45 | ## Environment 46 | 47 | ### OS and Version 48 | 49 | 50 | 51 | ### Related Software 52 | 53 | 54 | 55 | 56 | ### Mention any other details that might be useful 57 | 58 | ## Mitigation 59 | 60 | ### Fix it yourself? 61 | 62 | - [ ] Tick this box if you'd like to work on this. 63 | 64 | ### Suggestions and Ideas 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 3 | 6 | # Purpose 7 | 8 | 9 | 10 | ## Problem / Scope 11 | 12 | ## Solution / Functionality 13 | 14 | ## Does this introduce a breaking change? 15 | 16 | 17 | - [x] Yes 18 | - [ ] No 19 | 20 | ## Pull Request Type 21 | 22 | What kind of change does this Pull Request introduce? 23 | 24 | 25 | - [x] Bugfix 26 | - [ ] Feature 27 | - [ ] Code style update (formatting, local variables) 28 | - [ ] Refactoring (no functional changes, no api changes) 29 | - [ ] Documentation content changes 30 | - [ ] Other... Please describe: 31 | 32 | ## Changes 33 | 34 | ### Affected Scenarios 35 | 36 | 37 | 38 | 39 | 40 | ### Tests 41 | 42 | Did you include tests? 43 | 44 | - [ ] Yes 45 | - [X] No 46 | 47 | #### Steps to run included tests 48 | 49 | 50 | 51 | ## linked issues 52 | 53 | 54 | ## Other Information 55 | 56 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | version: 2 5 | updates: 6 | - package-ecosystem: "pip" 7 | directories: 8 | - "/" 9 | - "/tests" 10 | - "/sdk/Autosuggest" 11 | - "/sdk/CustomImageSearch" 12 | - "/sdk/CustomWebSearch" 13 | - "/sdk/EntitySearch" 14 | - "/sdk/ImageSearch" 15 | - "/sdk/NewsSearch" 16 | - "/sdk/SpellCheck" 17 | - "/sdk/VideoSearch" 18 | - "/sdk/VisualSearch" 19 | - "/sdk/WebSearch" 20 | schedule: 21 | interval: "monthly" 22 | 23 | - package-ecosystem: "github-actions" 24 | directories: 25 | - "/.github/workflows" 26 | schedule: 27 | interval: "monthly" 28 | -------------------------------------------------------------------------------- /.github/workflows/black.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | name: Black 5 | permissions: 6 | pull-requests: read 7 | 8 | 9 | on: 10 | push: 11 | branches: 12 | - main 13 | pull_request: 14 | branches: 15 | - main 16 | 17 | jobs: 18 | format: 19 | runs-on: ubuntu-latest 20 | strategy: 21 | matrix: 22 | python-version: ["3.11"] 23 | steps: 24 | - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 25 | 26 | - name: Set up Python ${{ matrix.python-version }} 27 | uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 28 | with: 29 | python-version: ${{ matrix.python-version }} 30 | 31 | - name: Install dependencies 32 | run: | 33 | python -m pip install --upgrade pip 34 | pip install black 35 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 36 | echo "PYTHONPATH=." >> "$GITHUB_ENV" 37 | 38 | - name: Checking the code for formatting issues 39 | run: | 40 | black --check --verbose $(git ls-files '*.py') 41 | 42 | -------------------------------------------------------------------------------- /.github/workflows/pylint.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | name: Pylint 5 | permissions: 6 | pull-requests: read 7 | 8 | on: 9 | push: 10 | branches: 11 | - main 12 | pull_request: 13 | branches: 14 | - main 15 | 16 | jobs: 17 | lint: 18 | runs-on: ubuntu-latest 19 | strategy: 20 | matrix: 21 | python-version: ["3.11"] 22 | steps: 23 | - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 24 | 25 | - name: Set up Python ${{ matrix.python-version }} 26 | uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 27 | with: 28 | python-version: ${{ matrix.python-version }} 29 | 30 | - name: Install dependencies 31 | run: | 32 | python -m pip install --upgrade pip 33 | pip install pylint 34 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 35 | echo "PYTHONPATH=." >> "$GITHUB_ENV" 36 | 37 | - name: Analysing rest samples test code with pylint 38 | run: | 39 | if ! pylint $(git ls-files './tests/rest/test_*.py') --fail-under 8; then 40 | echo "::warning title=linter::pylint found issues in files under ./tests/rest/test_*.py" 41 | fi 42 | 43 | - name: Analysing rest samples code with pylint 44 | # Sample files are intended as quickstarts for clients 45 | # That's why they are self-contained 46 | # I.e., they don't import code from other files 47 | # I.e., they must have duplicate parts! 48 | # So, ignoring the warning using (--disable duplicate-code) 49 | run: | 50 | pylint --disable duplicate-code $(git ls-files './samples/rest/bing*.py') 51 | 52 | -------------------------------------------------------------------------------- /.github/workflows/pytest.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | name: Pytest 5 | permissions: 6 | pull-requests: read 7 | 8 | on: 9 | push: 10 | branches: 11 | - main 12 | pull_request: 13 | branches: 14 | - main 15 | 16 | jobs: 17 | test: 18 | runs-on: ubuntu-latest 19 | strategy: 20 | matrix: 21 | python-version: ["3.11"] 22 | steps: 23 | - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 24 | 25 | - name: Set up Python ${{ matrix.python-version }} 26 | uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 27 | with: 28 | python-version: ${{ matrix.python-version }} 29 | 30 | - name: Install dependencies 31 | run: | 32 | python -m pip install --upgrade pip 33 | python -m pip install pytest pytest-retry 34 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 35 | echo "PYTHONPATH=." >> "$GITHUB_ENV" 36 | 37 | - name: Running tests for the rest code samples 38 | env: 39 | BING_SEARCH_V7_WEB_SEARCH_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_WEB_SEARCH_SUBSCRIPTION_KEY }} 40 | BING_SEARCH_V7_NEWS_SEARCH_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_NEWS_SEARCH_SUBSCRIPTION_KEY }} 41 | BING_SEARCH_V7_IMAGE_SEARCH_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_IMAGE_SEARCH_SUBSCRIPTION_KEY }} 42 | BING_SEARCH_V7_VIDEO_SEARCH_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_VIDEO_SEARCH_SUBSCRIPTION_KEY }} 43 | BING_SEARCH_V7_ENTITY_SEARCH_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_ENTITY_SEARCH_SUBSCRIPTION_KEY }} 44 | BING_SEARCH_V7_VISUAL_SEARCH_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_VISUAL_SEARCH_SUBSCRIPTION_KEY }} 45 | BING_SEARCH_V7_SPELL_CHECK_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_SPELL_CHECK_SUBSCRIPTION_KEY }} 46 | BING_SEARCH_V7_AUTO_SUGGEST_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_AUTO_SUGGEST_SUBSCRIPTION_KEY }} 47 | BING_SEARCH_V7_CUSTOM_SEARCH_SUBSCRIPTION_KEY: ${{ secrets.BING_SEARCH_V7_CUSTOM_SEARCH_SUBSCRIPTION_KEY }} 48 | BING_CUSTOM_SEARCH_CONFIG: ${{ secrets.BING_CUSTOM_SEARCH_CONFIG }} 49 | run: | 50 | python -m pytest --cumulative-timing 1 -v ./tests/rest/ 51 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 3 | # Microsoft Open Source Code of Conduct 4 | 5 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 6 | 7 | Resources: 8 | 9 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 10 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 11 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 12 | - Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support) 13 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 3 | # Contributing to [bing-search-sdk-for-python] 4 | 5 | This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [Contributor License Agreements](https://cla.opensource.microsoft.com). 6 | 7 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. 8 | 9 | - [Code of Conduct](#code-of-conduct) 10 | - [Found an Issue?](#found-an-issue) 11 | - [Want a Feature?](#want-a-feature) 12 | - [Submission Guidelines](#submission-guidelines) 13 | - [Submitting an Issue](#submitting-an-issue) 14 | - [Submitting a Pull Request (PR)](#submitting-a-pull-request-pr) 15 | 16 | ## Code of Conduct 17 | 18 | Help us keep this project open and inclusive. Please read and follow our [Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 19 | 20 | ## Found an Issue? 21 | 22 | If you find a bug in the source code or a mistake in the documentation, you can help us by [submitting an issue](#submitting-an-issue) or even better by [submitting a pull request (PR)](#submitting-a-pull-request-pr) with a fix. 23 | 24 | ## Want a Feature? 25 | 26 | You can *request* a new feature by [submitting an Issue](#submitting-an-issue) to the GitHub Repository. If you would like to *implement* a new feature, please submit an issue with a proposal for your work first, to be sure that we can use it. 27 | 28 | - **Small Features** can be crafted and directly [submitted as a Pull Request (PR)](#submitting-a-pull-request-pr) 29 | 30 | ## Submission Guidelines 31 | 32 | ### Submitting an Issue 33 | 34 | Click [here](https://github.com/microsoft/bing-search-sdk-for-python/issues/new/choose) and fill the template, if the template is not there, use this [file](.github/ISSUE_TEMPLATE.md) 35 | 36 | ### Submitting a Pull Request (PR) 37 | 38 | > Before you implement your idea, search the repository's [pull requests](https://github.com/microsoft/bing-search-sdk-for-python/pulls) for an open or closed PR that relates to your submission. 39 | 40 | 1. Fork the repo 41 | 42 | 2. Implement the changes in the forked version 43 | - Use descriptive commit messages 44 | - Follow the structure and code style of the repo 45 | 46 | 3. Create a pull request using this [template](.github/PULL_REQUEST_TEMPLATE.md) 47 | 48 | 4. Wait for a review and implement/discuss suggestions 49 | 50 | 5. Thanks for your contribution! 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /PRIVACY.txt: -------------------------------------------------------------------------------- 1 | Data Collection. The software may collect information about you and your use of the software and send it to Microsoft. 2 | Microsoft may use this information to provide services and improve our products and services. 3 | You may turn off the telemetry as described in the repository. There are also some features in the software that may enable 4 | you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, 5 | including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. 6 | Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection 7 | and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices. -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | ## Security 6 | 7 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). 8 | 9 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. 10 | 11 | ## Reporting Security Issues 12 | 13 | **Please do not report security vulnerabilities through public GitHub issues.** 14 | 15 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). 16 | 17 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). 18 | 19 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 20 | 21 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 22 | 23 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 24 | * Full paths of source file(s) related to the manifestation of the issue 25 | * The location of the affected source code (tag/branch/commit or direct URL) 26 | * Any special configuration required to reproduce the issue 27 | * Step-by-step instructions to reproduce the issue 28 | * Proof-of-concept or exploit code (if possible) 29 | * Impact of the issue, including how an attacker might exploit the issue 30 | 31 | This information will help us triage your report more quickly. 32 | 33 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. 34 | 35 | ## Preferred Languages 36 | 37 | We prefer all communications to be in English. 38 | 39 | ## Policy 40 | 41 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). 42 | 43 | 44 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | 3 | # Support 4 | 5 | For detailed documentation visit our [Bing APIs for documentation](https://docs.microsoft.com/en-us/bing/search-apis/) 6 | 7 | ## How to file issues and get help 8 | 9 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new Issue. 10 | 11 | For help and questions about using this project, please start an issue and unless the issue is urgent, kindly wait at two business days before tagging people. Please don't disclose any information about security/privacy, if you spot any secruity flaws or bugs, follow the instructions in [SECURITY.md](SECURITY.md). 12 | 13 | ## Microsoft Support Policy 14 | 15 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above. 16 | 17 | ### Looking for support for a Microsoft product or service? 18 | 19 | Consider some of these resources: 20 | 21 | - Support resources at [Microsoft Support](https://support.microsoft.com). 22 | - Microsoft documentation, samples and more at [Microsoft Learn](https://learn.microsoft.com). 23 | 24 | Online forums are also often very helpful. 25 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Starter pipeline 5 | # Start with a minimal pipeline that you can customize to build and deploy your code. 6 | # Add steps that build, run tests, deploy, and more: 7 | # https://aka.ms/yaml 8 | 9 | trigger: 10 | - main 11 | 12 | jobs: 13 | - job: 'search' 14 | 15 | pool: 16 | vmImage: 'windows-2019' 17 | 18 | strategy: 19 | matrix: 20 | Python35: 21 | python.version: '3.5' 22 | Python36: 23 | python.version: '3.6' 24 | 25 | steps: 26 | - task: UsePythonVersion@0 27 | displayName: 'Use Python Version' 28 | inputs: 29 | versionSpec: '$(python.version)' 30 | 31 | - script: python -m pip install --upgrade pip setuptools wheel 32 | displayName: 'Install tools' 33 | workingDirectory: . 34 | 35 | - script: | 36 | pip install azure-core 37 | pip install -r requirements.txt 38 | python example.py 39 | displayName: 'run tests' 40 | workingDirectory: . 41 | -------------------------------------------------------------------------------- /example.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | """Sample launcher. 5 | 6 | This file is just the samples launcher. Nothing here os related 7 | to Bing Apis. Look into the "samples" folder for actual code 8 | """ 9 | 10 | import importlib 11 | import pkgutil 12 | 13 | # import logging 14 | # logging.basicConfig(level=logging.DEBUG) 15 | 16 | import tools 17 | import os, sys, inspect 18 | import samples.sdk 19 | 20 | 21 | def run_all_samples(): 22 | for _, section_name_name, ispkg in pkgutil.walk_packages(samples.sdk.__path__): 23 | section_package_name = "samples.sdk." + section_name_name 24 | section_package = importlib.import_module(section_package_name) 25 | sample_module = importlib.import_module(section_package_name) 26 | subkey_env_name = getattr(sample_module, "SUBSCRIPTION_KEY", None) 27 | if not subkey_env_name: 28 | continue 29 | print("Executing sample from ", section_name_name) 30 | try: 31 | tools.execute_samples(sample_module.__dict__, subkey_env_name) 32 | except tools.SubscriptionKeyError as err: 33 | print("{}\n".format(err)) 34 | 35 | 36 | if __name__ == "__main__": 37 | run_all_samples() 38 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | microsoft-bing-websearch 5 | microsoft-bing-visualsearch 6 | microsoft-bing-videosearch 7 | microsoft-bing-imagesearch 8 | microsoft-bing-newssearch 9 | microsoft-bing-spellcheck 10 | microsoft-bing-entitysearch 11 | microsoft-bing-autosuggest 12 | microsoft-bing-customimagesearch 13 | microsoft-bing-customwebsearch 14 | msrest 15 | azure-common 16 | msrestazure 17 | azure-core 18 | requests 19 | python-dotenv 20 | -------------------------------------------------------------------------------- /samples/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /samples/rest/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /samples/rest/bing_auto_suggest_v7.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Python example showcasing the usage of Bing Auto Suggest API using REST calls""" 4 | 5 | import json 6 | from pprint import pprint 7 | 8 | import dotenv 9 | import requests 10 | from requests import HTTPError 11 | 12 | 13 | def auto_suggest_basic( 14 | query, subscription_key, auth_header_name="Ocp-Apim-Subscription-Key", mkt="en-us" 15 | ): 16 | """Bing Auto Suggest Basic REST call 17 | 18 | This sample uses the Bing Autosuggest API to provide a list of suggested search query strings 19 | Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-autosuggest/overview 20 | 21 | May throw HTTPError in case of invalid parameters or a server error. 22 | 23 | Args: 24 | subscription_key (str): Azure subscription key of Bing Auto Suggest service 25 | auth_header_name (str): Name of the authorization header 26 | query (str): Query to get suggestions for 27 | mkt (str): Market to search in 28 | """ 29 | 30 | # Construct the request 31 | endpoint = "https://api.bing.microsoft.com/v7.0/suggestions" 32 | params = {"q": query, "mkt": mkt} 33 | headers = {auth_header_name: subscription_key} 34 | 35 | # Call the API 36 | try: 37 | response = requests.get(endpoint, headers=headers, params=params, timeout=10) 38 | response.raise_for_status() 39 | return response 40 | except HTTPError as ex: 41 | print(ex) 42 | print("++The above exception was thrown and handled succesfully++") 43 | return response 44 | 45 | 46 | def main() -> None: 47 | """Main Function that sends an example request and pretty prints the response""" 48 | # Load the environment variables from .env file 49 | env = dotenv.dotenv_values() 50 | 51 | # pylint: disable=invalid-name 52 | SUBSCRIPTION_KEY_ENV_VAR_NAME = "BING_SEARCH_V7_AUTO_SUGGEST_SUBSCRIPTION_KEY" 53 | 54 | # Add your Bing Auto Suggest V7 subscription key to your environment variables / .env file 55 | subscription_key = env.get(SUBSCRIPTION_KEY_ENV_VAR_NAME) 56 | if not subscription_key: 57 | raise ( 58 | RuntimeError( 59 | f"Please define the {SUBSCRIPTION_KEY_ENV_VAR_NAME} environment variable" 60 | ) 61 | ) 62 | 63 | response = auto_suggest_basic(query="sail", subscription_key=subscription_key) 64 | print("\nResponse Headers:\n") 65 | pprint(dict(response.headers)) 66 | 67 | print("\nJSON Response:\n") 68 | print(json.dumps(response.json(), indent=4)) 69 | 70 | 71 | if __name__ == "__main__": 72 | main() 73 | -------------------------------------------------------------------------------- /samples/rest/bing_custom_search_v7.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Python example showcasing the usage of Bing Custom Search API using REST calls""" 4 | 5 | import json 6 | from pprint import pprint 7 | 8 | import dotenv 9 | import requests 10 | from requests import HTTPError 11 | 12 | 13 | def custom_search_basic( 14 | query, 15 | subscription_key, 16 | custom_config_id, 17 | auth_header_name="Ocp-Apim-Subscription-Key", 18 | mkt="en-us", 19 | ): 20 | """Bing Custom Search Basic REST call 21 | 22 | This sample uses the Bing Custom Search API to search for a query topic and 23 | get back user-controlled web page results. 24 | Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/overview 25 | 26 | May throw HTTPError in case of invalid parameters or a server error. 27 | 28 | Args: 29 | subscription_key (str): Azure subscription key of Bing Custom Search service 30 | custom_config_id (str): Custom Configuation ID obtained from the portal 31 | auth_header_name (str): Name of the authorization header 32 | query (str): Query to search for 33 | mkt (str): Market to search in 34 | """ 35 | # Construct a request 36 | endpoint = "https://api.bing.microsoft.com/v7.0/custom/search" 37 | params = {"q": query, "mkt": mkt, "customconfig": custom_config_id} 38 | headers = {auth_header_name: subscription_key} 39 | 40 | # Call the API 41 | try: 42 | response = requests.get(endpoint, headers=headers, params=params, timeout=10) 43 | response.raise_for_status() 44 | return response 45 | except HTTPError as ex: 46 | print(ex) 47 | print("++The above exception was thrown and handled succesfully++") 48 | return response 49 | 50 | 51 | def main() -> None: 52 | """Main Function that sends an example request and pretty prints the response""" 53 | # Load the environment variables from .env file 54 | env = dotenv.dotenv_values() 55 | 56 | # pylint: disable=invalid-name 57 | SUBSCRIPTION_KEY_ENV_VAR_NAME = "BING_SEARCH_V7_CUSTOM_SEARCH_SUBSCRIPTION_KEY" 58 | CUSTOM_CONFIG_ID_ENV_VAR_NAME = "BING_CUSTOM_SEARCH_CONFIG" 59 | 60 | # Add your Bing Custom Search V7 subscription key and Configutation ID to 61 | # your environment variables / .env file 62 | subscription_key = env.get(SUBSCRIPTION_KEY_ENV_VAR_NAME) 63 | if not subscription_key: 64 | raise ( 65 | RuntimeError( 66 | f"Please define the {SUBSCRIPTION_KEY_ENV_VAR_NAME} environment variable" 67 | ) 68 | ) 69 | custom_config_id = env.get(CUSTOM_CONFIG_ID_ENV_VAR_NAME, "1") 70 | 71 | response = custom_search_basic("Microsoft", subscription_key, custom_config_id) 72 | print("\nResponse Headers:\n") 73 | pprint(dict(response.headers)) 74 | 75 | print("\nJSON Response:\n") 76 | print(json.dumps(response.json(), indent=4)) 77 | 78 | 79 | if __name__ == "__main__": 80 | main() 81 | -------------------------------------------------------------------------------- /samples/rest/bing_entity_search_v7.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Python example showcasing the usage of Bing Entity Search API using REST calls""" 4 | 5 | import json 6 | from pprint import pprint 7 | 8 | import dotenv 9 | import requests 10 | from requests import HTTPError 11 | 12 | 13 | def entity_search_basic( 14 | query, subscription_key, auth_header_name="Ocp-Apim-Subscription-Key", mkt="en-us" 15 | ): 16 | """Bing Entity Search Basic REST call 17 | 18 | This sample uses the Bing Entity Search API to retreive information about a well-known entity 19 | Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-entity-search/overview 20 | 21 | May throw HTTPError in case of invalid parameters or a server error. 22 | 23 | Args: 24 | subscription_key (str): Azure subscription key of Bing Entity Search service 25 | auth_header_name (str): Name of the authorization header 26 | query (str): Query to search for 27 | mkt (str): Market to search in 28 | """ 29 | # Construct the request 30 | endpoint = "https://api.bing.microsoft.com/v7.0/entities" 31 | params = {"q": query, "mkt": mkt} 32 | headers = {auth_header_name: subscription_key} 33 | 34 | # Call the API 35 | try: 36 | response = requests.get(endpoint, headers=headers, params=params, timeout=10) 37 | response.raise_for_status() 38 | return response 39 | except HTTPError as ex: 40 | print(ex) 41 | print("++The above exception was thrown and handled succesfully++") 42 | return response 43 | 44 | 45 | def main() -> None: 46 | """Main Function that sends an example request and pretty prints the response""" 47 | # Load the environment variables from .env file 48 | env = dotenv.dotenv_values() 49 | 50 | # pylint: disable=invalid-name 51 | SUBSCRIPTION_KEY_ENV_VAR_NAME = "BING_SEARCH_V7_ENTITY_SEARCH_SUBSCRIPTION_KEY" 52 | 53 | # Add your Bing Entity Search V7 subscription key to your environment variables / .env file 54 | subscription_key = env.get(SUBSCRIPTION_KEY_ENV_VAR_NAME) 55 | if not subscription_key: 56 | raise ( 57 | RuntimeError( 58 | f"Please define the {SUBSCRIPTION_KEY_ENV_VAR_NAME} environment variable" 59 | ) 60 | ) 61 | 62 | response = entity_search_basic("alija izetbegović", subscription_key) 63 | print("\nResponse Headers:\n") 64 | pprint(dict(response.headers)) 65 | 66 | print("\nJSON Response:\n") 67 | print(json.dumps(response.json(), indent=4)) 68 | 69 | 70 | if __name__ == "__main__": 71 | main() 72 | -------------------------------------------------------------------------------- /samples/rest/bing_image_search_v7.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Python example showcasing the usage of Bing Image Search API using REST calls""" 4 | 5 | import json 6 | from pprint import pprint 7 | 8 | import dotenv 9 | import requests 10 | from requests import HTTPError 11 | 12 | 13 | def image_search_basic( 14 | query, subscription_key, auth_header_name="Ocp-Apim-Subscription-Key", mkt="en-us" 15 | ): 16 | """Bing Image Search Basic REST call 17 | 18 | This sample makes a call to the Bing Image Search API with a text query and 19 | returns relevant images with data. 20 | Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-image-search/overview 21 | 22 | May throw HTTPError in case of invalid parameters or a server error. 23 | 24 | Args: 25 | subscription_key (str): Azure subscription key of Bing Image Search service 26 | auth_header_name (str): Name of the authorization header 27 | query (str): Query to search for 28 | mkt (str): Market to search in 29 | """ 30 | # Construct a request 31 | endpoint = "https://api.bing.microsoft.com/v7.0/images/search" 32 | params = {"q": query, "mkt": mkt} 33 | headers = {auth_header_name: subscription_key} 34 | 35 | # Call the API 36 | try: 37 | response = requests.get(endpoint, headers=headers, params=params, timeout=10) 38 | response.raise_for_status() 39 | return response 40 | except HTTPError as ex: 41 | print(ex) 42 | print("++The above exception was thrown and handled succesfully++") 43 | return response 44 | 45 | 46 | def main() -> None: 47 | """Main Function that sends an example request and pretty prints the response""" 48 | # Load the environment variables from .env file 49 | env = dotenv.dotenv_values() 50 | 51 | # pylint: disable=invalid-name 52 | SUBSCRIPTION_KEY_ENV_VAR_NAME = "BING_SEARCH_V7_IMAGE_SEARCH_SUBSCRIPTION_KEY" 53 | 54 | # Add your Bing Image Search V7 subscription key to your environment variables / .env file 55 | subscription_key = env.get(SUBSCRIPTION_KEY_ENV_VAR_NAME) 56 | if not subscription_key: 57 | raise ( 58 | RuntimeError( 59 | f"Please define the {SUBSCRIPTION_KEY_ENV_VAR_NAME} environment variable" 60 | ) 61 | ) 62 | 63 | response = image_search_basic("Arabian horse", subscription_key) 64 | print("\nResponse Headers:\n") 65 | pprint(dict(response.headers)) 66 | 67 | print("\nJSON Response:\n") 68 | print(json.dumps(response.json(), indent=4)) 69 | 70 | 71 | if __name__ == "__main__": 72 | main() 73 | -------------------------------------------------------------------------------- /samples/rest/bing_news_search_v7.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Python example showcasing the usage of Bing News Search API using REST calls""" 4 | 5 | import json 6 | from pprint import pprint 7 | 8 | import dotenv 9 | import requests 10 | from requests import HTTPError 11 | 12 | 13 | def news_search_basic( 14 | query, subscription_key, auth_header_name="Ocp-Apim-Subscription-Key", mkt="en-us" 15 | ): 16 | """Bing News Search Basic REST call 17 | 18 | This sample makes a call to the Bing News Search API with a text query and 19 | returns relevant news webpages. 20 | Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-news-search/overview 21 | 22 | May throw HTTPError in case of invalid parameters or a server error. 23 | 24 | Args: 25 | subscription_key (str): Azure subscription key of Bing News Search service 26 | auth_header_name (str): Name of the authorization header 27 | query (str): Query to search for 28 | mkt (str): Market to search in 29 | """ 30 | # Construct a request 31 | endpoint = "https://api.bing.microsoft.com/v7.0/news/search" 32 | params = {"q": query, "mkt": mkt} 33 | headers = {auth_header_name: subscription_key} 34 | 35 | # Call the API 36 | try: 37 | response = requests.get(endpoint, headers=headers, params=params, timeout=10) 38 | response.raise_for_status() 39 | return response 40 | except HTTPError as ex: 41 | print(ex) 42 | print("++The above exception was thrown and handled succesfully++") 43 | return response 44 | 45 | 46 | def main() -> None: 47 | """Main Function that sends an example request and pretty prints the response""" 48 | # Load the environment variables from .env file 49 | env = dotenv.dotenv_values() 50 | 51 | # pylint: disable=invalid-name 52 | SUBSCRIPTION_KEY_ENV_VAR_NAME = "BING_SEARCH_V7_NEWS_SEARCH_SUBSCRIPTION_KEY" 53 | 54 | # Add your Bing News Search V7 subscription key to your environment variables / .env file 55 | subscription_key = env.get(SUBSCRIPTION_KEY_ENV_VAR_NAME) 56 | if not subscription_key: 57 | raise ( 58 | RuntimeError( 59 | f"Please define the {SUBSCRIPTION_KEY_ENV_VAR_NAME} environment variable" 60 | ) 61 | ) 62 | 63 | response = news_search_basic("Microsoft", subscription_key) 64 | print("\nResponse Headers:\n") 65 | pprint(dict(response.headers)) 66 | 67 | print("\nJSON Response:\n") 68 | print(json.dumps(response.json(), indent=4)) 69 | 70 | 71 | if __name__ == "__main__": 72 | main() 73 | -------------------------------------------------------------------------------- /samples/rest/bing_video_search_v7.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Python example showcasing the usage of Bing Video Search API using REST calls""" 4 | 5 | import json 6 | from pprint import pprint 7 | 8 | import dotenv 9 | import requests 10 | from requests import HTTPError 11 | 12 | 13 | def video_search_basic( 14 | query, subscription_key, auth_header_name="Ocp-Apim-Subscription-Key", mkt="en-us" 15 | ): 16 | """Bing Video Search Basic REST call 17 | 18 | This sample makes a call to the Bing Video Search API with a topic query and 19 | returns relevant video with data. 20 | 21 | Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-video-search/overview 22 | 23 | May throw HTTPError in case of invalid parameters or a server error. 24 | 25 | Args: 26 | subscription_key (str): Azure subscription key of Bing Video Search service 27 | auth_header_name (str): Name of the authorization header 28 | query (str): Query to search for 29 | mkt (str): Market to search in 30 | """ 31 | # Construct a request 32 | endpoint = "https://api.bing.microsoft.com/v7.0/videos/search" 33 | params = {"q": query, "mkt": mkt} 34 | headers = {auth_header_name: subscription_key, "Content-Type": "application/json"} 35 | 36 | # Call the API 37 | try: 38 | response = requests.get(endpoint, headers=headers, params=params, timeout=10) 39 | response.raise_for_status() 40 | return response 41 | except HTTPError as ex: 42 | print(ex) 43 | print("++The above exception was thrown and handled succesfully++") 44 | return response 45 | 46 | 47 | def main() -> None: 48 | """Main Function that sends an example request and pretty prints the response""" 49 | # Load the environment variables from .env file 50 | env = dotenv.dotenv_values() 51 | 52 | # pylint: disable=invalid-name 53 | SUBSCRIPTION_KEY_ENV_VAR_NAME = "BING_SEARCH_V7_VIDEO_SEARCH_SUBSCRIPTION_KEY" 54 | 55 | # Add your Bing Video Search V7 subscription key to your environment variables / .env file 56 | subscription_key = env.get(SUBSCRIPTION_KEY_ENV_VAR_NAME) 57 | if not subscription_key: 58 | raise ( 59 | RuntimeError( 60 | f"Please define the {SUBSCRIPTION_KEY_ENV_VAR_NAME} environment variable" 61 | ) 62 | ) 63 | 64 | response = video_search_basic("kentucky derby", subscription_key) 65 | print("\nResponse Headers:\n") 66 | pprint(dict(response.headers)) 67 | 68 | print("\nJSON Response:\n") 69 | print(json.dumps(response.json(), indent=4)) 70 | 71 | 72 | if __name__ == "__main__": 73 | main() 74 | -------------------------------------------------------------------------------- /samples/rest/bing_web_search_v7.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Python example showcasing the usage of Bing Web Search API using REST calls""" 4 | 5 | import json 6 | from pprint import pprint 7 | 8 | import dotenv 9 | import requests 10 | from requests import HTTPError 11 | 12 | 13 | def web_search_basic( 14 | query, subscription_key, auth_header_name="Ocp-Apim-Subscription-Key", mkt="en-us" 15 | ): 16 | """Bing Web Search Basic REST call 17 | 18 | This sample makes a call to the Bing Web Search API with a text query and returns relevant pages 19 | Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-web-search/overview 20 | 21 | May throw HTTPError in case of invalid parameters or a server error. 22 | 23 | Args: 24 | subscription_key (str): Azure subscription key of Bing Web Search service 25 | auth_header_name (str): Name of the authorization header 26 | query (str): Query to search for 27 | mkt (str): Market to search in 28 | """ 29 | # Construct a request 30 | endpoint = "https://api.bing.microsoft.com/v7.0/search" 31 | params = {"q": query, "mkt": mkt} 32 | headers = {auth_header_name: subscription_key} 33 | 34 | # Call the API 35 | try: 36 | response = requests.get(endpoint, headers=headers, params=params, timeout=10) 37 | response.raise_for_status() 38 | return response 39 | except HTTPError as ex: 40 | print(ex) 41 | print("++The above exception was thrown and handled succesfully++") 42 | return response 43 | 44 | 45 | def main() -> None: 46 | """Main Function that sends an example request and pretty prints the response""" 47 | # Load the environment variables from .env file 48 | env = dotenv.dotenv_values() 49 | 50 | # pylint: disable=invalid-name 51 | SUBSCRIPTION_KEY_ENV_VAR_NAME = "BING_SEARCH_V7_WEB_SEARCH_SUBSCRIPTION_KEY" 52 | 53 | # Add your Bing Web Search V7 subscription key to your environment variables / .env file 54 | subscription_key = env.get(SUBSCRIPTION_KEY_ENV_VAR_NAME) 55 | if not subscription_key: 56 | raise ( 57 | RuntimeError( 58 | f"Please define the {SUBSCRIPTION_KEY_ENV_VAR_NAME} environment variable" 59 | ) 60 | ) 61 | 62 | response = web_search_basic("Microsoft", subscription_key) 63 | print("\nResponse Headers:\n") 64 | pprint(dict(response.headers)) 65 | 66 | print("\nJSON Response:\n") 67 | print(json.dumps(response.json(), indent=4)) 68 | 69 | 70 | if __name__ == "__main__": 71 | main() 72 | -------------------------------------------------------------------------------- /samples/sdk/TestImages/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bing-search-sdk-for-python/eb02313ba81cfa767b429893f1118c6ad9e8959b/samples/sdk/TestImages/image.jpg -------------------------------------------------------------------------------- /samples/sdk/autosuggest_samples.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from autosuggest_client import AutoSuggestClient 5 | from autosuggest_client.models import ( 6 | Suggestions, 7 | SuggestionsSuggestionGroup, 8 | SearchAction, 9 | ErrorResponse, 10 | ) 11 | from azure.core.credentials import AzureKeyCredential 12 | 13 | 14 | SUBSCRIPTION_KEY = None 15 | ENDPOINT = "https://api.bing.microsoft.com" + "/v7.0/" 16 | 17 | 18 | def autosuggest_lookup(subscription_key): 19 | """AutoSuggestLookup. 20 | 21 | This will look up a single query (Xbox) and print out name and url for first web result. 22 | """ 23 | client = AutoSuggestClient( 24 | endpoint=ENDPOINT, credential=AzureKeyCredential(SUBSCRIPTION_KEY) 25 | ) 26 | 27 | try: 28 | suggestions = client.auto_suggest(query="Satya Nadella") # type: Suggestions 29 | 30 | if suggestions.suggestion_groups: 31 | print('Searched for "Satya Nadella" and found suggestions:') 32 | suggestion_group = suggestions.suggestion_groups[ 33 | 0 34 | ] # type: SuggestionsSuggestionGroup 35 | for suggestion in suggestion_group.search_suggestions: # type: SearchAction 36 | print("....................................") 37 | print(suggestion.query) 38 | print(suggestion.display_text) 39 | print(suggestion.url) 40 | print(suggestion.search_kind) 41 | else: 42 | print("Didn't see any suggestion..") 43 | 44 | except Exception as err: 45 | print("Encountered exception. {}".format(err)) 46 | 47 | 48 | def error(subscription_key): 49 | """Error. 50 | 51 | This triggers a bad request and shows how to read the error response. 52 | """ 53 | 54 | # Breaking the subscription key on purpose 55 | client = AutoSuggestClient( 56 | credential=AzureKeyCredential(SUBSCRIPTION_KEY + "1"), endpoint=ENDPOINT 57 | ) 58 | 59 | try: 60 | suggestions = client.auto_suggest(query="Satya Nadella", market="no-ty") 61 | except Exception as err: 62 | # The status code of the error should be a good indication of what occurred. However, if you'd like more details, you can dig into the response. 63 | # Please note that depending on the type of error, the response schema might be different, so you aren't guaranteed a specific error response schema. 64 | 65 | print("Exception occurred, with reason {}.\n".format(err)) 66 | 67 | 68 | if __name__ == "__main__": 69 | import sys 70 | import os.path 71 | 72 | sys.path.append(os.path.abspath(os.path.join(__file__, "..", ".."))) 73 | autosuggest_lookup(SUBSCRIPTION_KEY) 74 | error(SUBSCRIPTION_KEY) 75 | -------------------------------------------------------------------------------- /samples/sdk/custom_image_search_samples.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | from custom_image_search_client import CustomImageSearchClient 6 | from azure.core.credentials import AzureKeyCredential 7 | 8 | 9 | SUBSCRIPTION_KEY = None 10 | ENDPOINT = "https://api.bing.microsoft.com" + "/v7.0/" 11 | 12 | 13 | def custom_image_search_result_lookup(subscription_key): 14 | """CustomImageSearchResultLookup. 15 | 16 | This will look up a single query (Xbox) and print out number of results, insights token, thumbnail url, content url for the first image result 17 | """ 18 | 19 | client = CustomImageSearchClient( 20 | endpoint=ENDPOINT, credential=AzureKeyCredential(subscription_key) 21 | ) 22 | try: 23 | image_results = client.custom_instance.image_search( 24 | query="Xbox", custom_config=1 25 | ) 26 | print('Searched for Query " Xbox "') 27 | 28 | # WebPages 29 | if image_results.value: 30 | # find the first web page 31 | first_image_result = image_results.value[0] 32 | 33 | if first_image_result: 34 | print("Image result count: {}".format(len(image_results.value))) 35 | print( 36 | "First image insights token: {}".format( 37 | first_image_result.image_insights_token 38 | ) 39 | ) 40 | print( 41 | "First image thumbnail url: {}".format( 42 | first_image_result.thumbnail_url 43 | ) 44 | ) 45 | print( 46 | "First image content url: {}".format(first_image_result.content_url) 47 | ) 48 | else: 49 | print("Couldn't find image results!") 50 | else: 51 | print("Couldn't find image results!") 52 | except Exception as e: 53 | print("encountered exception. " + str(e)) 54 | 55 | 56 | if __name__ == "__main__": 57 | import sys 58 | import os.path 59 | 60 | sys.path.append(os.path.abspath(os.path.join(__file__, "..", ".."))) 61 | custom_image_search_result_lookup(SUBSCRIPTION_KEY) 62 | -------------------------------------------------------------------------------- /samples/sdk/custom_search_samples.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | from custom_search_client import CustomSearchClient 6 | from azure.core.credentials import AzureKeyCredential 7 | 8 | SUBSCRIPTION_KEY = None 9 | ENDPOINT = "https://api.bing.microsoft.com" + "/v7.0/" 10 | 11 | 12 | def custom_search_web_page_result_lookup(subscription_key): 13 | """CustomSearch. 14 | 15 | This will look up a single query (Xbox) and print out name and url for first web result. 16 | """ 17 | 18 | client = CustomSearchClient( 19 | endpoint=ENDPOINT, credential=AzureKeyCredential(subscription_key) 20 | ) 21 | 22 | try: 23 | web_data = client.custom_instance.search(query="xbox", custom_config=1) 24 | print("Searched for Query 'xbox'") 25 | 26 | if web_data.web_pages.value: 27 | first_web_result = web_data.web_pages.value[0] 28 | print("Web Pages result count: {}".format(len(web_data.web_pages.value))) 29 | print("First Web Page name: {}".format(first_web_result.name)) 30 | print("First Web Page url: {}".format(first_web_result.url)) 31 | else: 32 | print("Didn't see any web data..") 33 | 34 | except Exception as err: 35 | print("Encountered exception. {}".format(err)) 36 | 37 | 38 | if __name__ == "__main__": 39 | import sys, os.path 40 | 41 | sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..", ".."))) 42 | custom_search_web_page_result_lookup(SUBSCRIPTION_KEY) 43 | -------------------------------------------------------------------------------- /samples/sdk/image-search-quickstart.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | from image_search_client import ImageSearchClient 6 | from azure.core.credentials import AzureKeyCredential 7 | 8 | 9 | SUBSCRIPTION_KEY = None 10 | ENDPOINT = "https://api.bing.microsoft.com" + "/v7.0/" 11 | 12 | 13 | search_term = "canadian rockies" 14 | 15 | """ 16 | This application will search images on the web with the Bing Image Search API and print out first image result. 17 | """ 18 | if SUBSCRIPTION_KEY: 19 | # create the image search client 20 | client = ImageSearchClient(AzureKeyCredential(SUBSCRIPTION_KEY)) 21 | # send a search query to the Bing Image Search API 22 | image_results = client.images.search(query=search_term) 23 | print("Searching the web for images of: {}".format(search_term)) 24 | 25 | # Image results 26 | if image_results.value: 27 | first_image_result = image_results.value[0] 28 | print("Total number of images returned: {}".format(len(image_results.value))) 29 | print("First image thumbnail url: {}".format(first_image_result.thumbnail_url)) 30 | print("First image content url: {}".format(first_image_result.content_url)) 31 | else: 32 | print("Couldn't find image results!") 33 | -------------------------------------------------------------------------------- /samples/sdk/spellcheck_samples.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | from spell_check_client import SpellCheckClient 6 | from azure.core.credentials import AzureKeyCredential 7 | 8 | SUBSCRIPTION_KEY = None 9 | ENDPOINT = "https://api.bing.microsoft.com" + "/v7.0/" 10 | 11 | 12 | def spellcheck(subscription_key): 13 | """SpellCheck. 14 | 15 | This will do a search for misspelled query and parse the response. 16 | """ 17 | client = SpellCheckClient(AzureKeyCredential(subscription_key)) 18 | 19 | try: 20 | result = client.spell_checker("Bill Gatas", mode="proof") 21 | print('Correction for Query# "bill gatas"') 22 | 23 | if result.flagged_tokens: 24 | first_spellcheck_result = result.flagged_tokens[0] 25 | 26 | print("SpellCheck result count: {}".format(len(result.flagged_tokens))) 27 | print("First SpellCheck token: {}".format(first_spellcheck_result.token)) 28 | print("First SpellCheck type: {}".format(first_spellcheck_result.type)) 29 | print( 30 | "First SpellCheck suggestion count: {}".format( 31 | len(first_spellcheck_result.suggestions) 32 | ) 33 | ) 34 | 35 | if first_spellcheck_result.suggestions: 36 | first_suggestion = first_spellcheck_result.suggestions[0] 37 | print( 38 | "First SpellCheck suggestion score: {}".format( 39 | first_suggestion.score 40 | ) 41 | ) 42 | print( 43 | "First SpellCheck suggestion: {}".format( 44 | first_suggestion.suggestion 45 | ) 46 | ) 47 | else: 48 | print("Couldn't get any Spell check results!") 49 | 50 | else: 51 | print("Didn't see any SpellCheck results..") 52 | 53 | except Exception as err: 54 | print("Encountered exception. {}".format(err)) 55 | 56 | 57 | if __name__ == "__main__": 58 | import sys, os.path 59 | 60 | sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..", ".."))) 61 | spellcheck(SUBSCRIPTION_KEY) 62 | -------------------------------------------------------------------------------- /sdk/Autosuggest/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/Autosuggest/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Autosuggest SDK for Python 4 | 5 | This is the Microsoft Bing Autosuggest Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Autosuggest](https://docs.microsoft.com/en-us/bing/search-apis/bing-autosuggest/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/Autosuggest/autosuggest_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._auto_suggest_client import AutoSuggestClient 11 | 12 | __all__ = ["AutoSuggestClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/Autosuggest/autosuggest_client/_auto_suggest_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | 16 | if TYPE_CHECKING: 17 | # pylint: disable=unused-import,ungrouped-imports 18 | from typing import Any, Optional 19 | 20 | from azure.core.credentials import TokenCredential 21 | 22 | from ._configuration import AutoSuggestClientConfiguration 23 | from .operations import AutoSuggestClientOperationsMixin 24 | import models 25 | 26 | 27 | class AutoSuggestClient(AutoSuggestClientOperationsMixin): 28 | """Autosuggest supplies search terms derived from a root text sent to the service. The terms Autosuggest supplies are related to the root text based on similarity and their frequency or ratings of usefulness in other searches. For examples that show how to use Autosuggest, see `Search using AutoSuggest `_. 29 | 30 | :param credential: Credential needed for the client to connect to Azure. 31 | :type credentials: None 32 | :param str base_url: Service URL 33 | """ 34 | 35 | def __init__( 36 | self, 37 | credential, # type: none 38 | base_url=None, # type: Optional[str] 39 | **kwargs # type: Any 40 | ): 41 | # type: (...) -> None 42 | if not base_url: 43 | base_url = "https://api.bing.microsoft.com/v7.0" 44 | self._config = AutoSuggestClientConfiguration(credential, **kwargs) 45 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 46 | client_models = { 47 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 48 | } 49 | self._serialize = Serializer(client_models) 50 | self._serialize.client_side_validation = False 51 | self._deserialize = Deserializer(client_models) 52 | 53 | def close(self): 54 | # type: () -> None 55 | self._client.close() 56 | 57 | def __enter__(self): 58 | # type: () -> AutoSuggestClient 59 | self._client.__enter__() 60 | return self 61 | 62 | def __exit__(self, *exc_details): 63 | # type: (Any) -> None 64 | self._client.__exit__(*exc_details) 65 | -------------------------------------------------------------------------------- /sdk/Autosuggest/autosuggest_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._auto_suggest_client import AutoSuggestClient 11 | 12 | __all__ = ["AutoSuggestClient"] 13 | -------------------------------------------------------------------------------- /sdk/Autosuggest/autosuggest_client/aio/_auto_suggest_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import AutoSuggestClientConfiguration 20 | from .operations import AutoSuggestClientOperationsMixin 21 | from .. import models 22 | 23 | 24 | class AutoSuggestClient(AutoSuggestClientOperationsMixin): 25 | """Autosuggest supplies search terms derived from a root text sent to the service. The terms Autosuggest supplies are related to the root text based on similarity and their frequency or ratings of usefulness in other searches. For examples that show how to use Autosuggest, see `Search using AutoSuggest `_. 26 | 27 | :param credential: Credential needed for the client to connect to Azure. 28 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 29 | :param str base_url: Service URL 30 | """ 31 | 32 | def __init__( 33 | self, 34 | credential: "AsyncTokenCredential", 35 | base_url: Optional[str] = None, 36 | **kwargs: Any 37 | ) -> None: 38 | if not base_url: 39 | base_url = "https://api.bing.microsoft.com/v7.0" 40 | self._config = AutoSuggestClientConfiguration(credential, **kwargs) 41 | self._client = AsyncPipelineClient( 42 | base_url=base_url, config=self._config, **kwargs 43 | ) 44 | 45 | client_models = { 46 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 47 | } 48 | self._serialize = Serializer(client_models) 49 | self._serialize.client_side_validation = False 50 | self._deserialize = Deserializer(client_models) 51 | 52 | async def close(self) -> None: 53 | await self._client.close() 54 | 55 | async def __aenter__(self) -> "AutoSuggestClient": 56 | await self._client.__aenter__() 57 | return self 58 | 59 | async def __aexit__(self, *exc_details) -> None: 60 | await self._client.__aexit__(*exc_details) 61 | -------------------------------------------------------------------------------- /sdk/Autosuggest/autosuggest_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._auto_suggest_client_operations import AutoSuggestClientOperationsMixin 11 | 12 | __all__ = [ 13 | "AutoSuggestClientOperationsMixin", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/Autosuggest/autosuggest_client/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | try: 11 | from ._models_py3 import Action 12 | from ._models_py3 import Answer 13 | from ._models_py3 import CreativeWork 14 | from ._models_py3 import Error 15 | from ._models_py3 import ErrorResponse 16 | from ._models_py3 import Identifiable 17 | from ._models_py3 import QueryContext 18 | from ._models_py3 import Response 19 | from ._models_py3 import ResponseBase 20 | from ._models_py3 import SearchAction 21 | from ._models_py3 import SearchResultsAnswer 22 | from ._models_py3 import Suggestions 23 | from ._models_py3 import SuggestionsSuggestionGroup 24 | from ._models_py3 import Thing 25 | except (SyntaxError, ImportError): 26 | from ._models import Action # type: ignore 27 | from ._models import Answer # type: ignore 28 | from ._models import CreativeWork # type: ignore 29 | from ._models import Error # type: ignore 30 | from ._models import ErrorResponse # type: ignore 31 | from ._models import Identifiable # type: ignore 32 | from ._models import QueryContext # type: ignore 33 | from ._models import Response # type: ignore 34 | from ._models import ResponseBase # type: ignore 35 | from ._models import SearchAction # type: ignore 36 | from ._models import SearchResultsAnswer # type: ignore 37 | from ._models import Suggestions # type: ignore 38 | from ._models import SuggestionsSuggestionGroup # type: ignore 39 | from ._models import Thing # type: ignore 40 | 41 | from ._auto_suggest_client_enums import ( 42 | ErrorCode, 43 | ResponseFormat, 44 | SafeSearch, 45 | ScenarioType, 46 | SearchKind, 47 | XBingApisSDK, 48 | ) 49 | 50 | __all__ = [ 51 | "Action", 52 | "Answer", 53 | "CreativeWork", 54 | "Error", 55 | "ErrorResponse", 56 | "Identifiable", 57 | "QueryContext", 58 | "Response", 59 | "ResponseBase", 60 | "SearchAction", 61 | "SearchResultsAnswer", 62 | "Suggestions", 63 | "SuggestionsSuggestionGroup", 64 | "Thing", 65 | "ErrorCode", 66 | "ResponseFormat", 67 | "SafeSearch", 68 | "ScenarioType", 69 | "SearchKind", 70 | "XBingApisSDK", 71 | ] 72 | -------------------------------------------------------------------------------- /sdk/Autosuggest/autosuggest_client/models/_auto_suggest_client_enums.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from enum import Enum, EnumMeta 11 | from six import with_metaclass 12 | 13 | 14 | class _CaseInsensitiveEnumMeta(EnumMeta): 15 | def __getitem__(self, name): 16 | return super().__getitem__(name.upper()) 17 | 18 | def __getattr__(cls, name): 19 | """Return the enum member matching `name` 20 | We use __getattr__ instead of descriptors or inserting into the enum 21 | class' __dict__ in order to support `name` and `value` being both 22 | properties for enum members (which live in the class' __dict__) and 23 | enum members themselves. 24 | """ 25 | try: 26 | return cls._member_map_[name.upper()] 27 | except KeyError: 28 | raise AttributeError(name) 29 | 30 | 31 | class ErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 32 | """The error code that identifies the category of error.""" 33 | 34 | NONE = "None" 35 | SERVER_ERROR = "ServerError" 36 | INVALID_REQUEST = "InvalidRequest" 37 | RATE_LIMIT_EXCEEDED = "RateLimitExceeded" 38 | INVALID_AUTHORIZATION = "InvalidAuthorization" 39 | INSUFFICIENT_AUTHORIZATION = "InsufficientAuthorization" 40 | 41 | 42 | class ResponseFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 43 | 44 | JSON = "Json" 45 | JSON_LD = "JsonLd" 46 | 47 | 48 | class SafeSearch(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 49 | 50 | OFF = "Off" 51 | MODERATE = "Moderate" 52 | STRICT = "Strict" 53 | 54 | 55 | class ScenarioType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 56 | 57 | UNKNOWN = "Unknown" 58 | WEB = "Web" 59 | STORE_APPS = "StoreApps" 60 | SEARCH_HISTORY = "SearchHistory" 61 | PERSONAL_SEARCH_DOCUMENTS = "PersonalSearchDocuments" 62 | PERSONAL_SEARCH_TAGS = "PersonalSearchTags" 63 | CUSTOM = "Custom" 64 | 65 | 66 | class SearchKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 67 | 68 | WEB_SEARCH = "WebSearch" 69 | HISTORY_SEARCH = "HistorySearch" 70 | DOCUMENT_SEARCH = "DocumentSearch" 71 | TAG_SEARCH = "TagSearch" 72 | LOCATION_SEARCH = "LocationSearch" 73 | CUSTOM_SEARCH = "CustomSearch" 74 | 75 | 76 | class XBingApisSDK(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 77 | 78 | TRUE = "true" 79 | -------------------------------------------------------------------------------- /sdk/Autosuggest/autosuggest_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._auto_suggest_client_operations import AutoSuggestClientOperationsMixin 11 | 12 | __all__ = [ 13 | "AutoSuggestClientOperationsMixin", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/Autosuggest/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/Autosuggest/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/Autosuggest/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-autosuggest" 13 | PACKAGE_PPRINT_NAME = "Autosuggest" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "autosuggest_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/CustomImageSearch/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Custom Image Search SDK for Python 4 | 5 | This is the Microsoft Bing Custom Image Search Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Custom Image Search](https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/custom_image_search_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._custom_image_search_client import CustomImageSearchClient 11 | 12 | __all__ = ["CustomImageSearchClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/custom_image_search_client/_custom_image_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from typing import Any, Optional 18 | 19 | from azure.core.credentials import TokenCredential 20 | 21 | from ._configuration import CustomImageSearchClientConfiguration 22 | from .operations import CustomInstanceOperations 23 | from . import models 24 | 25 | 26 | class CustomImageSearchClient(object): 27 | """The Bing Custom Image Search API lets you send an image search query to Bing and get back image search results customized to meet your custom search definition. 28 | 29 | :ivar custom_instance: CustomInstanceOperations operations 30 | :vartype custom_instance: custom_image_search_client.operations.CustomInstanceOperations 31 | :param credential: Credential needed for the client to connect to Azure. 32 | :type credential: ~azure.core.credentials.TokenCredential 33 | :param str base_url: Service URL 34 | """ 35 | 36 | def __init__( 37 | self, 38 | credential, # type: "TokenCredential" 39 | base_url=None, # type: Optional[str] 40 | **kwargs # type: Any 41 | ): 42 | # type: (...) -> None 43 | if not base_url: 44 | base_url = "https://api.bing.microsoft.com/v7.0/custom" 45 | self._config = CustomImageSearchClientConfiguration(credential, **kwargs) 46 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 47 | 48 | client_models = { 49 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 50 | } 51 | self._serialize = Serializer(client_models) 52 | self._serialize.client_side_validation = False 53 | self._deserialize = Deserializer(client_models) 54 | 55 | self.custom_instance = CustomInstanceOperations( 56 | self._client, self._config, self._serialize, self._deserialize 57 | ) 58 | 59 | def close(self): 60 | # type: () -> None 61 | self._client.close() 62 | 63 | def __enter__(self): 64 | # type: () -> CustomImageSearchClient 65 | self._client.__enter__() 66 | return self 67 | 68 | def __exit__(self, *exc_details): 69 | # type: (Any) -> None 70 | self._client.__exit__(*exc_details) 71 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/custom_image_search_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._custom_image_search_client import CustomImageSearchClient 11 | 12 | __all__ = ["CustomImageSearchClient"] 13 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/custom_image_search_client/aio/_custom_image_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import CustomImageSearchClientConfiguration 20 | from .operations import CustomInstanceOperations 21 | from .. import models 22 | 23 | 24 | class CustomImageSearchClient(object): 25 | """The Bing Custom Image Search API lets you send an image search query to Bing and get back image search results customized to meet your custom search definition. 26 | 27 | :ivar custom_instance: CustomInstanceOperations operations 28 | :vartype custom_instance: custom_image_search_client.aio.operations.CustomInstanceOperations 29 | :param credential: Credential needed for the client to connect to Azure. 30 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 31 | :param str base_url: Service URL 32 | """ 33 | 34 | def __init__( 35 | self, 36 | credential: "AsyncTokenCredential", 37 | base_url: Optional[str] = None, 38 | **kwargs: Any 39 | ) -> None: 40 | if not base_url: 41 | base_url = "https://api.bing.microsoft.com/v7.0/custom" 42 | self._config = CustomImageSearchClientConfiguration(credential, **kwargs) 43 | self._client = AsyncPipelineClient( 44 | base_url=base_url, config=self._config, **kwargs 45 | ) 46 | 47 | client_models = { 48 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 49 | } 50 | self._serialize = Serializer(client_models) 51 | self._serialize.client_side_validation = False 52 | self._deserialize = Deserializer(client_models) 53 | 54 | self.custom_instance = CustomInstanceOperations( 55 | self._client, self._config, self._serialize, self._deserialize 56 | ) 57 | 58 | async def close(self) -> None: 59 | await self._client.close() 60 | 61 | async def __aenter__(self) -> "CustomImageSearchClient": 62 | await self._client.__aenter__() 63 | return self 64 | 65 | async def __aexit__(self, *exc_details) -> None: 66 | await self._client.__aexit__(*exc_details) 67 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/custom_image_search_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._custom_instance_operations import CustomInstanceOperations 11 | 12 | __all__ = [ 13 | "CustomInstanceOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/custom_image_search_client/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | try: 11 | from ._models_py3 import Answer 12 | from ._models_py3 import CreativeWork 13 | from ._models_py3 import Error 14 | from ._models_py3 import ErrorResponse 15 | from ._models_py3 import Identifiable 16 | from ._models_py3 import ImageObject 17 | from ._models_py3 import Images 18 | from ._models_py3 import MediaObject 19 | from ._models_py3 import Query 20 | from ._models_py3 import Response 21 | from ._models_py3 import ResponseBase 22 | from ._models_py3 import SearchResultsAnswer 23 | from ._models_py3 import Thing 24 | from ._models_py3 import WebPage 25 | except (SyntaxError, ImportError): 26 | from ._models import Answer # type: ignore 27 | from ._models import CreativeWork # type: ignore 28 | from ._models import Error # type: ignore 29 | from ._models import ErrorResponse # type: ignore 30 | from ._models import Identifiable # type: ignore 31 | from ._models import ImageObject # type: ignore 32 | from ._models import Images # type: ignore 33 | from ._models import MediaObject # type: ignore 34 | from ._models import Query # type: ignore 35 | from ._models import Response # type: ignore 36 | from ._models import ResponseBase # type: ignore 37 | from ._models import SearchResultsAnswer # type: ignore 38 | from ._models import Thing # type: ignore 39 | from ._models import WebPage # type: ignore 40 | 41 | from ._custom_image_search_client_enums import ( 42 | ErrorCode, 43 | ErrorSubCode, 44 | Freshness, 45 | ImageAspect, 46 | ImageColor, 47 | ImageContent, 48 | ImageLicense, 49 | ImageSize, 50 | ImageType, 51 | SafeSearch, 52 | XBingApisSDK, 53 | ) 54 | 55 | __all__ = [ 56 | "Answer", 57 | "CreativeWork", 58 | "Error", 59 | "ErrorResponse", 60 | "Identifiable", 61 | "ImageObject", 62 | "Images", 63 | "MediaObject", 64 | "Query", 65 | "Response", 66 | "ResponseBase", 67 | "SearchResultsAnswer", 68 | "Thing", 69 | "WebPage", 70 | "ErrorCode", 71 | "ErrorSubCode", 72 | "Freshness", 73 | "ImageAspect", 74 | "ImageColor", 75 | "ImageContent", 76 | "ImageLicense", 77 | "ImageSize", 78 | "ImageType", 79 | "SafeSearch", 80 | "XBingApisSDK", 81 | ] 82 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/custom_image_search_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._custom_instance_operations import CustomInstanceOperations 11 | 12 | __all__ = [ 13 | "CustomInstanceOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/custom_image_search_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /sdk/CustomImageSearch/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/CustomImageSearch/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/CustomImageSearch/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-customimagesearch" 13 | PACKAGE_PPRINT_NAME = "Custom Image Search" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "custom_image_search_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/CustomWebSearch/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Custom Web Search SDK for Python 4 | 5 | This is the Microsoft Bing Custom Web Search Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Custom Web Search](https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._custom_search_client import CustomSearchClient 11 | 12 | __all__ = ["CustomSearchClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/_custom_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from typing import Any, Optional 18 | 19 | from azure.core.credentials import TokenCredential 20 | 21 | from ._configuration import CustomSearchClientConfiguration 22 | from .operations import CustomInstanceOperations 23 | from . import models 24 | 25 | 26 | class CustomSearchClient(object): 27 | """The Bing Custom Search API lets you send a search query to Bing and get back search results customized to meet your custom search definition. 28 | 29 | :ivar custom_instance: CustomInstanceOperations operations 30 | :vartype custom_instance: custom_search_client.operations.CustomInstanceOperations 31 | :param credential: Credential needed for the client to connect to Azure. 32 | :type credential: ~azure.core.credentials.TokenCredential 33 | :param str base_url: Service URL 34 | """ 35 | 36 | def __init__( 37 | self, 38 | credential, # type: "TokenCredential" 39 | base_url=None, # type: Optional[str] 40 | **kwargs # type: Any 41 | ): 42 | # type: (...) -> None 43 | if not base_url: 44 | base_url = "https://api.bing.microsoft.com/v7.0/custom" 45 | self._config = CustomSearchClientConfiguration(credential, **kwargs) 46 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 47 | 48 | client_models = { 49 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 50 | } 51 | self._serialize = Serializer(client_models) 52 | self._serialize.client_side_validation = False 53 | self._deserialize = Deserializer(client_models) 54 | 55 | self.custom_instance = CustomInstanceOperations( 56 | self._client, self._config, self._serialize, self._deserialize 57 | ) 58 | 59 | def close(self): 60 | # type: () -> None 61 | self._client.close() 62 | 63 | def __enter__(self): 64 | # type: () -> CustomSearchClient 65 | self._client.__enter__() 66 | return self 67 | 68 | def __exit__(self, *exc_details): 69 | # type: (Any) -> None 70 | self._client.__exit__(*exc_details) 71 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._custom_search_client import CustomSearchClient 11 | 12 | __all__ = ["CustomSearchClient"] 13 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/aio/_custom_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import CustomSearchClientConfiguration 20 | from .operations import CustomInstanceOperations 21 | from .. import models 22 | 23 | 24 | class CustomSearchClient(object): 25 | """The Bing Custom Search API lets you send a search query to Bing and get back search results customized to meet your custom search definition. 26 | 27 | :ivar custom_instance: CustomInstanceOperations operations 28 | :vartype custom_instance: custom_search_client.aio.operations.CustomInstanceOperations 29 | :param credential: Credential needed for the client to connect to Azure. 30 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 31 | :param str base_url: Service URL 32 | """ 33 | 34 | def __init__( 35 | self, 36 | credential: "AsyncTokenCredential", 37 | base_url: Optional[str] = None, 38 | **kwargs: Any 39 | ) -> None: 40 | if not base_url: 41 | base_url = "https://api.bing.microsoft.com/v7.0/custom" 42 | self._config = CustomSearchClientConfiguration(credential, **kwargs) 43 | self._client = AsyncPipelineClient( 44 | base_url=base_url, config=self._config, **kwargs 45 | ) 46 | 47 | client_models = { 48 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 49 | } 50 | self._serialize = Serializer(client_models) 51 | self._serialize.client_side_validation = False 52 | self._deserialize = Deserializer(client_models) 53 | 54 | self.custom_instance = CustomInstanceOperations( 55 | self._client, self._config, self._serialize, self._deserialize 56 | ) 57 | 58 | async def close(self) -> None: 59 | await self._client.close() 60 | 61 | async def __aenter__(self) -> "CustomSearchClient": 62 | await self._client.__aenter__() 63 | return self 64 | 65 | async def __aexit__(self, *exc_details) -> None: 66 | await self._client.__aexit__(*exc_details) 67 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._custom_instance_operations import CustomInstanceOperations 11 | 12 | __all__ = [ 13 | "CustomInstanceOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | try: 11 | from ._models_py3 import Answer 12 | from ._models_py3 import CreativeWork 13 | from ._models_py3 import Error 14 | from ._models_py3 import ErrorResponse 15 | from ._models_py3 import Identifiable 16 | from ._models_py3 import Query 17 | from ._models_py3 import QueryContext 18 | from ._models_py3 import Response 19 | from ._models_py3 import ResponseBase 20 | from ._models_py3 import SearchResponse 21 | from ._models_py3 import SearchResultsAnswer 22 | from ._models_py3 import Thing 23 | from ._models_py3 import WebAnswer 24 | from ._models_py3 import WebMetaTag 25 | from ._models_py3 import WebPage 26 | except (SyntaxError, ImportError): 27 | from ._models import Answer # type: ignore 28 | from ._models import CreativeWork # type: ignore 29 | from ._models import Error # type: ignore 30 | from ._models import ErrorResponse # type: ignore 31 | from ._models import Identifiable # type: ignore 32 | from ._models import Query # type: ignore 33 | from ._models import QueryContext # type: ignore 34 | from ._models import Response # type: ignore 35 | from ._models import ResponseBase # type: ignore 36 | from ._models import SearchResponse # type: ignore 37 | from ._models import SearchResultsAnswer # type: ignore 38 | from ._models import Thing # type: ignore 39 | from ._models import WebAnswer # type: ignore 40 | from ._models import WebMetaTag # type: ignore 41 | from ._models import WebPage # type: ignore 42 | 43 | from ._custom_search_client_enums import ( 44 | ErrorCode, 45 | ErrorSubCode, 46 | SafeSearch, 47 | TextFormat, 48 | XBingApisSDK, 49 | ) 50 | 51 | __all__ = [ 52 | "Answer", 53 | "CreativeWork", 54 | "Error", 55 | "ErrorResponse", 56 | "Identifiable", 57 | "Query", 58 | "QueryContext", 59 | "Response", 60 | "ResponseBase", 61 | "SearchResponse", 62 | "SearchResultsAnswer", 63 | "Thing", 64 | "WebAnswer", 65 | "WebMetaTag", 66 | "WebPage", 67 | "ErrorCode", 68 | "ErrorSubCode", 69 | "SafeSearch", 70 | "TextFormat", 71 | "XBingApisSDK", 72 | ] 73 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/models/_custom_search_client_enums.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from enum import Enum, EnumMeta 11 | from six import with_metaclass 12 | 13 | 14 | class _CaseInsensitiveEnumMeta(EnumMeta): 15 | def __getitem__(self, name): 16 | return super().__getitem__(name.upper()) 17 | 18 | def __getattr__(cls, name): 19 | """Return the enum member matching `name` 20 | We use __getattr__ instead of descriptors or inserting into the enum 21 | class' __dict__ in order to support `name` and `value` being both 22 | properties for enum members (which live in the class' __dict__) and 23 | enum members themselves. 24 | """ 25 | try: 26 | return cls._member_map_[name.upper()] 27 | except KeyError: 28 | raise AttributeError(name) 29 | 30 | 31 | class ErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 32 | """The error code that identifies the category of error.""" 33 | 34 | NONE = "None" 35 | SERVER_ERROR = "ServerError" 36 | INVALID_REQUEST = "InvalidRequest" 37 | RATE_LIMIT_EXCEEDED = "RateLimitExceeded" 38 | INVALID_AUTHORIZATION = "InvalidAuthorization" 39 | INSUFFICIENT_AUTHORIZATION = "InsufficientAuthorization" 40 | 41 | 42 | class ErrorSubCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 43 | """The error code that further helps to identify the error.""" 44 | 45 | UNEXPECTED_ERROR = "UnexpectedError" 46 | RESOURCE_ERROR = "ResourceError" 47 | NOT_IMPLEMENTED = "NotImplemented" 48 | PARAMETER_MISSING = "ParameterMissing" 49 | PARAMETER_INVALID_VALUE = "ParameterInvalidValue" 50 | HTTP_NOT_ALLOWED = "HttpNotAllowed" 51 | BLOCKED = "Blocked" 52 | AUTHORIZATION_MISSING = "AuthorizationMissing" 53 | AUTHORIZATION_REDUNDANCY = "AuthorizationRedundancy" 54 | AUTHORIZATION_DISABLED = "AuthorizationDisabled" 55 | AUTHORIZATION_EXPIRED = "AuthorizationExpired" 56 | 57 | 58 | class SafeSearch(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 59 | 60 | OFF = "Off" 61 | MODERATE = "Moderate" 62 | STRICT = "Strict" 63 | 64 | 65 | class TextFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 66 | 67 | RAW = "Raw" 68 | HTML = "Html" 69 | 70 | 71 | class XBingApisSDK(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 72 | 73 | TRUE = "true" 74 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._custom_instance_operations import CustomInstanceOperations 11 | 12 | __all__ = [ 13 | "CustomInstanceOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/custom_search_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /sdk/CustomWebSearch/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/CustomWebSearch/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/CustomWebSearch/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-customwebsearch" 13 | PACKAGE_PPRINT_NAME = "Custom Web Search" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "custom_search_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/EntitySearch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/EntitySearch/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Entity Search SDK for Python 4 | 5 | This is the Microsoft Bing Entity Search Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Entity Search](https://docs.microsoft.com/en-us/bing/search-apis/bing-entity-search/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/EntitySearch/entity_search_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._entity_search_client import EntitySearchClient 11 | 12 | __all__ = ["EntitySearchClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/EntitySearch/entity_search_client/_entity_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from typing import Any, Optional 18 | 19 | from azure.core.credentials import TokenCredential 20 | 21 | from ._configuration import EntitySearchClientConfiguration 22 | from .operations import EntitiesOperations 23 | from . import models 24 | 25 | 26 | class EntitySearchClient(object): 27 | """The Entity Search API lets you send a search query to Bing and get back search results that include entities and places. Place results include restaurants, hotel, or other local businesses. For places, the query can specify the name of the local business or it can ask for a list (for example, restaurants near me). Entity results include persons, places, or things. Place in this context is tourist attractions, states, countries, etc. 28 | 29 | :ivar entities: EntitiesOperations operations 30 | :vartype entities: entity_search_client.operations.EntitiesOperations 31 | :param credential: Credential needed for the client to connect to Azure. 32 | :type credential: None 33 | :param str base_url: Service URL 34 | """ 35 | 36 | def __init__( 37 | self, 38 | credential, # type: none 39 | base_url=None, # type: Optional[str] 40 | **kwargs # type: Any 41 | ): 42 | # type: (...) -> None 43 | if not base_url: 44 | base_url = "https://api.bing.microsoft.com/v7.0" 45 | self._config = EntitySearchClientConfiguration(credential, **kwargs) 46 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 47 | 48 | client_models = { 49 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 50 | } 51 | self._serialize = Serializer(client_models) 52 | self._serialize.client_side_validation = False 53 | self._deserialize = Deserializer(client_models) 54 | 55 | self.entities = EntitiesOperations( 56 | self._client, self._config, self._serialize, self._deserialize 57 | ) 58 | 59 | def close(self): 60 | # type: () -> None 61 | self._client.close() 62 | 63 | def __enter__(self): 64 | # type: () -> EntitySearchClient 65 | self._client.__enter__() 66 | return self 67 | 68 | def __exit__(self, *exc_details): 69 | # type: (Any) -> None 70 | self._client.__exit__(*exc_details) 71 | -------------------------------------------------------------------------------- /sdk/EntitySearch/entity_search_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._entity_search_client import EntitySearchClient 11 | 12 | __all__ = ["EntitySearchClient"] 13 | -------------------------------------------------------------------------------- /sdk/EntitySearch/entity_search_client/aio/_entity_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import EntitySearchClientConfiguration 20 | from .operations import EntitiesOperations 21 | from .. import models 22 | 23 | 24 | class EntitySearchClient(object): 25 | """The Entity Search API lets you send a search query to Bing and get back search results that include entities and places. Place results include restaurants, hotel, or other local businesses. For places, the query can specify the name of the local business or it can ask for a list (for example, restaurants near me). Entity results include persons, places, or things. Place in this context is tourist attractions, states, countries, etc. 26 | 27 | :ivar entities: EntitiesOperations operations 28 | :vartype entities: entity_search_client.aio.operations.EntitiesOperations 29 | :param credential: Credential needed for the client to connect to Azure. 30 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 31 | :param str base_url: Service URL 32 | """ 33 | 34 | def __init__( 35 | self, 36 | credential: "AsyncTokenCredential", 37 | base_url: Optional[str] = None, 38 | **kwargs: Any 39 | ) -> None: 40 | if not base_url: 41 | base_url = "https://api.bing.microsoft.com/v7.0" 42 | self._config = EntitySearchClientConfiguration(credential, **kwargs) 43 | self._client = AsyncPipelineClient( 44 | base_url=base_url, config=self._config, **kwargs 45 | ) 46 | 47 | client_models = { 48 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 49 | } 50 | self._serialize = Serializer(client_models) 51 | self._serialize.client_side_validation = False 52 | self._deserialize = Deserializer(client_models) 53 | 54 | self.entities = EntitiesOperations( 55 | self._client, self._config, self._serialize, self._deserialize 56 | ) 57 | 58 | async def close(self) -> None: 59 | await self._client.close() 60 | 61 | async def __aenter__(self) -> "EntitySearchClient": 62 | await self._client.__aenter__() 63 | return self 64 | 65 | async def __aexit__(self, *exc_details) -> None: 66 | await self._client.__aexit__(*exc_details) 67 | -------------------------------------------------------------------------------- /sdk/EntitySearch/entity_search_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._entities_operations import EntitiesOperations 11 | 12 | __all__ = [ 13 | "EntitiesOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/EntitySearch/entity_search_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._entities_operations import EntitiesOperations 11 | 12 | __all__ = [ 13 | "EntitiesOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/EntitySearch/entity_search_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /sdk/EntitySearch/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/EntitySearch/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/EntitySearch/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-entitysearch" 13 | PACKAGE_PPRINT_NAME = "Entity Search" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "entity_search_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/ImageSearch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/ImageSearch/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Image Search SDK for Python 4 | 5 | This is the Microsoft Bing Image Search Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Image Search](https://docs.microsoft.com/en-us/bing/search-apis/bing-image-search/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/ImageSearch/image_search_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._image_search_client import ImageSearchClient 11 | 12 | __all__ = ["ImageSearchClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/ImageSearch/image_search_client/_image_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from typing import Any, Optional 18 | 19 | from azure.core.credentials import TokenCredential 20 | 21 | from ._configuration import ImageSearchClientConfiguration 22 | from .operations import ImagesOperations 23 | from . import models 24 | 25 | 26 | class ImageSearchClient(object): 27 | """The Image Search API lets you send a search query to Bing and get back a list of relevant images. This section provides technical details about the query parameters and headers that you use to request images and the JSON response objects that contain them. For examples that show how to make requests, see `Searching the Web for Images `_. 28 | 29 | :ivar images: ImagesOperations operations 30 | :vartype images: image_search_client.operations.ImagesOperations 31 | :param credential: Credential needed for the client to connect to Azure. 32 | :type credential: ~azure.core.credentials.TokenCredential 33 | :param str base_url: Service URL 34 | """ 35 | 36 | def __init__( 37 | self, 38 | credential, # type: "TokenCredential" 39 | base_url=None, # type: Optional[str] 40 | **kwargs # type: Any 41 | ): 42 | # type: (...) -> None 43 | if not base_url: 44 | base_url = "https://api.bing.microsoft.com/v7.0" 45 | self._config = ImageSearchClientConfiguration(credential, **kwargs) 46 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 47 | 48 | client_models = { 49 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 50 | } 51 | self._serialize = Serializer(client_models) 52 | self._serialize.client_side_validation = False 53 | self._deserialize = Deserializer(client_models) 54 | 55 | self.images = ImagesOperations( 56 | self._client, self._config, self._serialize, self._deserialize 57 | ) 58 | 59 | def close(self): 60 | # type: () -> None 61 | self._client.close() 62 | 63 | def __enter__(self): 64 | # type: () -> ImageSearchClient 65 | self._client.__enter__() 66 | return self 67 | 68 | def __exit__(self, *exc_details): 69 | # type: (Any) -> None 70 | self._client.__exit__(*exc_details) 71 | -------------------------------------------------------------------------------- /sdk/ImageSearch/image_search_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._image_search_client import ImageSearchClient 11 | 12 | __all__ = ["ImageSearchClient"] 13 | -------------------------------------------------------------------------------- /sdk/ImageSearch/image_search_client/aio/_image_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import ImageSearchClientConfiguration 20 | from .operations import ImagesOperations 21 | from .. import models 22 | 23 | 24 | class ImageSearchClient(object): 25 | """The Image Search API lets you send a search query to Bing and get back a list of relevant images. This section provides technical details about the query parameters and headers that you use to request images and the JSON response objects that contain them. For examples that show how to make requests, see `Searching the Web for Images `_. 26 | 27 | :ivar images: ImagesOperations operations 28 | :vartype images: image_search_client.aio.operations.ImagesOperations 29 | :param credential: Credential needed for the client to connect to Azure. 30 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 31 | :param str base_url: Service URL 32 | """ 33 | 34 | def __init__( 35 | self, 36 | credential: "AsyncTokenCredential", 37 | base_url: Optional[str] = None, 38 | **kwargs: Any 39 | ) -> None: 40 | if not base_url: 41 | base_url = "https://api.bing.microsoft.com/v7.0" 42 | self._config = ImageSearchClientConfiguration(credential, **kwargs) 43 | self._client = AsyncPipelineClient( 44 | base_url=base_url, config=self._config, **kwargs 45 | ) 46 | 47 | client_models = { 48 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 49 | } 50 | self._serialize = Serializer(client_models) 51 | self._serialize.client_side_validation = False 52 | self._deserialize = Deserializer(client_models) 53 | 54 | self.images = ImagesOperations( 55 | self._client, self._config, self._serialize, self._deserialize 56 | ) 57 | 58 | async def close(self) -> None: 59 | await self._client.close() 60 | 61 | async def __aenter__(self) -> "ImageSearchClient": 62 | await self._client.__aenter__() 63 | return self 64 | 65 | async def __aexit__(self, *exc_details) -> None: 66 | await self._client.__aexit__(*exc_details) 67 | -------------------------------------------------------------------------------- /sdk/ImageSearch/image_search_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._images_operations import ImagesOperations 11 | 12 | __all__ = [ 13 | "ImagesOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/ImageSearch/image_search_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._images_operations import ImagesOperations 11 | 12 | __all__ = [ 13 | "ImagesOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/ImageSearch/image_search_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /sdk/ImageSearch/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/ImageSearch/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/ImageSearch/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-imagesearch" 13 | PACKAGE_PPRINT_NAME = "Image Search" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "image_search_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/NewsSearch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/NewsSearch/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing News Search SDK for Python 4 | 5 | This is the Microsoft Bing News Search Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [News Search](https://docs.microsoft.com/en-us/bing/search-apis/bing-news-search/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/NewsSearch/news_search_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._news_search_client import NewsSearchClient 11 | 12 | __all__ = ["NewsSearchClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/NewsSearch/news_search_client/_news_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from typing import Any, Optional 18 | 19 | from azure.core.credentials import TokenCredential 20 | 21 | from ._configuration import NewsSearchClientConfiguration 22 | from .operations import NewsOperations 23 | from . import models 24 | 25 | 26 | class NewsSearchClient(object): 27 | """The News Search API lets you send a search query to Bing and get back a list of news that are relevant to the search query. This section provides technical details about the query parameters and headers that you use to request news and the JSON response objects that contain them. For examples that show how to make requests, see `Searching the web for news `_. 28 | 29 | :ivar news: NewsOperations operations 30 | :vartype news: news_search_client.operations.NewsOperations 31 | :param credential: Credential needed for the client to connect to Azure. 32 | :type credential: None 33 | :param str base_url: Service URL 34 | """ 35 | 36 | def __init__( 37 | self, 38 | credential, # type: none 39 | base_url=None, # type: Optional[str] 40 | **kwargs # type: Any 41 | ): 42 | # type: (...) -> None 43 | if not base_url: 44 | base_url = "https://api.bing.microsoft.com/v7.0" 45 | self._config = NewsSearchClientConfiguration(credential, **kwargs) 46 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 47 | 48 | client_models = { 49 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 50 | } 51 | self._serialize = Serializer(client_models) 52 | self._serialize.client_side_validation = False 53 | self._deserialize = Deserializer(client_models) 54 | 55 | self.news = NewsOperations( 56 | self._client, self._config, self._serialize, self._deserialize 57 | ) 58 | 59 | def close(self): 60 | # type: () -> None 61 | self._client.close() 62 | 63 | def __enter__(self): 64 | # type: () -> NewsSearchClient 65 | self._client.__enter__() 66 | return self 67 | 68 | def __exit__(self, *exc_details): 69 | # type: (Any) -> None 70 | self._client.__exit__(*exc_details) 71 | -------------------------------------------------------------------------------- /sdk/NewsSearch/news_search_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._news_search_client import NewsSearchClient 11 | 12 | __all__ = ["NewsSearchClient"] 13 | -------------------------------------------------------------------------------- /sdk/NewsSearch/news_search_client/aio/_news_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import NewsSearchClientConfiguration 20 | from .operations import NewsOperations 21 | from .. import models 22 | 23 | 24 | class NewsSearchClient(object): 25 | """The News Search API lets you send a search query to Bing and get back a list of news that are relevant to the search query. This section provides technical details about the query parameters and headers that you use to request news and the JSON response objects that contain them. For examples that show how to make requests, see `Searching the web for news `_. 26 | 27 | :ivar news: NewsOperations operations 28 | :vartype news: news_search_client.aio.operations.NewsOperations 29 | :param credential: Credential needed for the client to connect to Azure. 30 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 31 | :param str base_url: Service URL 32 | """ 33 | 34 | def __init__( 35 | self, 36 | credential: "AsyncTokenCredential", 37 | base_url: Optional[str] = None, 38 | **kwargs: Any 39 | ) -> None: 40 | if not base_url: 41 | base_url = "https://api.bing.microsoft.com/v7.0" 42 | self._config = NewsSearchClientConfiguration(credential, **kwargs) 43 | self._client = AsyncPipelineClient( 44 | base_url=base_url, config=self._config, **kwargs 45 | ) 46 | 47 | client_models = { 48 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 49 | } 50 | self._serialize = Serializer(client_models) 51 | self._serialize.client_side_validation = False 52 | self._deserialize = Deserializer(client_models) 53 | 54 | self.news = NewsOperations( 55 | self._client, self._config, self._serialize, self._deserialize 56 | ) 57 | 58 | async def close(self) -> None: 59 | await self._client.close() 60 | 61 | async def __aenter__(self) -> "NewsSearchClient": 62 | await self._client.__aenter__() 63 | return self 64 | 65 | async def __aexit__(self, *exc_details) -> None: 66 | await self._client.__aexit__(*exc_details) 67 | -------------------------------------------------------------------------------- /sdk/NewsSearch/news_search_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._news_operations import NewsOperations 11 | 12 | __all__ = [ 13 | "NewsOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/NewsSearch/news_search_client/models/_news_search_client_enums.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from enum import Enum, EnumMeta 11 | from six import with_metaclass 12 | 13 | 14 | class _CaseInsensitiveEnumMeta(EnumMeta): 15 | def __getitem__(self, name): 16 | return super().__getitem__(name.upper()) 17 | 18 | def __getattr__(cls, name): 19 | """Return the enum member matching `name` 20 | We use __getattr__ instead of descriptors or inserting into the enum 21 | class' __dict__ in order to support `name` and `value` being both 22 | properties for enum members (which live in the class' __dict__) and 23 | enum members themselves. 24 | """ 25 | try: 26 | return cls._member_map_[name.upper()] 27 | except KeyError: 28 | raise AttributeError(name) 29 | 30 | 31 | class ErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 32 | """The error code that identifies the category of error.""" 33 | 34 | NONE = "None" 35 | SERVER_ERROR = "ServerError" 36 | INVALID_REQUEST = "InvalidRequest" 37 | RATE_LIMIT_EXCEEDED = "RateLimitExceeded" 38 | INVALID_AUTHORIZATION = "InvalidAuthorization" 39 | INSUFFICIENT_AUTHORIZATION = "InsufficientAuthorization" 40 | 41 | 42 | class ErrorSubCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 43 | """The error code that further helps to identify the error.""" 44 | 45 | UNEXPECTED_ERROR = "UnexpectedError" 46 | RESOURCE_ERROR = "ResourceError" 47 | NOT_IMPLEMENTED = "NotImplemented" 48 | PARAMETER_MISSING = "ParameterMissing" 49 | PARAMETER_INVALID_VALUE = "ParameterInvalidValue" 50 | HTTP_NOT_ALLOWED = "HttpNotAllowed" 51 | BLOCKED = "Blocked" 52 | AUTHORIZATION_MISSING = "AuthorizationMissing" 53 | AUTHORIZATION_REDUNDANCY = "AuthorizationRedundancy" 54 | AUTHORIZATION_DISABLED = "AuthorizationDisabled" 55 | AUTHORIZATION_EXPIRED = "AuthorizationExpired" 56 | 57 | 58 | class Freshness(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 59 | 60 | DAY = "Day" 61 | WEEK = "Week" 62 | MONTH = "Month" 63 | 64 | 65 | class SafeSearch(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 66 | 67 | OFF = "Off" 68 | MODERATE = "Moderate" 69 | STRICT = "Strict" 70 | 71 | 72 | class TextFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 73 | 74 | RAW = "Raw" 75 | HTML = "Html" 76 | 77 | 78 | class XBingApisSDK(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 79 | 80 | TRUE = "true" 81 | -------------------------------------------------------------------------------- /sdk/NewsSearch/news_search_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._news_operations import NewsOperations 11 | 12 | __all__ = [ 13 | "NewsOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/NewsSearch/news_search_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /sdk/NewsSearch/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/NewsSearch/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/NewsSearch/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-newssearch" 13 | PACKAGE_PPRINT_NAME = "News Search" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "news_search_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/SpellCheck/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/SpellCheck/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Spell Check SDK for Python 4 | 5 | This is the Microsoft Bing Spell Check Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Spell Check](https://docs.microsoft.com/en-us/bing/search-apis/bing-spell-check/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/SpellCheck/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/SpellCheck/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/SpellCheck/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-spellcheck" 13 | PACKAGE_PPRINT_NAME = "Spell Check" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "spell_check_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._spell_check_client import SpellCheckClient 11 | 12 | __all__ = ["SpellCheckClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/_spell_check_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from typing import Any, Optional 18 | 19 | from azure.core.credentials import TokenCredential 20 | 21 | from ._configuration import SpellCheckClientConfiguration 22 | from .operations import SpellCheckClientOperationsMixin 23 | from . import models 24 | 25 | 26 | class SpellCheckClient(SpellCheckClientOperationsMixin): 27 | """The Spell Check API - V7 lets you check a text string for spelling and grammar errors. 28 | 29 | :param credential: Credential needed for the client to connect to Azure. 30 | :type credential: ~azure.core.credentials.TokenCredential 31 | :param str base_url: Service URL 32 | """ 33 | 34 | def __init__( 35 | self, 36 | credential, # type: "TokenCredential" 37 | base_url=None, # type: Optional[str] 38 | **kwargs # type: Any 39 | ): 40 | # type: (...) -> None 41 | if not base_url: 42 | base_url = "https://api.bing.microsoft.com/v7.0" 43 | self._config = SpellCheckClientConfiguration(credential, **kwargs) 44 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 45 | 46 | client_models = { 47 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 48 | } 49 | self._serialize = Serializer(client_models) 50 | self._serialize.client_side_validation = False 51 | self._deserialize = Deserializer(client_models) 52 | 53 | def close(self): 54 | # type: () -> None 55 | self._client.close() 56 | 57 | def __enter__(self): 58 | # type: () -> SpellCheckClient 59 | self._client.__enter__() 60 | return self 61 | 62 | def __exit__(self, *exc_details): 63 | # type: (Any) -> None 64 | self._client.__exit__(*exc_details) 65 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._spell_check_client import SpellCheckClient 11 | 12 | __all__ = ["SpellCheckClient"] 13 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/aio/_spell_check_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import SpellCheckClientConfiguration 20 | from .operations import SpellCheckClientOperationsMixin 21 | from .. import models 22 | 23 | 24 | class SpellCheckClient(SpellCheckClientOperationsMixin): 25 | """The Spell Check API - V7 lets you check a text string for spelling and grammar errors. 26 | 27 | :param credential: Credential needed for the client to connect to Azure. 28 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 29 | :param str base_url: Service URL 30 | """ 31 | 32 | def __init__( 33 | self, 34 | credential: "AsyncTokenCredential", 35 | base_url: Optional[str] = None, 36 | **kwargs: Any 37 | ) -> None: 38 | if not base_url: 39 | base_url = "https://api.bing.microsoft.com/v7.0" 40 | self._config = SpellCheckClientConfiguration(credential, **kwargs) 41 | self._client = AsyncPipelineClient( 42 | base_url=base_url, config=self._config, **kwargs 43 | ) 44 | 45 | client_models = { 46 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 47 | } 48 | self._serialize = Serializer(client_models) 49 | self._serialize.client_side_validation = False 50 | self._deserialize = Deserializer(client_models) 51 | 52 | async def close(self) -> None: 53 | await self._client.close() 54 | 55 | async def __aenter__(self) -> "SpellCheckClient": 56 | await self._client.__aenter__() 57 | return self 58 | 59 | async def __aexit__(self, *exc_details) -> None: 60 | await self._client.__aexit__(*exc_details) 61 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._spell_check_client_operations import SpellCheckClientOperationsMixin 11 | 12 | __all__ = [ 13 | "SpellCheckClientOperationsMixin", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | try: 11 | from ._models_py3 import Answer 12 | from ._models_py3 import Error 13 | from ._models_py3 import ErrorResponse 14 | from ._models_py3 import Identifiable 15 | from ._models_py3 import Response 16 | from ._models_py3 import ResponseBase 17 | from ._models_py3 import SpellCheck 18 | from ._models_py3 import SpellingFlaggedToken 19 | from ._models_py3 import SpellingTokenSuggestion 20 | except (SyntaxError, ImportError): 21 | from ._models import Answer # type: ignore 22 | from ._models import Error # type: ignore 23 | from ._models import ErrorResponse # type: ignore 24 | from ._models import Identifiable # type: ignore 25 | from ._models import Response # type: ignore 26 | from ._models import ResponseBase # type: ignore 27 | from ._models import SpellCheck # type: ignore 28 | from ._models import SpellingFlaggedToken # type: ignore 29 | from ._models import SpellingTokenSuggestion # type: ignore 30 | 31 | from ._spell_check_client_enums import ( 32 | ActionType, 33 | ErrorCode, 34 | ErrorSubCode, 35 | ErrorType, 36 | Mode, 37 | XBingApisSDK, 38 | ) 39 | 40 | __all__ = [ 41 | "Answer", 42 | "Error", 43 | "ErrorResponse", 44 | "Identifiable", 45 | "Response", 46 | "ResponseBase", 47 | "SpellCheck", 48 | "SpellingFlaggedToken", 49 | "SpellingTokenSuggestion", 50 | "ActionType", 51 | "ErrorCode", 52 | "ErrorSubCode", 53 | "ErrorType", 54 | "Mode", 55 | "XBingApisSDK", 56 | ] 57 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/models/_spell_check_client_enums.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from enum import Enum, EnumMeta 11 | from six import with_metaclass 12 | 13 | 14 | class _CaseInsensitiveEnumMeta(EnumMeta): 15 | def __getitem__(self, name): 16 | return super().__getitem__(name.upper()) 17 | 18 | def __getattr__(cls, name): 19 | """Return the enum member matching `name` 20 | We use __getattr__ instead of descriptors or inserting into the enum 21 | class' __dict__ in order to support `name` and `value` being both 22 | properties for enum members (which live in the class' __dict__) and 23 | enum members themselves. 24 | """ 25 | try: 26 | return cls._member_map_[name.upper()] 27 | except KeyError: 28 | raise AttributeError(name) 29 | 30 | 31 | class ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 32 | 33 | EDIT = "Edit" 34 | LOAD = "Load" 35 | 36 | 37 | class ErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 38 | """The error code that identifies the category of error.""" 39 | 40 | NONE = "None" 41 | SERVER_ERROR = "ServerError" 42 | INVALID_REQUEST = "InvalidRequest" 43 | RATE_LIMIT_EXCEEDED = "RateLimitExceeded" 44 | INVALID_AUTHORIZATION = "InvalidAuthorization" 45 | INSUFFICIENT_AUTHORIZATION = "InsufficientAuthorization" 46 | 47 | 48 | class ErrorSubCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 49 | """The error code that further helps to identify the error.""" 50 | 51 | UNEXPECTED_ERROR = "UnexpectedError" 52 | RESOURCE_ERROR = "ResourceError" 53 | NOT_IMPLEMENTED = "NotImplemented" 54 | PARAMETER_MISSING = "ParameterMissing" 55 | PARAMETER_INVALID_VALUE = "ParameterInvalidValue" 56 | HTTP_NOT_ALLOWED = "HttpNotAllowed" 57 | BLOCKED = "Blocked" 58 | AUTHORIZATION_MISSING = "AuthorizationMissing" 59 | AUTHORIZATION_REDUNDANCY = "AuthorizationRedundancy" 60 | AUTHORIZATION_DISABLED = "AuthorizationDisabled" 61 | AUTHORIZATION_EXPIRED = "AuthorizationExpired" 62 | 63 | 64 | class ErrorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 65 | 66 | UNKNOWN_TOKEN = "UnknownToken" 67 | REPEATED_TOKEN = "RepeatedToken" 68 | 69 | 70 | class Mode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 71 | 72 | PROOF = "proof" 73 | SPELL = "spell" 74 | 75 | 76 | class XBingApisSDK(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): 77 | 78 | TRUE = "true" 79 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._spell_check_client_operations import SpellCheckClientOperationsMixin 11 | 12 | __all__ = [ 13 | "SpellCheckClientOperationsMixin", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/SpellCheck/spell_check_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /sdk/VideoSearch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/VideoSearch/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Video Search SDK for Python 4 | 5 | This is the Microsoft Bing Video Search Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Video Search](https://docs.microsoft.com/en-us/bing/search-apis/bing-video-search/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/VideoSearch/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/VideoSearch/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/VideoSearch/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-videosearch" 13 | PACKAGE_PPRINT_NAME = "Video Search" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "video_search_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/VideoSearch/video_search_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._video_search_client import VideoSearchClient 11 | 12 | __all__ = ["VideoSearchClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/VideoSearch/video_search_client/_video_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from typing import Any, Optional 18 | 19 | from azure.core.credentials import TokenCredential 20 | 21 | from ._configuration import VideoSearchClientConfiguration 22 | from .operations import VideosOperations 23 | from . import models 24 | 25 | 26 | class VideoSearchClient(object): 27 | """The Video Search API lets you search on Bing for video that are relevant to the user's search query, for insights about a video or for videos that are trending based on search requests made by others. This section provides technical details about the query parameters and headers that you use to request videos and the JSON response objects that contain them. For examples that show how to make requests, see `Searching the Web for Videos `_. 28 | 29 | :ivar videos: VideosOperations operations 30 | :vartype videos: video_search_client.operations.VideosOperations 31 | :param credential: Credential needed for the client to connect to Azure. 32 | :type credential: ~azure.core.credentials.TokenCredential 33 | :param str base_url: Service URL 34 | """ 35 | 36 | def __init__( 37 | self, 38 | credential, # type: "TokenCredential" 39 | base_url=None, # type: Optional[str] 40 | **kwargs # type: Any 41 | ): 42 | # type: (...) -> None 43 | if not base_url: 44 | base_url = "https://api.bing.microsoft.com/v7.0" 45 | self._config = VideoSearchClientConfiguration(credential, **kwargs) 46 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 47 | 48 | client_models = { 49 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 50 | } 51 | self._serialize = Serializer(client_models) 52 | self._serialize.client_side_validation = False 53 | self._deserialize = Deserializer(client_models) 54 | 55 | self.videos = VideosOperations( 56 | self._client, self._config, self._serialize, self._deserialize 57 | ) 58 | 59 | def close(self): 60 | # type: () -> None 61 | self._client.close() 62 | 63 | def __enter__(self): 64 | # type: () -> VideoSearchClient 65 | self._client.__enter__() 66 | return self 67 | 68 | def __exit__(self, *exc_details): 69 | # type: (Any) -> None 70 | self._client.__exit__(*exc_details) 71 | -------------------------------------------------------------------------------- /sdk/VideoSearch/video_search_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._video_search_client import VideoSearchClient 11 | 12 | __all__ = ["VideoSearchClient"] 13 | -------------------------------------------------------------------------------- /sdk/VideoSearch/video_search_client/aio/_video_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import VideoSearchClientConfiguration 20 | from .operations import VideosOperations 21 | from .. import models 22 | 23 | 24 | class VideoSearchClient(object): 25 | """The Video Search API lets you search on Bing for video that are relevant to the user's search query, for insights about a video or for videos that are trending based on search requests made by others. This section provides technical details about the query parameters and headers that you use to request videos and the JSON response objects that contain them. For examples that show how to make requests, see `Searching the Web for Videos `_. 26 | 27 | :ivar videos: VideosOperations operations 28 | :vartype videos: video_search_client.aio.operations.VideosOperations 29 | :param credential: Credential needed for the client to connect to Azure. 30 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 31 | :param str base_url: Service URL 32 | """ 33 | 34 | def __init__( 35 | self, 36 | credential: "AsyncTokenCredential", 37 | base_url: Optional[str] = None, 38 | **kwargs: Any 39 | ) -> None: 40 | if not base_url: 41 | base_url = "https://api.bing.microsoft.com/v7.0" 42 | self._config = VideoSearchClientConfiguration(credential, **kwargs) 43 | self._client = AsyncPipelineClient( 44 | base_url=base_url, config=self._config, **kwargs 45 | ) 46 | 47 | client_models = { 48 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 49 | } 50 | self._serialize = Serializer(client_models) 51 | self._serialize.client_side_validation = False 52 | self._deserialize = Deserializer(client_models) 53 | 54 | self.videos = VideosOperations( 55 | self._client, self._config, self._serialize, self._deserialize 56 | ) 57 | 58 | async def close(self) -> None: 59 | await self._client.close() 60 | 61 | async def __aenter__(self) -> "VideoSearchClient": 62 | await self._client.__aenter__() 63 | return self 64 | 65 | async def __aexit__(self, *exc_details) -> None: 66 | await self._client.__aexit__(*exc_details) 67 | -------------------------------------------------------------------------------- /sdk/VideoSearch/video_search_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._videos_operations import VideosOperations 11 | 12 | __all__ = [ 13 | "VideosOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/VideoSearch/video_search_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._videos_operations import VideosOperations 11 | 12 | __all__ = [ 13 | "VideosOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/VideoSearch/video_search_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /sdk/VisualSearch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/VisualSearch/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Visual Search SDK for Python 4 | 5 | This is the Microsoft Bing Visual Search Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Visual Search](https://docs.microsoft.com/en-us/bing/search-apis/bing-visual-search/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/VisualSearch/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/VisualSearch/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/VisualSearch/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-visualsearch" 13 | PACKAGE_PPRINT_NAME = "Visual Search" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "visual_search_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/VisualSearch/visual_search_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._visual_search_client import VisualSearchClient 11 | 12 | __all__ = ["VisualSearchClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/VisualSearch/visual_search_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._visual_search_client import VisualSearchClient 11 | 12 | __all__ = ["VisualSearchClient"] 13 | -------------------------------------------------------------------------------- /sdk/VisualSearch/visual_search_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._images_operations import ImagesOperations 11 | 12 | __all__ = [ 13 | "ImagesOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/VisualSearch/visual_search_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._images_operations import ImagesOperations 11 | 12 | __all__ = [ 13 | "ImagesOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/VisualSearch/visual_search_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /sdk/WebSearch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /sdk/WebSearch/README.md: -------------------------------------------------------------------------------- 1 | 3 | ## Microsoft Bing Web Search SDK for Python 4 | 5 | This is the Microsoft Bing Web Search Client Library. 6 | 7 | This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. 8 | 9 | 10 | ## Usage 11 | 12 | For more, see [Web Search](https://docs.microsoft.com/en-us/bing/search-apis/bing-web-search/overview) 13 | on docs.microsoft.com. 14 | 15 | ## Provide Feedback 16 | 17 | If you encounter any bugs or have suggestions, please file an issue in 18 | the [Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues) 19 | section of the project. 20 | 21 | -------------------------------------------------------------------------------- /sdk/WebSearch/pyproject.toml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [build-system] 5 | requires = [ 6 | "setuptools>=42", 7 | "wheel", 8 | "msrest>=0.5.0", 9 | "msrestazure>=0.4.32,<2.0.0", 10 | "azure-common~=1.1", 11 | ] 12 | build-backend = "setuptools.build_meta" 13 | -------------------------------------------------------------------------------- /sdk/WebSearch/setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | [bdist_wheel] 5 | universal=1 -------------------------------------------------------------------------------- /sdk/WebSearch/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) Microsoft Corporation. 4 | # Licensed under the MIT License. 5 | 6 | import re 7 | import os.path 8 | from io import open 9 | from setuptools import find_packages, setup 10 | 11 | # Change the PACKAGE_NAME only to change folder and different name 12 | PACKAGE_NAME = "microsoft-bing-websearch" 13 | PACKAGE_PPRINT_NAME = "Web Search" 14 | 15 | # a-b-c => a/b/c 16 | package_folder_path = "web_search_client" 17 | # a-b-c => a.b.c 18 | namespace_name = PACKAGE_NAME.replace("-", ".") 19 | 20 | # azure v0.x is not compatible with this package 21 | # azure v0.x used to have a __version__ attribute (newer versions don't) 22 | try: 23 | import azure 24 | 25 | try: 26 | ver = azure.__version__ 27 | raise Exception( 28 | "This package is incompatible with azure=={}. ".format(ver) 29 | + 'Uninstall it with "pip uninstall azure".' 30 | ) 31 | except AttributeError: 32 | pass 33 | except ImportError: 34 | pass 35 | 36 | # Version extraction inspired from 'requests' 37 | with open(os.path.join(package_folder_path, "version.py"), "r") as fd: 38 | version = re.search( 39 | r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE 40 | ).group(1) 41 | 42 | if not version: 43 | raise RuntimeError("Cannot find version information") 44 | 45 | with open("README.md", encoding="utf-8") as f: 46 | readme = f.read() 47 | 48 | 49 | setup( 50 | name=PACKAGE_NAME, 51 | version=version, 52 | description="Microsoft Bing {} Client Library for Python".format( 53 | PACKAGE_PPRINT_NAME 54 | ), 55 | long_description=readme + "\n\n", 56 | long_description_content_type="text/markdown", 57 | license="MIT License", 58 | author="Microsoft Corporation", 59 | author_email="v-mariamal@microsoft.com", 60 | url="https://github.com/Azure/azure-sdk-for-python", 61 | classifiers=[ 62 | "Development Status :: 4 - Beta", 63 | "Programming Language :: Python", 64 | "Programming Language :: Python :: 2", 65 | "Programming Language :: Python :: 2.7", 66 | "Programming Language :: Python :: 3", 67 | "Programming Language :: Python :: 3.5", 68 | "Programming Language :: Python :: 3.6", 69 | "Programming Language :: Python :: 3.7", 70 | "Programming Language :: Python :: 3.8", 71 | "License :: OSI Approved :: MIT License", 72 | ], 73 | zip_safe=False, 74 | packages=find_packages( 75 | exclude=[ 76 | "tests", 77 | # Exclude packages that will be covered by PEP420 or nspkg 78 | "azure", 79 | ] 80 | ), 81 | install_requires=[ 82 | "msrest>=0.5.0", 83 | "msrestazure>=0.4.32,<2.0.0", 84 | "azure-common~=1.1", 85 | ], 86 | ) 87 | -------------------------------------------------------------------------------- /sdk/WebSearch/web_search_client/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._web_search_client import WebSearchClient 11 | 12 | __all__ = ["WebSearchClient"] 13 | 14 | try: 15 | from ._patch import patch_sdk # type: ignore 16 | 17 | patch_sdk() 18 | except ImportError: 19 | pass 20 | -------------------------------------------------------------------------------- /sdk/WebSearch/web_search_client/_web_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import TYPE_CHECKING 11 | 12 | from azure.core import PipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from typing import Any, Optional 18 | 19 | from azure.core.credentials import TokenCredential 20 | 21 | from ._configuration import WebSearchClientConfiguration 22 | from .operations import WebOperations 23 | from . import models 24 | 25 | 26 | class WebSearchClient(object): 27 | """The Web Search API lets you send a search query to Bing and get back search results that include links to webpages, images, and more. 28 | 29 | :ivar web: WebOperations operations 30 | :vartype web: web_search_client.operations.WebOperations 31 | :param credential: Credential needed for the client to connect to Azure. 32 | :type credentials: None 33 | :param str base_url: Service URL 34 | """ 35 | 36 | def __init__( 37 | self, 38 | credential, # type: none 39 | base_url=None, # type: Optional[str] 40 | **kwargs # type: Any 41 | ): 42 | # type: (...) -> None 43 | if not base_url: 44 | base_url = "https://api.bing.microsoft.com/v7.0" 45 | self._config = WebSearchClientConfiguration(credential, **kwargs) 46 | self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) 47 | 48 | client_models = { 49 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 50 | } 51 | self._serialize = Serializer(client_models) 52 | self._serialize.client_side_validation = False 53 | self._deserialize = Deserializer(client_models) 54 | 55 | self.web = WebOperations( 56 | self._client, self._config, self._serialize, self._deserialize 57 | ) 58 | 59 | def close(self): 60 | # type: () -> None 61 | self._client.close() 62 | 63 | def __enter__(self): 64 | # type: () -> WebSearchClient 65 | self._client.__enter__() 66 | return self 67 | 68 | def __exit__(self, *exc_details): 69 | # type: (Any) -> None 70 | self._client.__exit__(*exc_details) 71 | -------------------------------------------------------------------------------- /sdk/WebSearch/web_search_client/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._web_search_client import WebSearchClient 11 | 12 | __all__ = ["WebSearchClient"] 13 | -------------------------------------------------------------------------------- /sdk/WebSearch/web_search_client/aio/_web_search_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from typing import Any, Optional, TYPE_CHECKING 11 | 12 | from azure.core import AsyncPipelineClient 13 | from msrest import Deserializer, Serializer 14 | 15 | if TYPE_CHECKING: 16 | # pylint: disable=unused-import,ungrouped-imports 17 | from azure.core.credentials_async import AsyncTokenCredential 18 | 19 | from ._configuration import WebSearchClientConfiguration 20 | from .operations import WebOperations 21 | from .. import models 22 | 23 | 24 | class WebSearchClient(object): 25 | """The Web Search API lets you send a search query to Bing and get back search results that include links to webpages, images, and more. 26 | 27 | :ivar web: WebOperations operations 28 | :vartype web: web_search_client.aio.operations.WebOperations 29 | :param credential: Credential needed for the client to connect to Azure. 30 | :type credential: ~azure.core.credentials_async.AsyncTokenCredential 31 | :param str base_url: Service URL 32 | """ 33 | 34 | def __init__( 35 | self, 36 | credential: "AsyncTokenCredential", 37 | base_url: Optional[str] = None, 38 | **kwargs: Any 39 | ) -> None: 40 | if not base_url: 41 | base_url = "https://api.bing.microsoft.com/v7.0" 42 | self._config = WebSearchClientConfiguration(credential, **kwargs) 43 | self._client = AsyncPipelineClient( 44 | base_url=base_url, config=self._config, **kwargs 45 | ) 46 | 47 | client_models = { 48 | k: v for k, v in models.__dict__.items() if isinstance(v, type) 49 | } 50 | self._serialize = Serializer(client_models) 51 | self._serialize.client_side_validation = False 52 | self._deserialize = Deserializer(client_models) 53 | 54 | self.web = WebOperations( 55 | self._client, self._config, self._serialize, self._deserialize 56 | ) 57 | 58 | async def close(self) -> None: 59 | await self._client.close() 60 | 61 | async def __aenter__(self) -> "WebSearchClient": 62 | await self._client.__aenter__() 63 | return self 64 | 65 | async def __aexit__(self, *exc_details) -> None: 66 | await self._client.__aexit__(*exc_details) 67 | -------------------------------------------------------------------------------- /sdk/WebSearch/web_search_client/aio/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._web_operations import WebOperations 11 | 12 | __all__ = [ 13 | "WebOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/WebSearch/web_search_client/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # coding=utf-8 5 | # -------------------------------------------------------------------------- 6 | # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator}) 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 | # -------------------------------------------------------------------------- 9 | 10 | from ._web_operations import WebOperations 11 | 12 | __all__ = [ 13 | "WebOperations", 14 | ] 15 | -------------------------------------------------------------------------------- /sdk/WebSearch/web_search_client/py.typed: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | # Marker file for PEP 561. -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | 3 | # Tests folder 4 | 5 | This folder is just the automatic testing system, to be sure that this sample is always up-to-date with the 6 | latest update of the mentioned package. 7 | 8 | This folder is a generic test launcher and not part of the samples themselves. 9 | -------------------------------------------------------------------------------- /tests/rest/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /tests/rest/test_samples_visual_search.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Tests for Visual Search REST samples.""" 4 | 5 | import os 6 | import unittest 7 | 8 | import dotenv 9 | from requests import JSONDecodeError 10 | 11 | from samples.rest.bing_visual_search_v7 import visual_search_basic 12 | 13 | 14 | class VisualSearchRESTSamplesTest(unittest.TestCase): 15 | """Class for testing REST samples.""" 16 | 17 | @classmethod 18 | def setUpClass(cls): 19 | cls.dotenv = dotenv.dotenv_values() 20 | subscription_key_env_var_name = "BING_SEARCH_V7_VISUAL_SEARCH_SUBSCRIPTION_KEY" 21 | cls.subscription_key = cls.dotenv.get( 22 | subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name) 23 | ) 24 | 25 | def test_visual_search_subscription_key_not_empty(self): 26 | """Test that the subscription key is defined in the environment""" 27 | self.assertIsNotNone(self.subscription_key) 28 | self.assertNotEqual(self.subscription_key, "") 29 | 30 | def test_visual_search_basic(self): 31 | """Test the basic REST call to Visual Search API""" 32 | response = visual_search_basic(subscription_key=self.subscription_key) 33 | self.assertEqual(response.status_code, 200) 34 | 35 | def test_visual_search_response_is_json(self): 36 | """Test that Visual Search API returns responses in JSON format""" 37 | response = visual_search_basic(subscription_key=self.subscription_key) 38 | try: 39 | response.json() 40 | except JSONDecodeError: 41 | self.fail( 42 | "Failed to decode response as JSON, check if valid JSON is returned" 43 | ) 44 | 45 | def test_visual_search_no_auth(self): 46 | """Test that Visual Search API returns 401 if authorization fails""" 47 | response = visual_search_basic(subscription_key="") 48 | self.assertEqual(response.status_code, 401) 49 | 50 | def test_visual_search_response_object_type(self): 51 | """Test that Visual Search API returns the correct type hint""" 52 | response = visual_search_basic(subscription_key=self.subscription_key) 53 | try: 54 | self.assertEqual(response.json()["_type"], "ImageKnowledge") 55 | except KeyError: 56 | self.fail("The response object doesn't include the type hint") 57 | 58 | def test_visual_search_response_object_structure(self): 59 | """Test that Visual Search API responses follow the correct structure""" 60 | response = visual_search_basic(subscription_key=self.subscription_key) 61 | response_json = response.json() 62 | self.assertIn("image", response_json) 63 | self.assertIn("imageInsightsToken", response_json["image"]) 64 | try: 65 | self.assertGreater(len(response_json["tags"]), 0) 66 | except KeyError: 67 | self.fail("The response object doesn't include any visual results") 68 | 69 | 70 | if __name__ == "__main__": 71 | unittest.main(verbosity=1) 72 | -------------------------------------------------------------------------------- /tests/test-requirements.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | azure-devtools 5 | mock;python_version<="2.7" 6 | nose 7 | six 8 | -------------------------------------------------------------------------------- /tests/test_example.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import os.path 5 | import unittest 6 | 7 | try: 8 | from unittest import mock 9 | except ImportError: 10 | import mock 11 | 12 | 13 | from example import run_all_samples 14 | 15 | 16 | TEST_CONFIG = os.path.join(os.path.dirname(__file__), "testsettings.cfg") 17 | 18 | 19 | class SearchExampleTest: 20 | """Simple test launcher for the sample. 21 | 22 | Be sure to set the two environment vaiables before staring it live. 23 | """ 24 | 25 | def test_example(self): 26 | if self.in_recording: 27 | run_all_samples() 28 | else: 29 | with mock.patch.dict( 30 | "os.environ", 31 | { 32 | "ENTITYSEARCH_SUBSCRIPTION_KEY": "00000000000000000000000000", 33 | "WEBSEARCH_SUBSCRIPTION_KEY": "00000000000000000000000000", 34 | "SPELLCHECK_SUBSCRIPTION_KEY": "00000000000000000000000000", 35 | "CUSTOMSEARCH_SUBSCRIPTION_KEY": "00000000000000000000000000", 36 | "IMAGESEARCH_SUBSCRIPTION_KEY": "00000000000000000000000000", 37 | "NEWSSEARCH_SUBSCRIPTION_KEY": "00000000000000000000000000", 38 | "WEBSEARCH_SUBSCRIPTION_KEY": "00000000000000000000000000", 39 | "CUSTOMVISION_TRAINING_KEY": "00000000000000000000000000", 40 | "CUSTOMVISION_PREDICTION_KEY": "00000000000000000000000000", 41 | }, 42 | ): 43 | run_all_samples() 44 | 45 | 46 | if __name__ == "__main__": 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /tests/testsettings.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | live-mode: false 5 | -------------------------------------------------------------------------------- /tools.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | """This file is just a sample launcher code. 5 | 6 | """ 7 | 8 | try: 9 | from inspect import getfullargspec as get_arg_spec 10 | except ImportError: 11 | from inspect import getargspec as get_arg_spec 12 | import os 13 | import sys 14 | import types 15 | 16 | 17 | class SubscriptionKeyError(Exception): 18 | pass 19 | 20 | 21 | def start_sample(func, subscription_key): 22 | """Start the function and show its doc on output.""" 23 | print("Sample:", func.__doc__, "\n") 24 | func(subscription_key) 25 | print("\n\n") 26 | 27 | 28 | def execute_samples(module_globals, key_env_variable): 29 | """Execute samples based on a dict """ 30 | try: 31 | subscription_key = key_env_variable 32 | except KeyError: 33 | raise SubscriptionKeyError( 34 | "You need to either set the {} env variable.".format(key_env_variable) 35 | ) 36 | 37 | for func in list(module_globals.values()): 38 | if not isinstance(func, types.FunctionType): 39 | continue 40 | args = get_arg_spec(func).args 41 | if "subscription_key" in args: 42 | start_sample(func, subscription_key) 43 | --------------------------------------------------------------------------------