-
Couldn't load subscription status.
- Fork 3
Add HttpClientFactory and update Graph client to use it #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b23cc04
Add Http client factory
Ndiritu 4c3fa35
Update Graph class to use HttpClientFactory
Ndiritu 0293b63
Remove proxy configuration from Graph, GraphRequest and GraphCollecti…
Ndiritu 7231294
Update copyright statement, class and interface php docs
Ndiritu b6cdb1a
Remove TODO comments
Ndiritu 3665dd2
Set the httpClient on a Graph client only through the constructor
Ndiritu 8762088
Make HttpClientFactory methods static
Ndiritu 719d50c
Undo Windows-style CRLF newlines added by editor
Ndiritu 4dc0e87
Update editorConfig to use Unix-style line endings (LF)
Ndiritu b95fc51
Restore GraphTest file to LF line endings
Ndiritu 2f161e0
Improve validation of national cloud urls
Ndiritu b044859
Fix GraphException toString() to use child exception class names if n…
Ndiritu bca9780
Add reference to Guzzle client configuration documentation
Ndiritu acd2855
Set default apiVersion and nationalCloud on Graph client if empty str…
Ndiritu 17bb389
Allow non-national cloud but valid hosts to be set as base URL of Gra…
Ndiritu f11850d
Improve base url and national cloud host validation
Ndiritu 20186f0
Change ClientInitialisationException to GraphClientException
Ndiritu 607d4e8
Renamed Graph to BaseClient
Ndiritu 13112b4
Refactor GraphRequest and GraphCollectionRequest constructors
Ndiritu bdd2ed5
Make base graph client abstract
Ndiritu efb8bc8
Fix initialisation of default graph request headers
Ndiritu bed36da
Update PSR-7 request object when headers or body is updated
Ndiritu 35ce3ff
Support PSR-18 and HttPlug async clients
Ndiritu 8a92a86
GraphCollectionRequest updates
Ndiritu 8583d17
Initialise http request object using init method in constructor
Ndiritu f1bb80f
Make national cloud host check case-insensitive
Ndiritu bfb37ca
Fix method access modifiers in AbstractGraphClient
Ndiritu 7606355
Merge pull request #4 from microsoftgraph/philip/feat/graph-request-c…
Ndiritu 018c427
Resolve merge conflicts
Ndiritu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,27 @@ | ||
| # top-most EditorConfig file | ||
| root = true | ||
|
|
||
| # All PHP files MUST use the Unix LF (linefeed) line ending. | ||
| # Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting. | ||
| # All PHP files MUST end with a single blank line. | ||
| # There MUST NOT be trailing whitespace at the end of non-blank lines. | ||
| [*] | ||
| charset = utf-8 | ||
| end_of_line = crlf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
|
|
||
| # PHP-Files, Composer.json, MD-Files | ||
| [{*.php,composer.json,*.md}] | ||
| indent_style = space | ||
| indent_size = 4 | ||
|
|
||
| # HTML-Files LESS-Files SASS-Files CSS-Files JS-Files JSON-Files | ||
| [{*.html,*.less,*.sass,*.css,*.js,*.json}] | ||
| indent_style = tab | ||
| indent_size = 4 | ||
|
|
||
| # Gitlab-CI, Travis-CI | ||
| [*.yml] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| # top-most EditorConfig file | ||
| root = true | ||
| # All PHP files MUST use the Unix LF (linefeed) line ending. | ||
| # Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting. | ||
| # All PHP files MUST end with a single blank line. | ||
| # There MUST NOT be trailing whitespace at the end of non-blank lines. | ||
| [*] | ||
| charset = utf-8 | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
| # PHP-Files, Composer.json, MD-Files | ||
| [{*.php,composer.json,*.md}] | ||
| indent_style = space | ||
| indent_size = 4 | ||
| # HTML-Files LESS-Files SASS-Files CSS-Files JS-Files JSON-Files | ||
| [{*.html,*.less,*.sass,*.css,*.js,*.json}] | ||
| indent_style = tab | ||
| indent_size = 4 | ||
| # Gitlab-CI, Travis-CI | ||
| [*.yml] | ||
| indent_style = space | ||
| indent_size = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,38 @@ | ||
| { | ||
| "name": "microsoft/microsoft-graph-core", | ||
| "type": "library", | ||
| "description": "The Microsoft Graph SDK for PHP", | ||
| "homepage": "https://developer.microsoft.com/en-us/graph", | ||
| "license": "MIT", | ||
| "authors": [ | ||
| { | ||
| "name": "Microsoft Graph Client Tooling", | ||
| "email": "graphtooling@service.microsoft.com", | ||
| "role": "Developer" | ||
| } | ||
| ], | ||
| "require": { | ||
| "php": "^8.0 || ^7.3", | ||
| "guzzlehttp/guzzle": "^6.0 || ^7.0", | ||
| "ext-json": "*" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^8.0 || ^9.0", | ||
| "mikey179/vfsstream": "^1.2", | ||
| "vimeo/psalm": "^4.8", | ||
| "microsoft/microsoft-graph": "^1.34" | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Microsoft\\Graph\\": "src/" | ||
| } | ||
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "Microsoft\\Graph\\Test\\": "tests/Functional/", | ||
| "Microsoft\\Graph\\Http\\Test\\": "tests/Http/" | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "name": "microsoft/microsoft-graph-core", | ||
| "type": "library", | ||
| "description": "The Microsoft Graph SDK for PHP", | ||
| "homepage": "https://developer.microsoft.com/en-us/graph", | ||
| "license": "MIT", | ||
| "authors": [ | ||
| { | ||
| "name": "Microsoft Graph Client Tooling", | ||
| "email": "graphtooling@service.microsoft.com", | ||
| "role": "Developer" | ||
| } | ||
| ], | ||
| "require": { | ||
| "php": "^8.0 || ^7.3", | ||
| "guzzlehttp/guzzle": "^7.0", | ||
| "php-http/httplug": "^2.2.0", | ||
| "php-http/guzzle7-adapter": "^1.0.0", | ||
| "ext-json": "*" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^8.0 || ^9.0", | ||
| "mikey179/vfsstream": "^1.2", | ||
| "vimeo/psalm": "^4.8", | ||
| "microsoft/microsoft-graph": "^1.34" | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Microsoft\\Graph\\": "src/" | ||
| } | ||
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "Microsoft\\Graph\\Test\\": "tests/Functional/", | ||
| "Microsoft\\Graph\\Http\\Test\\": "tests/Http/" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,4 +101,4 @@ public function value() | |
| { | ||
| return $this->_value; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <?php | ||
| /** | ||
| * Copyright (c) Microsoft Corporation. All Rights Reserved. | ||
| * Licensed under the MIT License. See License in the project root | ||
| * for license information. | ||
| */ | ||
|
|
||
| namespace Microsoft\Graph\Core; | ||
|
|
||
| use Microsoft\Graph\Http\GraphRequestUtil; | ||
|
|
||
| /** | ||
| * Class NationalCloud | ||
| * | ||
| * Defines Graph hosts for the various national clouds | ||
| * | ||
| * @package Microsoft\Graph\Core | ||
| * @copyright 2021 Microsoft Corporation | ||
| * @license https://opensource.org/licenses/MIT MIT License | ||
| * @link https://developer.microsoft.com/graph | ||
| */ | ||
| final class NationalCloud | ||
| { | ||
| const GLOBAL = "https://graph.microsoft.com"; | ||
| const US_GOV = "https://graph.microsoft.us"; | ||
| const US_DOD = "https://dod-graph.microsoft.us"; | ||
| const GERMANY = "https://graph.microsoft.de"; | ||
| const CHINA = "https://microsoftgraph.chinacloudapi.cn"; | ||
|
|
||
| /** | ||
| * Unique hostnames from constant values [graph.microsoft.com, graph.microsoft.us, ...] | ||
| * | ||
| * @var array | ||
| */ | ||
| private static $hosts = []; | ||
|
|
||
| /** | ||
| * Checks if url contains a valid National Cloud host | ||
| * | ||
| * @param string $url | ||
| * @return bool | ||
| */ | ||
| public static function isValidNationalCloudHost(string $url): bool { | ||
| self::initHosts(); | ||
| $validUrlParts = GraphRequestUtil::isValidBaseUrl($url); | ||
| return $validUrlParts && array_key_exists($validUrlParts["host"], self::$hosts); | ||
| } | ||
|
|
||
| /** | ||
| * Extracts hostnames from constant values to an array with unique keys for optimal lookup | ||
| */ | ||
| private static function initHosts(): void { | ||
| if (!self::$hosts) { | ||
| $reflectedClass = new \ReflectionClass(__CLASS__); | ||
| $constants = $reflectedClass->getConstants(); | ||
| foreach ($constants as $constName => $url) { | ||
| // Create associative array for O(1) key lookup | ||
| $hostname = parse_url($url)["host"]; | ||
| self::$hosts[$hostname] = true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
| /** | ||
| * Copyright (c) Microsoft Corporation. All Rights Reserved. | ||
| * Licensed under the MIT License. See License in the project root | ||
| * for license information. | ||
| */ | ||
|
|
||
| namespace Microsoft\Graph\Exception; | ||
|
|
||
| /** | ||
| * Class ClientInitialisationException | ||
| * | ||
| * @package Microsoft\Graph\Exception | ||
| * @copyright 2021 Microsoft Corporation | ||
| * @license https://opensource.org/licenses/MIT MIT License | ||
| * @link https://developer.microsoft.com/graph | ||
| */ | ||
| class GraphClientException extends GraphException | ||
| { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.