1# coding=utf-8 2# -------------------------------------------------------------------------- 3# Copyright (c) Microsoft Corporation. All rights reserved. 4# Licensed under the MIT License. See License.txt in the project root for 5# license information. 6# 7# Code generated by Microsoft (R) AutoRest Code Generator. 8# Changes may cause incorrect behavior and will be lost if the code is 9# regenerated. 10# -------------------------------------------------------------------------- 11 12import uuid 13from msrest.pipeline import ClientRawResponse 14 15from .. import models 16 17 18class ComputeNodeOperations(object): 19 """ComputeNodeOperations operations. 20 21 You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. 22 23 :param client: Client for service requests. 24 :param config: Configuration of service client. 25 :param serializer: An object model serializer. 26 :param deserializer: An object model deserializer. 27 :ivar api_version: The API version to use for the request. Constant value: "2021-06-01.14.0". 28 """ 29 30 models = models 31 32 def __init__(self, client, config, serializer, deserializer): 33 34 self._client = client 35 self._serialize = serializer 36 self._deserialize = deserializer 37 self.api_version = "2021-06-01.14.0" 38 39 self.config = config 40 41 def add_user( 42 self, pool_id, node_id, user, compute_node_add_user_options=None, custom_headers=None, raw=False, **operation_config): 43 """Adds a user Account to the specified Compute Node. 44 45 You can add a user Account to a Compute Node only when it is in the 46 idle or running state. 47 48 :param pool_id: The ID of the Pool that contains the Compute Node. 49 :type pool_id: str 50 :param node_id: The ID of the machine on which you want to create a 51 user Account. 52 :type node_id: str 53 :param user: The user Account to be created. 54 :type user: ~azure.batch.models.ComputeNodeUser 55 :param compute_node_add_user_options: Additional parameters for the 56 operation 57 :type compute_node_add_user_options: 58 ~azure.batch.models.ComputeNodeAddUserOptions 59 :param dict custom_headers: headers that will be added to the request 60 :param bool raw: returns the direct response alongside the 61 deserialized response 62 :param operation_config: :ref:`Operation configuration 63 overrides<msrest:optionsforoperations>`. 64 :return: None or ClientRawResponse if raw=true 65 :rtype: None or ~msrest.pipeline.ClientRawResponse 66 :raises: 67 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 68 """ 69 timeout = None 70 if compute_node_add_user_options is not None: 71 timeout = compute_node_add_user_options.timeout 72 client_request_id = None 73 if compute_node_add_user_options is not None: 74 client_request_id = compute_node_add_user_options.client_request_id 75 return_client_request_id = None 76 if compute_node_add_user_options is not None: 77 return_client_request_id = compute_node_add_user_options.return_client_request_id 78 ocp_date = None 79 if compute_node_add_user_options is not None: 80 ocp_date = compute_node_add_user_options.ocp_date 81 82 # Construct URL 83 url = self.add_user.metadata['url'] 84 path_format_arguments = { 85 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 86 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 87 'nodeId': self._serialize.url("node_id", node_id, 'str') 88 } 89 url = self._client.format_url(url, **path_format_arguments) 90 91 # Construct parameters 92 query_parameters = {} 93 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 94 if timeout is not None: 95 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 96 97 # Construct headers 98 header_parameters = {} 99 header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' 100 if self.config.generate_client_request_id: 101 header_parameters['client-request-id'] = str(uuid.uuid1()) 102 if custom_headers: 103 header_parameters.update(custom_headers) 104 if self.config.accept_language is not None: 105 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 106 if client_request_id is not None: 107 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 108 if return_client_request_id is not None: 109 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 110 if ocp_date is not None: 111 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 112 113 # Construct body 114 body_content = self._serialize.body(user, 'ComputeNodeUser') 115 116 # Construct and send request 117 request = self._client.post(url, query_parameters, header_parameters, body_content) 118 response = self._client.send(request, stream=False, **operation_config) 119 120 if response.status_code not in [201]: 121 raise models.BatchErrorException(self._deserialize, response) 122 123 if raw: 124 client_raw_response = ClientRawResponse(None, response) 125 client_raw_response.add_headers({ 126 'client-request-id': 'str', 127 'request-id': 'str', 128 'ETag': 'str', 129 'Last-Modified': 'rfc-1123', 130 'DataServiceId': 'str', 131 }) 132 return client_raw_response 133 add_user.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/users'} 134 135 def delete_user( 136 self, pool_id, node_id, user_name, compute_node_delete_user_options=None, custom_headers=None, raw=False, **operation_config): 137 """Deletes a user Account from the specified Compute Node. 138 139 You can delete a user Account to a Compute Node only when it is in the 140 idle or running state. 141 142 :param pool_id: The ID of the Pool that contains the Compute Node. 143 :type pool_id: str 144 :param node_id: The ID of the machine on which you want to delete a 145 user Account. 146 :type node_id: str 147 :param user_name: The name of the user Account to delete. 148 :type user_name: str 149 :param compute_node_delete_user_options: Additional parameters for the 150 operation 151 :type compute_node_delete_user_options: 152 ~azure.batch.models.ComputeNodeDeleteUserOptions 153 :param dict custom_headers: headers that will be added to the request 154 :param bool raw: returns the direct response alongside the 155 deserialized response 156 :param operation_config: :ref:`Operation configuration 157 overrides<msrest:optionsforoperations>`. 158 :return: None or ClientRawResponse if raw=true 159 :rtype: None or ~msrest.pipeline.ClientRawResponse 160 :raises: 161 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 162 """ 163 timeout = None 164 if compute_node_delete_user_options is not None: 165 timeout = compute_node_delete_user_options.timeout 166 client_request_id = None 167 if compute_node_delete_user_options is not None: 168 client_request_id = compute_node_delete_user_options.client_request_id 169 return_client_request_id = None 170 if compute_node_delete_user_options is not None: 171 return_client_request_id = compute_node_delete_user_options.return_client_request_id 172 ocp_date = None 173 if compute_node_delete_user_options is not None: 174 ocp_date = compute_node_delete_user_options.ocp_date 175 176 # Construct URL 177 url = self.delete_user.metadata['url'] 178 path_format_arguments = { 179 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 180 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 181 'nodeId': self._serialize.url("node_id", node_id, 'str'), 182 'userName': self._serialize.url("user_name", user_name, 'str') 183 } 184 url = self._client.format_url(url, **path_format_arguments) 185 186 # Construct parameters 187 query_parameters = {} 188 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 189 if timeout is not None: 190 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 191 192 # Construct headers 193 header_parameters = {} 194 if self.config.generate_client_request_id: 195 header_parameters['client-request-id'] = str(uuid.uuid1()) 196 if custom_headers: 197 header_parameters.update(custom_headers) 198 if self.config.accept_language is not None: 199 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 200 if client_request_id is not None: 201 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 202 if return_client_request_id is not None: 203 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 204 if ocp_date is not None: 205 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 206 207 # Construct and send request 208 request = self._client.delete(url, query_parameters, header_parameters) 209 response = self._client.send(request, stream=False, **operation_config) 210 211 if response.status_code not in [200]: 212 raise models.BatchErrorException(self._deserialize, response) 213 214 if raw: 215 client_raw_response = ClientRawResponse(None, response) 216 client_raw_response.add_headers({ 217 'client-request-id': 'str', 218 'request-id': 'str', 219 }) 220 return client_raw_response 221 delete_user.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/users/{userName}'} 222 223 def update_user( 224 self, pool_id, node_id, user_name, node_update_user_parameter, compute_node_update_user_options=None, custom_headers=None, raw=False, **operation_config): 225 """Updates the password and expiration time of a user Account on the 226 specified Compute Node. 227 228 This operation replaces of all the updatable properties of the Account. 229 For example, if the expiryTime element is not specified, the current 230 value is replaced with the default value, not left unmodified. You can 231 update a user Account on a Compute Node only when it is in the idle or 232 running state. 233 234 :param pool_id: The ID of the Pool that contains the Compute Node. 235 :type pool_id: str 236 :param node_id: The ID of the machine on which you want to update a 237 user Account. 238 :type node_id: str 239 :param user_name: The name of the user Account to update. 240 :type user_name: str 241 :param node_update_user_parameter: The parameters for the request. 242 :type node_update_user_parameter: 243 ~azure.batch.models.NodeUpdateUserParameter 244 :param compute_node_update_user_options: Additional parameters for the 245 operation 246 :type compute_node_update_user_options: 247 ~azure.batch.models.ComputeNodeUpdateUserOptions 248 :param dict custom_headers: headers that will be added to the request 249 :param bool raw: returns the direct response alongside the 250 deserialized response 251 :param operation_config: :ref:`Operation configuration 252 overrides<msrest:optionsforoperations>`. 253 :return: None or ClientRawResponse if raw=true 254 :rtype: None or ~msrest.pipeline.ClientRawResponse 255 :raises: 256 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 257 """ 258 timeout = None 259 if compute_node_update_user_options is not None: 260 timeout = compute_node_update_user_options.timeout 261 client_request_id = None 262 if compute_node_update_user_options is not None: 263 client_request_id = compute_node_update_user_options.client_request_id 264 return_client_request_id = None 265 if compute_node_update_user_options is not None: 266 return_client_request_id = compute_node_update_user_options.return_client_request_id 267 ocp_date = None 268 if compute_node_update_user_options is not None: 269 ocp_date = compute_node_update_user_options.ocp_date 270 271 # Construct URL 272 url = self.update_user.metadata['url'] 273 path_format_arguments = { 274 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 275 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 276 'nodeId': self._serialize.url("node_id", node_id, 'str'), 277 'userName': self._serialize.url("user_name", user_name, 'str') 278 } 279 url = self._client.format_url(url, **path_format_arguments) 280 281 # Construct parameters 282 query_parameters = {} 283 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 284 if timeout is not None: 285 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 286 287 # Construct headers 288 header_parameters = {} 289 header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' 290 if self.config.generate_client_request_id: 291 header_parameters['client-request-id'] = str(uuid.uuid1()) 292 if custom_headers: 293 header_parameters.update(custom_headers) 294 if self.config.accept_language is not None: 295 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 296 if client_request_id is not None: 297 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 298 if return_client_request_id is not None: 299 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 300 if ocp_date is not None: 301 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 302 303 # Construct body 304 body_content = self._serialize.body(node_update_user_parameter, 'NodeUpdateUserParameter') 305 306 # Construct and send request 307 request = self._client.put(url, query_parameters, header_parameters, body_content) 308 response = self._client.send(request, stream=False, **operation_config) 309 310 if response.status_code not in [200]: 311 raise models.BatchErrorException(self._deserialize, response) 312 313 if raw: 314 client_raw_response = ClientRawResponse(None, response) 315 client_raw_response.add_headers({ 316 'client-request-id': 'str', 317 'request-id': 'str', 318 'ETag': 'str', 319 'Last-Modified': 'rfc-1123', 320 'DataServiceId': 'str', 321 }) 322 return client_raw_response 323 update_user.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/users/{userName}'} 324 325 def get( 326 self, pool_id, node_id, compute_node_get_options=None, custom_headers=None, raw=False, **operation_config): 327 """Gets information about the specified Compute Node. 328 329 :param pool_id: The ID of the Pool that contains the Compute Node. 330 :type pool_id: str 331 :param node_id: The ID of the Compute Node that you want to get 332 information about. 333 :type node_id: str 334 :param compute_node_get_options: Additional parameters for the 335 operation 336 :type compute_node_get_options: 337 ~azure.batch.models.ComputeNodeGetOptions 338 :param dict custom_headers: headers that will be added to the request 339 :param bool raw: returns the direct response alongside the 340 deserialized response 341 :param operation_config: :ref:`Operation configuration 342 overrides<msrest:optionsforoperations>`. 343 :return: ComputeNode or ClientRawResponse if raw=true 344 :rtype: ~azure.batch.models.ComputeNode or 345 ~msrest.pipeline.ClientRawResponse 346 :raises: 347 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 348 """ 349 select = None 350 if compute_node_get_options is not None: 351 select = compute_node_get_options.select 352 timeout = None 353 if compute_node_get_options is not None: 354 timeout = compute_node_get_options.timeout 355 client_request_id = None 356 if compute_node_get_options is not None: 357 client_request_id = compute_node_get_options.client_request_id 358 return_client_request_id = None 359 if compute_node_get_options is not None: 360 return_client_request_id = compute_node_get_options.return_client_request_id 361 ocp_date = None 362 if compute_node_get_options is not None: 363 ocp_date = compute_node_get_options.ocp_date 364 365 # Construct URL 366 url = self.get.metadata['url'] 367 path_format_arguments = { 368 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 369 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 370 'nodeId': self._serialize.url("node_id", node_id, 'str') 371 } 372 url = self._client.format_url(url, **path_format_arguments) 373 374 # Construct parameters 375 query_parameters = {} 376 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 377 if select is not None: 378 query_parameters['$select'] = self._serialize.query("select", select, 'str') 379 if timeout is not None: 380 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 381 382 # Construct headers 383 header_parameters = {} 384 header_parameters['Accept'] = 'application/json' 385 if self.config.generate_client_request_id: 386 header_parameters['client-request-id'] = str(uuid.uuid1()) 387 if custom_headers: 388 header_parameters.update(custom_headers) 389 if self.config.accept_language is not None: 390 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 391 if client_request_id is not None: 392 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 393 if return_client_request_id is not None: 394 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 395 if ocp_date is not None: 396 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 397 398 # Construct and send request 399 request = self._client.get(url, query_parameters, header_parameters) 400 response = self._client.send(request, stream=False, **operation_config) 401 402 if response.status_code not in [200]: 403 raise models.BatchErrorException(self._deserialize, response) 404 405 header_dict = {} 406 deserialized = None 407 if response.status_code == 200: 408 deserialized = self._deserialize('ComputeNode', response) 409 header_dict = { 410 'client-request-id': 'str', 411 'request-id': 'str', 412 'ETag': 'str', 413 'Last-Modified': 'rfc-1123', 414 } 415 416 if raw: 417 client_raw_response = ClientRawResponse(deserialized, response) 418 client_raw_response.add_headers(header_dict) 419 return client_raw_response 420 421 return deserialized 422 get.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}'} 423 424 def reboot( 425 self, pool_id, node_id, node_reboot_option=None, compute_node_reboot_options=None, custom_headers=None, raw=False, **operation_config): 426 """Restarts the specified Compute Node. 427 428 You can restart a Compute Node only if it is in an idle or running 429 state. 430 431 :param pool_id: The ID of the Pool that contains the Compute Node. 432 :type pool_id: str 433 :param node_id: The ID of the Compute Node that you want to restart. 434 :type node_id: str 435 :param node_reboot_option: The default value is requeue. Possible 436 values include: 'requeue', 'terminate', 'taskCompletion', 437 'retainedData' 438 :type node_reboot_option: str or 439 ~azure.batch.models.ComputeNodeRebootOption 440 :param compute_node_reboot_options: Additional parameters for the 441 operation 442 :type compute_node_reboot_options: 443 ~azure.batch.models.ComputeNodeRebootOptions 444 :param dict custom_headers: headers that will be added to the request 445 :param bool raw: returns the direct response alongside the 446 deserialized response 447 :param operation_config: :ref:`Operation configuration 448 overrides<msrest:optionsforoperations>`. 449 :return: None or ClientRawResponse if raw=true 450 :rtype: None or ~msrest.pipeline.ClientRawResponse 451 :raises: 452 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 453 """ 454 timeout = None 455 if compute_node_reboot_options is not None: 456 timeout = compute_node_reboot_options.timeout 457 client_request_id = None 458 if compute_node_reboot_options is not None: 459 client_request_id = compute_node_reboot_options.client_request_id 460 return_client_request_id = None 461 if compute_node_reboot_options is not None: 462 return_client_request_id = compute_node_reboot_options.return_client_request_id 463 ocp_date = None 464 if compute_node_reboot_options is not None: 465 ocp_date = compute_node_reboot_options.ocp_date 466 node_reboot_parameter = None 467 if node_reboot_option is not None: 468 node_reboot_parameter = models.NodeRebootParameter(node_reboot_option=node_reboot_option) 469 470 # Construct URL 471 url = self.reboot.metadata['url'] 472 path_format_arguments = { 473 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 474 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 475 'nodeId': self._serialize.url("node_id", node_id, 'str') 476 } 477 url = self._client.format_url(url, **path_format_arguments) 478 479 # Construct parameters 480 query_parameters = {} 481 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 482 if timeout is not None: 483 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 484 485 # Construct headers 486 header_parameters = {} 487 header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' 488 if self.config.generate_client_request_id: 489 header_parameters['client-request-id'] = str(uuid.uuid1()) 490 if custom_headers: 491 header_parameters.update(custom_headers) 492 if self.config.accept_language is not None: 493 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 494 if client_request_id is not None: 495 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 496 if return_client_request_id is not None: 497 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 498 if ocp_date is not None: 499 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 500 501 # Construct body 502 if node_reboot_parameter is not None: 503 body_content = self._serialize.body(node_reboot_parameter, 'NodeRebootParameter') 504 else: 505 body_content = None 506 507 # Construct and send request 508 request = self._client.post(url, query_parameters, header_parameters, body_content) 509 response = self._client.send(request, stream=False, **operation_config) 510 511 if response.status_code not in [202]: 512 raise models.BatchErrorException(self._deserialize, response) 513 514 if raw: 515 client_raw_response = ClientRawResponse(None, response) 516 client_raw_response.add_headers({ 517 'client-request-id': 'str', 518 'request-id': 'str', 519 'ETag': 'str', 520 'Last-Modified': 'rfc-1123', 521 'DataServiceId': 'str', 522 }) 523 return client_raw_response 524 reboot.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/reboot'} 525 526 def reimage( 527 self, pool_id, node_id, node_reimage_option=None, compute_node_reimage_options=None, custom_headers=None, raw=False, **operation_config): 528 """Reinstalls the operating system on the specified Compute Node. 529 530 You can reinstall the operating system on a Compute Node only if it is 531 in an idle or running state. This API can be invoked only on Pools 532 created with the cloud service configuration property. 533 534 :param pool_id: The ID of the Pool that contains the Compute Node. 535 :type pool_id: str 536 :param node_id: The ID of the Compute Node that you want to restart. 537 :type node_id: str 538 :param node_reimage_option: The default value is requeue. Possible 539 values include: 'requeue', 'terminate', 'taskCompletion', 540 'retainedData' 541 :type node_reimage_option: str or 542 ~azure.batch.models.ComputeNodeReimageOption 543 :param compute_node_reimage_options: Additional parameters for the 544 operation 545 :type compute_node_reimage_options: 546 ~azure.batch.models.ComputeNodeReimageOptions 547 :param dict custom_headers: headers that will be added to the request 548 :param bool raw: returns the direct response alongside the 549 deserialized response 550 :param operation_config: :ref:`Operation configuration 551 overrides<msrest:optionsforoperations>`. 552 :return: None or ClientRawResponse if raw=true 553 :rtype: None or ~msrest.pipeline.ClientRawResponse 554 :raises: 555 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 556 """ 557 timeout = None 558 if compute_node_reimage_options is not None: 559 timeout = compute_node_reimage_options.timeout 560 client_request_id = None 561 if compute_node_reimage_options is not None: 562 client_request_id = compute_node_reimage_options.client_request_id 563 return_client_request_id = None 564 if compute_node_reimage_options is not None: 565 return_client_request_id = compute_node_reimage_options.return_client_request_id 566 ocp_date = None 567 if compute_node_reimage_options is not None: 568 ocp_date = compute_node_reimage_options.ocp_date 569 node_reimage_parameter = None 570 if node_reimage_option is not None: 571 node_reimage_parameter = models.NodeReimageParameter(node_reimage_option=node_reimage_option) 572 573 # Construct URL 574 url = self.reimage.metadata['url'] 575 path_format_arguments = { 576 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 577 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 578 'nodeId': self._serialize.url("node_id", node_id, 'str') 579 } 580 url = self._client.format_url(url, **path_format_arguments) 581 582 # Construct parameters 583 query_parameters = {} 584 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 585 if timeout is not None: 586 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 587 588 # Construct headers 589 header_parameters = {} 590 header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' 591 if self.config.generate_client_request_id: 592 header_parameters['client-request-id'] = str(uuid.uuid1()) 593 if custom_headers: 594 header_parameters.update(custom_headers) 595 if self.config.accept_language is not None: 596 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 597 if client_request_id is not None: 598 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 599 if return_client_request_id is not None: 600 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 601 if ocp_date is not None: 602 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 603 604 # Construct body 605 if node_reimage_parameter is not None: 606 body_content = self._serialize.body(node_reimage_parameter, 'NodeReimageParameter') 607 else: 608 body_content = None 609 610 # Construct and send request 611 request = self._client.post(url, query_parameters, header_parameters, body_content) 612 response = self._client.send(request, stream=False, **operation_config) 613 614 if response.status_code not in [202]: 615 raise models.BatchErrorException(self._deserialize, response) 616 617 if raw: 618 client_raw_response = ClientRawResponse(None, response) 619 client_raw_response.add_headers({ 620 'client-request-id': 'str', 621 'request-id': 'str', 622 'ETag': 'str', 623 'Last-Modified': 'rfc-1123', 624 'DataServiceId': 'str', 625 }) 626 return client_raw_response 627 reimage.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/reimage'} 628 629 def disable_scheduling( 630 self, pool_id, node_id, node_disable_scheduling_option=None, compute_node_disable_scheduling_options=None, custom_headers=None, raw=False, **operation_config): 631 """Disables Task scheduling on the specified Compute Node. 632 633 You can disable Task scheduling on a Compute Node only if its current 634 scheduling state is enabled. 635 636 :param pool_id: The ID of the Pool that contains the Compute Node. 637 :type pool_id: str 638 :param node_id: The ID of the Compute Node on which you want to 639 disable Task scheduling. 640 :type node_id: str 641 :param node_disable_scheduling_option: The default value is requeue. 642 Possible values include: 'requeue', 'terminate', 'taskCompletion' 643 :type node_disable_scheduling_option: str or 644 ~azure.batch.models.DisableComputeNodeSchedulingOption 645 :param compute_node_disable_scheduling_options: Additional parameters 646 for the operation 647 :type compute_node_disable_scheduling_options: 648 ~azure.batch.models.ComputeNodeDisableSchedulingOptions 649 :param dict custom_headers: headers that will be added to the request 650 :param bool raw: returns the direct response alongside the 651 deserialized response 652 :param operation_config: :ref:`Operation configuration 653 overrides<msrest:optionsforoperations>`. 654 :return: None or ClientRawResponse if raw=true 655 :rtype: None or ~msrest.pipeline.ClientRawResponse 656 :raises: 657 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 658 """ 659 timeout = None 660 if compute_node_disable_scheduling_options is not None: 661 timeout = compute_node_disable_scheduling_options.timeout 662 client_request_id = None 663 if compute_node_disable_scheduling_options is not None: 664 client_request_id = compute_node_disable_scheduling_options.client_request_id 665 return_client_request_id = None 666 if compute_node_disable_scheduling_options is not None: 667 return_client_request_id = compute_node_disable_scheduling_options.return_client_request_id 668 ocp_date = None 669 if compute_node_disable_scheduling_options is not None: 670 ocp_date = compute_node_disable_scheduling_options.ocp_date 671 node_disable_scheduling_parameter = None 672 if node_disable_scheduling_option is not None: 673 node_disable_scheduling_parameter = models.NodeDisableSchedulingParameter(node_disable_scheduling_option=node_disable_scheduling_option) 674 675 # Construct URL 676 url = self.disable_scheduling.metadata['url'] 677 path_format_arguments = { 678 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 679 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 680 'nodeId': self._serialize.url("node_id", node_id, 'str') 681 } 682 url = self._client.format_url(url, **path_format_arguments) 683 684 # Construct parameters 685 query_parameters = {} 686 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 687 if timeout is not None: 688 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 689 690 # Construct headers 691 header_parameters = {} 692 header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' 693 if self.config.generate_client_request_id: 694 header_parameters['client-request-id'] = str(uuid.uuid1()) 695 if custom_headers: 696 header_parameters.update(custom_headers) 697 if self.config.accept_language is not None: 698 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 699 if client_request_id is not None: 700 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 701 if return_client_request_id is not None: 702 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 703 if ocp_date is not None: 704 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 705 706 # Construct body 707 if node_disable_scheduling_parameter is not None: 708 body_content = self._serialize.body(node_disable_scheduling_parameter, 'NodeDisableSchedulingParameter') 709 else: 710 body_content = None 711 712 # Construct and send request 713 request = self._client.post(url, query_parameters, header_parameters, body_content) 714 response = self._client.send(request, stream=False, **operation_config) 715 716 if response.status_code not in [200]: 717 raise models.BatchErrorException(self._deserialize, response) 718 719 if raw: 720 client_raw_response = ClientRawResponse(None, response) 721 client_raw_response.add_headers({ 722 'client-request-id': 'str', 723 'request-id': 'str', 724 'ETag': 'str', 725 'Last-Modified': 'rfc-1123', 726 'DataServiceId': 'str', 727 }) 728 return client_raw_response 729 disable_scheduling.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/disablescheduling'} 730 731 def enable_scheduling( 732 self, pool_id, node_id, compute_node_enable_scheduling_options=None, custom_headers=None, raw=False, **operation_config): 733 """Enables Task scheduling on the specified Compute Node. 734 735 You can enable Task scheduling on a Compute Node only if its current 736 scheduling state is disabled. 737 738 :param pool_id: The ID of the Pool that contains the Compute Node. 739 :type pool_id: str 740 :param node_id: The ID of the Compute Node on which you want to enable 741 Task scheduling. 742 :type node_id: str 743 :param compute_node_enable_scheduling_options: Additional parameters 744 for the operation 745 :type compute_node_enable_scheduling_options: 746 ~azure.batch.models.ComputeNodeEnableSchedulingOptions 747 :param dict custom_headers: headers that will be added to the request 748 :param bool raw: returns the direct response alongside the 749 deserialized response 750 :param operation_config: :ref:`Operation configuration 751 overrides<msrest:optionsforoperations>`. 752 :return: None or ClientRawResponse if raw=true 753 :rtype: None or ~msrest.pipeline.ClientRawResponse 754 :raises: 755 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 756 """ 757 timeout = None 758 if compute_node_enable_scheduling_options is not None: 759 timeout = compute_node_enable_scheduling_options.timeout 760 client_request_id = None 761 if compute_node_enable_scheduling_options is not None: 762 client_request_id = compute_node_enable_scheduling_options.client_request_id 763 return_client_request_id = None 764 if compute_node_enable_scheduling_options is not None: 765 return_client_request_id = compute_node_enable_scheduling_options.return_client_request_id 766 ocp_date = None 767 if compute_node_enable_scheduling_options is not None: 768 ocp_date = compute_node_enable_scheduling_options.ocp_date 769 770 # Construct URL 771 url = self.enable_scheduling.metadata['url'] 772 path_format_arguments = { 773 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 774 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 775 'nodeId': self._serialize.url("node_id", node_id, 'str') 776 } 777 url = self._client.format_url(url, **path_format_arguments) 778 779 # Construct parameters 780 query_parameters = {} 781 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 782 if timeout is not None: 783 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 784 785 # Construct headers 786 header_parameters = {} 787 if self.config.generate_client_request_id: 788 header_parameters['client-request-id'] = str(uuid.uuid1()) 789 if custom_headers: 790 header_parameters.update(custom_headers) 791 if self.config.accept_language is not None: 792 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 793 if client_request_id is not None: 794 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 795 if return_client_request_id is not None: 796 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 797 if ocp_date is not None: 798 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 799 800 # Construct and send request 801 request = self._client.post(url, query_parameters, header_parameters) 802 response = self._client.send(request, stream=False, **operation_config) 803 804 if response.status_code not in [200]: 805 raise models.BatchErrorException(self._deserialize, response) 806 807 if raw: 808 client_raw_response = ClientRawResponse(None, response) 809 client_raw_response.add_headers({ 810 'client-request-id': 'str', 811 'request-id': 'str', 812 'ETag': 'str', 813 'Last-Modified': 'rfc-1123', 814 'DataServiceId': 'str', 815 }) 816 return client_raw_response 817 enable_scheduling.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/enablescheduling'} 818 819 def get_remote_login_settings( 820 self, pool_id, node_id, compute_node_get_remote_login_settings_options=None, custom_headers=None, raw=False, **operation_config): 821 """Gets the settings required for remote login to a Compute Node. 822 823 Before you can remotely login to a Compute Node using the remote login 824 settings, you must create a user Account on the Compute Node. This API 825 can be invoked only on Pools created with the virtual machine 826 configuration property. For Pools created with a cloud service 827 configuration, see the GetRemoteDesktop API. 828 829 :param pool_id: The ID of the Pool that contains the Compute Node. 830 :type pool_id: str 831 :param node_id: The ID of the Compute Node for which to obtain the 832 remote login settings. 833 :type node_id: str 834 :param compute_node_get_remote_login_settings_options: Additional 835 parameters for the operation 836 :type compute_node_get_remote_login_settings_options: 837 ~azure.batch.models.ComputeNodeGetRemoteLoginSettingsOptions 838 :param dict custom_headers: headers that will be added to the request 839 :param bool raw: returns the direct response alongside the 840 deserialized response 841 :param operation_config: :ref:`Operation configuration 842 overrides<msrest:optionsforoperations>`. 843 :return: ComputeNodeGetRemoteLoginSettingsResult or ClientRawResponse 844 if raw=true 845 :rtype: ~azure.batch.models.ComputeNodeGetRemoteLoginSettingsResult or 846 ~msrest.pipeline.ClientRawResponse 847 :raises: 848 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 849 """ 850 timeout = None 851 if compute_node_get_remote_login_settings_options is not None: 852 timeout = compute_node_get_remote_login_settings_options.timeout 853 client_request_id = None 854 if compute_node_get_remote_login_settings_options is not None: 855 client_request_id = compute_node_get_remote_login_settings_options.client_request_id 856 return_client_request_id = None 857 if compute_node_get_remote_login_settings_options is not None: 858 return_client_request_id = compute_node_get_remote_login_settings_options.return_client_request_id 859 ocp_date = None 860 if compute_node_get_remote_login_settings_options is not None: 861 ocp_date = compute_node_get_remote_login_settings_options.ocp_date 862 863 # Construct URL 864 url = self.get_remote_login_settings.metadata['url'] 865 path_format_arguments = { 866 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 867 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 868 'nodeId': self._serialize.url("node_id", node_id, 'str') 869 } 870 url = self._client.format_url(url, **path_format_arguments) 871 872 # Construct parameters 873 query_parameters = {} 874 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 875 if timeout is not None: 876 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 877 878 # Construct headers 879 header_parameters = {} 880 header_parameters['Accept'] = 'application/json' 881 if self.config.generate_client_request_id: 882 header_parameters['client-request-id'] = str(uuid.uuid1()) 883 if custom_headers: 884 header_parameters.update(custom_headers) 885 if self.config.accept_language is not None: 886 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 887 if client_request_id is not None: 888 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 889 if return_client_request_id is not None: 890 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 891 if ocp_date is not None: 892 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 893 894 # Construct and send request 895 request = self._client.get(url, query_parameters, header_parameters) 896 response = self._client.send(request, stream=False, **operation_config) 897 898 if response.status_code not in [200]: 899 raise models.BatchErrorException(self._deserialize, response) 900 901 header_dict = {} 902 deserialized = None 903 if response.status_code == 200: 904 deserialized = self._deserialize('ComputeNodeGetRemoteLoginSettingsResult', response) 905 header_dict = { 906 'client-request-id': 'str', 907 'request-id': 'str', 908 'ETag': 'str', 909 'Last-Modified': 'rfc-1123', 910 } 911 912 if raw: 913 client_raw_response = ClientRawResponse(deserialized, response) 914 client_raw_response.add_headers(header_dict) 915 return client_raw_response 916 917 return deserialized 918 get_remote_login_settings.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/remoteloginsettings'} 919 920 def get_remote_desktop( 921 self, pool_id, node_id, compute_node_get_remote_desktop_options=None, custom_headers=None, raw=False, callback=None, **operation_config): 922 """Gets the Remote Desktop Protocol file for the specified Compute Node. 923 924 Before you can access a Compute Node by using the RDP file, you must 925 create a user Account on the Compute Node. This API can only be invoked 926 on Pools created with a cloud service configuration. For Pools created 927 with a virtual machine configuration, see the GetRemoteLoginSettings 928 API. 929 930 :param pool_id: The ID of the Pool that contains the Compute Node. 931 :type pool_id: str 932 :param node_id: The ID of the Compute Node for which you want to get 933 the Remote Desktop Protocol file. 934 :type node_id: str 935 :param compute_node_get_remote_desktop_options: Additional parameters 936 for the operation 937 :type compute_node_get_remote_desktop_options: 938 ~azure.batch.models.ComputeNodeGetRemoteDesktopOptions 939 :param dict custom_headers: headers that will be added to the request 940 :param bool raw: returns the direct response alongside the 941 deserialized response 942 :param callback: When specified, will be called with each chunk of 943 data that is streamed. The callback should take two arguments, the 944 bytes of the current chunk of data and the response object. If the 945 data is uploading, response will be None. 946 :type callback: Callable[Bytes, response=None] 947 :param operation_config: :ref:`Operation configuration 948 overrides<msrest:optionsforoperations>`. 949 :return: object or ClientRawResponse if raw=true 950 :rtype: Generator or ~msrest.pipeline.ClientRawResponse 951 :raises: 952 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 953 """ 954 timeout = None 955 if compute_node_get_remote_desktop_options is not None: 956 timeout = compute_node_get_remote_desktop_options.timeout 957 client_request_id = None 958 if compute_node_get_remote_desktop_options is not None: 959 client_request_id = compute_node_get_remote_desktop_options.client_request_id 960 return_client_request_id = None 961 if compute_node_get_remote_desktop_options is not None: 962 return_client_request_id = compute_node_get_remote_desktop_options.return_client_request_id 963 ocp_date = None 964 if compute_node_get_remote_desktop_options is not None: 965 ocp_date = compute_node_get_remote_desktop_options.ocp_date 966 967 # Construct URL 968 url = self.get_remote_desktop.metadata['url'] 969 path_format_arguments = { 970 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 971 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 972 'nodeId': self._serialize.url("node_id", node_id, 'str') 973 } 974 url = self._client.format_url(url, **path_format_arguments) 975 976 # Construct parameters 977 query_parameters = {} 978 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 979 if timeout is not None: 980 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 981 982 # Construct headers 983 header_parameters = {} 984 header_parameters['Accept'] = 'application/json' 985 if self.config.generate_client_request_id: 986 header_parameters['client-request-id'] = str(uuid.uuid1()) 987 if custom_headers: 988 header_parameters.update(custom_headers) 989 if self.config.accept_language is not None: 990 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 991 if client_request_id is not None: 992 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 993 if return_client_request_id is not None: 994 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 995 if ocp_date is not None: 996 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 997 998 # Construct and send request 999 request = self._client.get(url, query_parameters, header_parameters) 1000 response = self._client.send(request, stream=True, **operation_config) 1001 1002 if response.status_code not in [200]: 1003 raise models.BatchErrorException(self._deserialize, response) 1004 1005 header_dict = {} 1006 deserialized = self._client.stream_download(response, callback) 1007 1008 if raw: 1009 client_raw_response = ClientRawResponse(deserialized, response) 1010 client_raw_response.add_headers(header_dict) 1011 return client_raw_response 1012 1013 return deserialized 1014 get_remote_desktop.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/rdp'} 1015 1016 def upload_batch_service_logs( 1017 self, pool_id, node_id, upload_batch_service_logs_configuration, compute_node_upload_batch_service_logs_options=None, custom_headers=None, raw=False, **operation_config): 1018 """Upload Azure Batch service log files from the specified Compute Node to 1019 Azure Blob Storage. 1020 1021 This is for gathering Azure Batch service log files in an automated 1022 fashion from Compute Nodes if you are experiencing an error and wish to 1023 escalate to Azure support. The Azure Batch service log files should be 1024 shared with Azure support to aid in debugging issues with the Batch 1025 service. 1026 1027 :param pool_id: The ID of the Pool that contains the Compute Node. 1028 :type pool_id: str 1029 :param node_id: The ID of the Compute Node from which you want to 1030 upload the Azure Batch service log files. 1031 :type node_id: str 1032 :param upload_batch_service_logs_configuration: The Azure Batch 1033 service log files upload configuration. 1034 :type upload_batch_service_logs_configuration: 1035 ~azure.batch.models.UploadBatchServiceLogsConfiguration 1036 :param compute_node_upload_batch_service_logs_options: Additional 1037 parameters for the operation 1038 :type compute_node_upload_batch_service_logs_options: 1039 ~azure.batch.models.ComputeNodeUploadBatchServiceLogsOptions 1040 :param dict custom_headers: headers that will be added to the request 1041 :param bool raw: returns the direct response alongside the 1042 deserialized response 1043 :param operation_config: :ref:`Operation configuration 1044 overrides<msrest:optionsforoperations>`. 1045 :return: UploadBatchServiceLogsResult or ClientRawResponse if raw=true 1046 :rtype: ~azure.batch.models.UploadBatchServiceLogsResult or 1047 ~msrest.pipeline.ClientRawResponse 1048 :raises: 1049 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 1050 """ 1051 timeout = None 1052 if compute_node_upload_batch_service_logs_options is not None: 1053 timeout = compute_node_upload_batch_service_logs_options.timeout 1054 client_request_id = None 1055 if compute_node_upload_batch_service_logs_options is not None: 1056 client_request_id = compute_node_upload_batch_service_logs_options.client_request_id 1057 return_client_request_id = None 1058 if compute_node_upload_batch_service_logs_options is not None: 1059 return_client_request_id = compute_node_upload_batch_service_logs_options.return_client_request_id 1060 ocp_date = None 1061 if compute_node_upload_batch_service_logs_options is not None: 1062 ocp_date = compute_node_upload_batch_service_logs_options.ocp_date 1063 1064 # Construct URL 1065 url = self.upload_batch_service_logs.metadata['url'] 1066 path_format_arguments = { 1067 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 1068 'poolId': self._serialize.url("pool_id", pool_id, 'str'), 1069 'nodeId': self._serialize.url("node_id", node_id, 'str') 1070 } 1071 url = self._client.format_url(url, **path_format_arguments) 1072 1073 # Construct parameters 1074 query_parameters = {} 1075 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 1076 if timeout is not None: 1077 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 1078 1079 # Construct headers 1080 header_parameters = {} 1081 header_parameters['Accept'] = 'application/json' 1082 header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' 1083 if self.config.generate_client_request_id: 1084 header_parameters['client-request-id'] = str(uuid.uuid1()) 1085 if custom_headers: 1086 header_parameters.update(custom_headers) 1087 if self.config.accept_language is not None: 1088 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 1089 if client_request_id is not None: 1090 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 1091 if return_client_request_id is not None: 1092 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 1093 if ocp_date is not None: 1094 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 1095 1096 # Construct body 1097 body_content = self._serialize.body(upload_batch_service_logs_configuration, 'UploadBatchServiceLogsConfiguration') 1098 1099 # Construct and send request 1100 request = self._client.post(url, query_parameters, header_parameters, body_content) 1101 response = self._client.send(request, stream=False, **operation_config) 1102 1103 if response.status_code not in [200]: 1104 raise models.BatchErrorException(self._deserialize, response) 1105 1106 header_dict = {} 1107 deserialized = None 1108 if response.status_code == 200: 1109 deserialized = self._deserialize('UploadBatchServiceLogsResult', response) 1110 header_dict = { 1111 'client-request-id': 'str', 1112 'request-id': 'str', 1113 } 1114 1115 if raw: 1116 client_raw_response = ClientRawResponse(deserialized, response) 1117 client_raw_response.add_headers(header_dict) 1118 return client_raw_response 1119 1120 return deserialized 1121 upload_batch_service_logs.metadata = {'url': '/pools/{poolId}/nodes/{nodeId}/uploadbatchservicelogs'} 1122 1123 def list( 1124 self, pool_id, compute_node_list_options=None, custom_headers=None, raw=False, **operation_config): 1125 """Lists the Compute Nodes in the specified Pool. 1126 1127 :param pool_id: The ID of the Pool from which you want to list Compute 1128 Nodes. 1129 :type pool_id: str 1130 :param compute_node_list_options: Additional parameters for the 1131 operation 1132 :type compute_node_list_options: 1133 ~azure.batch.models.ComputeNodeListOptions 1134 :param dict custom_headers: headers that will be added to the request 1135 :param bool raw: returns the direct response alongside the 1136 deserialized response 1137 :param operation_config: :ref:`Operation configuration 1138 overrides<msrest:optionsforoperations>`. 1139 :return: An iterator like instance of ComputeNode 1140 :rtype: 1141 ~azure.batch.models.ComputeNodePaged[~azure.batch.models.ComputeNode] 1142 :raises: 1143 :class:`BatchErrorException<azure.batch.models.BatchErrorException>` 1144 """ 1145 filter = None 1146 if compute_node_list_options is not None: 1147 filter = compute_node_list_options.filter 1148 select = None 1149 if compute_node_list_options is not None: 1150 select = compute_node_list_options.select 1151 max_results = None 1152 if compute_node_list_options is not None: 1153 max_results = compute_node_list_options.max_results 1154 timeout = None 1155 if compute_node_list_options is not None: 1156 timeout = compute_node_list_options.timeout 1157 client_request_id = None 1158 if compute_node_list_options is not None: 1159 client_request_id = compute_node_list_options.client_request_id 1160 return_client_request_id = None 1161 if compute_node_list_options is not None: 1162 return_client_request_id = compute_node_list_options.return_client_request_id 1163 ocp_date = None 1164 if compute_node_list_options is not None: 1165 ocp_date = compute_node_list_options.ocp_date 1166 1167 def prepare_request(next_link=None): 1168 if not next_link: 1169 # Construct URL 1170 url = self.list.metadata['url'] 1171 path_format_arguments = { 1172 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 1173 'poolId': self._serialize.url("pool_id", pool_id, 'str') 1174 } 1175 url = self._client.format_url(url, **path_format_arguments) 1176 1177 # Construct parameters 1178 query_parameters = {} 1179 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 1180 if filter is not None: 1181 query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') 1182 if select is not None: 1183 query_parameters['$select'] = self._serialize.query("select", select, 'str') 1184 if max_results is not None: 1185 query_parameters['maxresults'] = self._serialize.query("max_results", max_results, 'int', maximum=1000, minimum=1) 1186 if timeout is not None: 1187 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') 1188 1189 else: 1190 url = next_link 1191 query_parameters = {} 1192 1193 # Construct headers 1194 header_parameters = {} 1195 header_parameters['Accept'] = 'application/json' 1196 if self.config.generate_client_request_id: 1197 header_parameters['client-request-id'] = str(uuid.uuid1()) 1198 if custom_headers: 1199 header_parameters.update(custom_headers) 1200 if self.config.accept_language is not None: 1201 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 1202 if client_request_id is not None: 1203 header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') 1204 if return_client_request_id is not None: 1205 header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') 1206 if ocp_date is not None: 1207 header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') 1208 1209 # Construct and send request 1210 request = self._client.get(url, query_parameters, header_parameters) 1211 return request 1212 1213 def internal_paging(next_link=None): 1214 request = prepare_request(next_link) 1215 1216 response = self._client.send(request, stream=False, **operation_config) 1217 1218 if response.status_code not in [200]: 1219 raise models.BatchErrorException(self._deserialize, response) 1220 1221 return response 1222 1223 # Deserialize response 1224 header_dict = None 1225 if raw: 1226 header_dict = {} 1227 deserialized = models.ComputeNodePaged(internal_paging, self._deserialize.dependencies, header_dict) 1228 1229 return deserialized 1230 list.metadata = {'url': '/pools/{poolId}/nodes'} 1231