|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Microsoft\Graph\Generated\Admin\Exchange; |
| 4 | + |
| 5 | +use Exception; |
| 6 | +use Http\Promise\Promise; |
| 7 | +use Microsoft\Graph\Generated\Admin\Exchange\Tracing\TracingRequestBuilder; |
| 8 | +use Microsoft\Graph\Generated\Models\ExchangeAdmin; |
| 9 | +use Microsoft\Graph\Generated\Models\ODataErrors\ODataError; |
| 10 | +use Microsoft\Kiota\Abstractions\BaseRequestBuilder; |
| 11 | +use Microsoft\Kiota\Abstractions\HttpMethod; |
| 12 | +use Microsoft\Kiota\Abstractions\RequestAdapter; |
| 13 | +use Microsoft\Kiota\Abstractions\RequestInformation; |
| 14 | + |
| 15 | +/** |
| 16 | + * Provides operations to manage the exchange property of the microsoft.graph.admin entity. |
| 17 | +*/ |
| 18 | +class ExchangeRequestBuilder extends BaseRequestBuilder |
| 19 | +{ |
| 20 | + /** |
| 21 | + * Provides operations to manage the tracing property of the microsoft.graph.exchangeAdmin entity. |
| 22 | + */ |
| 23 | + public function tracing(): TracingRequestBuilder { |
| 24 | + return new TracingRequestBuilder($this->pathParameters, $this->requestAdapter); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Instantiates a new ExchangeRequestBuilder and sets the default values. |
| 29 | + * @param array<string, mixed>|string $pathParametersOrRawUrl Path parameters for the request or a String representing the raw URL. |
| 30 | + * @param RequestAdapter $requestAdapter The request adapter to use to execute the requests. |
| 31 | + */ |
| 32 | + public function __construct($pathParametersOrRawUrl, RequestAdapter $requestAdapter) { |
| 33 | + parent::__construct($requestAdapter, [], '{+baseurl}/admin/exchange{?%24expand,%24select}'); |
| 34 | + if (is_array($pathParametersOrRawUrl)) { |
| 35 | + $this->pathParameters = $pathParametersOrRawUrl; |
| 36 | + } else { |
| 37 | + $this->pathParameters = ['request-raw-url' => $pathParametersOrRawUrl]; |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Delete navigation property exchange for admin |
| 43 | + * @param ExchangeRequestBuilderDeleteRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 44 | + * @return Promise<void|null> |
| 45 | + * @throws Exception |
| 46 | + */ |
| 47 | + public function delete(?ExchangeRequestBuilderDeleteRequestConfiguration $requestConfiguration = null): Promise { |
| 48 | + $requestInfo = $this->toDeleteRequestInformation($requestConfiguration); |
| 49 | + $errorMappings = [ |
| 50 | + 'XXX' => [ODataError::class, 'createFromDiscriminatorValue'], |
| 51 | + ]; |
| 52 | + return $this->requestAdapter->sendNoContentAsync($requestInfo, $errorMappings); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * A container for the Exchange admin functionality. Read-only. |
| 57 | + * @param ExchangeRequestBuilderGetRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 58 | + * @return Promise<ExchangeAdmin|null> |
| 59 | + * @throws Exception |
| 60 | + */ |
| 61 | + public function get(?ExchangeRequestBuilderGetRequestConfiguration $requestConfiguration = null): Promise { |
| 62 | + $requestInfo = $this->toGetRequestInformation($requestConfiguration); |
| 63 | + $errorMappings = [ |
| 64 | + 'XXX' => [ODataError::class, 'createFromDiscriminatorValue'], |
| 65 | + ]; |
| 66 | + return $this->requestAdapter->sendAsync($requestInfo, [ExchangeAdmin::class, 'createFromDiscriminatorValue'], $errorMappings); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Update the navigation property exchange in admin |
| 71 | + * @param ExchangeAdmin $body The request body |
| 72 | + * @param ExchangeRequestBuilderPatchRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 73 | + * @return Promise<ExchangeAdmin|null> |
| 74 | + * @throws Exception |
| 75 | + */ |
| 76 | + public function patch(ExchangeAdmin $body, ?ExchangeRequestBuilderPatchRequestConfiguration $requestConfiguration = null): Promise { |
| 77 | + $requestInfo = $this->toPatchRequestInformation($body, $requestConfiguration); |
| 78 | + $errorMappings = [ |
| 79 | + 'XXX' => [ODataError::class, 'createFromDiscriminatorValue'], |
| 80 | + ]; |
| 81 | + return $this->requestAdapter->sendAsync($requestInfo, [ExchangeAdmin::class, 'createFromDiscriminatorValue'], $errorMappings); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Delete navigation property exchange for admin |
| 86 | + * @param ExchangeRequestBuilderDeleteRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 87 | + * @return RequestInformation |
| 88 | + */ |
| 89 | + public function toDeleteRequestInformation(?ExchangeRequestBuilderDeleteRequestConfiguration $requestConfiguration = null): RequestInformation { |
| 90 | + $requestInfo = new RequestInformation(); |
| 91 | + $requestInfo->urlTemplate = $this->urlTemplate; |
| 92 | + $requestInfo->pathParameters = $this->pathParameters; |
| 93 | + $requestInfo->httpMethod = HttpMethod::DELETE; |
| 94 | + if ($requestConfiguration !== null) { |
| 95 | + $requestInfo->addHeaders($requestConfiguration->headers); |
| 96 | + $requestInfo->addRequestOptions(...$requestConfiguration->options); |
| 97 | + } |
| 98 | + $requestInfo->tryAddHeader('Accept', "application/json"); |
| 99 | + return $requestInfo; |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * A container for the Exchange admin functionality. Read-only. |
| 104 | + * @param ExchangeRequestBuilderGetRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 105 | + * @return RequestInformation |
| 106 | + */ |
| 107 | + public function toGetRequestInformation(?ExchangeRequestBuilderGetRequestConfiguration $requestConfiguration = null): RequestInformation { |
| 108 | + $requestInfo = new RequestInformation(); |
| 109 | + $requestInfo->urlTemplate = $this->urlTemplate; |
| 110 | + $requestInfo->pathParameters = $this->pathParameters; |
| 111 | + $requestInfo->httpMethod = HttpMethod::GET; |
| 112 | + if ($requestConfiguration !== null) { |
| 113 | + $requestInfo->addHeaders($requestConfiguration->headers); |
| 114 | + if ($requestConfiguration->queryParameters !== null) { |
| 115 | + $requestInfo->setQueryParameters($requestConfiguration->queryParameters); |
| 116 | + } |
| 117 | + $requestInfo->addRequestOptions(...$requestConfiguration->options); |
| 118 | + } |
| 119 | + $requestInfo->tryAddHeader('Accept', "application/json"); |
| 120 | + return $requestInfo; |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * Update the navigation property exchange in admin |
| 125 | + * @param ExchangeAdmin $body The request body |
| 126 | + * @param ExchangeRequestBuilderPatchRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 127 | + * @return RequestInformation |
| 128 | + */ |
| 129 | + public function toPatchRequestInformation(ExchangeAdmin $body, ?ExchangeRequestBuilderPatchRequestConfiguration $requestConfiguration = null): RequestInformation { |
| 130 | + $requestInfo = new RequestInformation(); |
| 131 | + $requestInfo->urlTemplate = $this->urlTemplate; |
| 132 | + $requestInfo->pathParameters = $this->pathParameters; |
| 133 | + $requestInfo->httpMethod = HttpMethod::PATCH; |
| 134 | + if ($requestConfiguration !== null) { |
| 135 | + $requestInfo->addHeaders($requestConfiguration->headers); |
| 136 | + $requestInfo->addRequestOptions(...$requestConfiguration->options); |
| 137 | + } |
| 138 | + $requestInfo->tryAddHeader('Accept', "application/json"); |
| 139 | + $requestInfo->setContentFromParsable($this->requestAdapter, "application/json", $body); |
| 140 | + return $requestInfo; |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. |
| 145 | + * @param string $rawUrl The raw URL to use for the request builder. |
| 146 | + * @return ExchangeRequestBuilder |
| 147 | + */ |
| 148 | + public function withUrl(string $rawUrl): ExchangeRequestBuilder { |
| 149 | + return new ExchangeRequestBuilder($rawUrl, $this->requestAdapter); |
| 150 | + } |
| 151 | + |
| 152 | +} |
0 commit comments