|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Microsoft\Graph\Beta\Generated\Admin\CloudLicensing\Allotments; |
| 4 | + |
| 5 | +use Exception; |
| 6 | +use Http\Promise\Promise; |
| 7 | +use Microsoft\Graph\Beta\Generated\Admin\CloudLicensing\Allotments\Count\CountRequestBuilder; |
| 8 | +use Microsoft\Graph\Beta\Generated\Admin\CloudLicensing\Allotments\Item\AllotmentItemRequestBuilder; |
| 9 | +use Microsoft\Graph\Beta\Generated\Models\CloudLicensing\Allotment; |
| 10 | +use Microsoft\Graph\Beta\Generated\Models\CloudLicensing\AllotmentCollectionResponse; |
| 11 | +use Microsoft\Graph\Beta\Generated\Models\ODataErrors\ODataError; |
| 12 | +use Microsoft\Kiota\Abstractions\BaseRequestBuilder; |
| 13 | +use Microsoft\Kiota\Abstractions\HttpMethod; |
| 14 | +use Microsoft\Kiota\Abstractions\RequestAdapter; |
| 15 | +use Microsoft\Kiota\Abstractions\RequestInformation; |
| 16 | + |
| 17 | +/** |
| 18 | + * Provides operations to manage the allotments property of the microsoft.graph.cloudLicensing.adminCloudLicensing entity. |
| 19 | +*/ |
| 20 | +class AllotmentsRequestBuilder extends BaseRequestBuilder |
| 21 | +{ |
| 22 | + /** |
| 23 | + * Provides operations to count the resources in the collection. |
| 24 | + */ |
| 25 | + public function count(): CountRequestBuilder { |
| 26 | + return new CountRequestBuilder($this->pathParameters, $this->requestAdapter); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Provides operations to manage the allotments property of the microsoft.graph.cloudLicensing.adminCloudLicensing entity. |
| 31 | + * @param string $allotmentId The unique identifier of allotment |
| 32 | + * @return AllotmentItemRequestBuilder |
| 33 | + */ |
| 34 | + public function byAllotmentId(string $allotmentId): AllotmentItemRequestBuilder { |
| 35 | + $urlTplParams = $this->pathParameters; |
| 36 | + $urlTplParams['allotment%2Did'] = $allotmentId; |
| 37 | + return new AllotmentItemRequestBuilder($urlTplParams, $this->requestAdapter); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Instantiates a new AllotmentsRequestBuilder and sets the default values. |
| 42 | + * @param array<string, mixed>|string $pathParametersOrRawUrl Path parameters for the request or a String representing the raw URL. |
| 43 | + * @param RequestAdapter $requestAdapter The request adapter to use to execute the requests. |
| 44 | + */ |
| 45 | + public function __construct($pathParametersOrRawUrl, RequestAdapter $requestAdapter) { |
| 46 | + parent::__construct($requestAdapter, [], '{+baseurl}/admin/cloudLicensing/allotments{?%24count,%24expand,%24filter,%24orderby,%24search,%24select,%24skip,%24top}'); |
| 47 | + if (is_array($pathParametersOrRawUrl)) { |
| 48 | + $this->pathParameters = $pathParametersOrRawUrl; |
| 49 | + } else { |
| 50 | + $this->pathParameters = ['request-raw-url' => $pathParametersOrRawUrl]; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Get a list of the allotment objects and their properties. |
| 56 | + * @param AllotmentsRequestBuilderGetRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 57 | + * @return Promise<AllotmentCollectionResponse|null> |
| 58 | + * @throws Exception |
| 59 | + * @link https://learn.microsoft.com/graph/api/cloudlicensing-admincloudlicensing-list-allotments?view=graph-rest-beta Find more info here |
| 60 | + */ |
| 61 | + public function get(?AllotmentsRequestBuilderGetRequestConfiguration $requestConfiguration = null): Promise { |
| 62 | + $requestInfo = $this->toGetRequestInformation($requestConfiguration); |
| 63 | + $errorMappings = [ |
| 64 | + 'XXX' => [ODataError::class, 'createFromDiscriminatorValue'], |
| 65 | + ]; |
| 66 | + return $this->requestAdapter->sendAsync($requestInfo, [AllotmentCollectionResponse::class, 'createFromDiscriminatorValue'], $errorMappings); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Create new navigation property to allotments for admin |
| 71 | + * @param Allotment $body The request body |
| 72 | + * @param AllotmentsRequestBuilderPostRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 73 | + * @return Promise<Allotment|null> |
| 74 | + * @throws Exception |
| 75 | + */ |
| 76 | + public function post(Allotment $body, ?AllotmentsRequestBuilderPostRequestConfiguration $requestConfiguration = null): Promise { |
| 77 | + $requestInfo = $this->toPostRequestInformation($body, $requestConfiguration); |
| 78 | + $errorMappings = [ |
| 79 | + 'XXX' => [ODataError::class, 'createFromDiscriminatorValue'], |
| 80 | + ]; |
| 81 | + return $this->requestAdapter->sendAsync($requestInfo, [Allotment::class, 'createFromDiscriminatorValue'], $errorMappings); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Get a list of the allotment objects and their properties. |
| 86 | + * @param AllotmentsRequestBuilderGetRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 87 | + * @return RequestInformation |
| 88 | + */ |
| 89 | + public function toGetRequestInformation(?AllotmentsRequestBuilderGetRequestConfiguration $requestConfiguration = null): RequestInformation { |
| 90 | + $requestInfo = new RequestInformation(); |
| 91 | + $requestInfo->urlTemplate = $this->urlTemplate; |
| 92 | + $requestInfo->pathParameters = $this->pathParameters; |
| 93 | + $requestInfo->httpMethod = HttpMethod::GET; |
| 94 | + if ($requestConfiguration !== null) { |
| 95 | + $requestInfo->addHeaders($requestConfiguration->headers); |
| 96 | + if ($requestConfiguration->queryParameters !== null) { |
| 97 | + $requestInfo->setQueryParameters($requestConfiguration->queryParameters); |
| 98 | + } |
| 99 | + $requestInfo->addRequestOptions(...$requestConfiguration->options); |
| 100 | + } |
| 101 | + $requestInfo->tryAddHeader('Accept', "application/json"); |
| 102 | + return $requestInfo; |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * Create new navigation property to allotments for admin |
| 107 | + * @param Allotment $body The request body |
| 108 | + * @param AllotmentsRequestBuilderPostRequestConfiguration|null $requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. |
| 109 | + * @return RequestInformation |
| 110 | + */ |
| 111 | + public function toPostRequestInformation(Allotment $body, ?AllotmentsRequestBuilderPostRequestConfiguration $requestConfiguration = null): RequestInformation { |
| 112 | + $requestInfo = new RequestInformation(); |
| 113 | + $requestInfo->urlTemplate = $this->urlTemplate; |
| 114 | + $requestInfo->pathParameters = $this->pathParameters; |
| 115 | + $requestInfo->httpMethod = HttpMethod::POST; |
| 116 | + if ($requestConfiguration !== null) { |
| 117 | + $requestInfo->addHeaders($requestConfiguration->headers); |
| 118 | + $requestInfo->addRequestOptions(...$requestConfiguration->options); |
| 119 | + } |
| 120 | + $requestInfo->tryAddHeader('Accept', "application/json"); |
| 121 | + $requestInfo->setContentFromParsable($this->requestAdapter, "application/json", $body); |
| 122 | + return $requestInfo; |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. |
| 127 | + * @param string $rawUrl The raw URL to use for the request builder. |
| 128 | + * @return AllotmentsRequestBuilder |
| 129 | + */ |
| 130 | + public function withUrl(string $rawUrl): AllotmentsRequestBuilder { |
| 131 | + return new AllotmentsRequestBuilder($rawUrl, $this->requestAdapter); |
| 132 | + } |
| 133 | + |
| 134 | +} |
0 commit comments