1# coding: utf-8 2# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. 3# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. 4 5 6from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 7from oci.decorators import init_model_state_from_kwargs 8 9 10@init_model_state_from_kwargs 11class Job(object): 12 """ 13 The properties that define a job. Jobs perform the actions that are defined in your configuration. 14 - **Plan job**. A plan job takes your Terraform configuration, parses it, and creates an execution plan. 15 - **Apply job**. The apply job takes your execution plan, applies it to the associated stack, then executes 16 the configuration's instructions. 17 - **Destroy job**. To clean up the infrastructure controlled by the stack, you run a destroy job. 18 A destroy job does not delete the stack or associated job resources, 19 but instead releases the resources managed by the stack. 20 - **Import_TF_State job**. An import Terraform state job takes a Terraform state file and sets it as the current 21 state of the stack. This is used to migrate local Terraform environments to Resource Manager. 22 """ 23 24 #: A constant which can be used with the operation property of a Job. 25 #: This constant has a value of "PLAN" 26 OPERATION_PLAN = "PLAN" 27 28 #: A constant which can be used with the operation property of a Job. 29 #: This constant has a value of "APPLY" 30 OPERATION_APPLY = "APPLY" 31 32 #: A constant which can be used with the operation property of a Job. 33 #: This constant has a value of "DESTROY" 34 OPERATION_DESTROY = "DESTROY" 35 36 #: A constant which can be used with the operation property of a Job. 37 #: This constant has a value of "IMPORT_TF_STATE" 38 OPERATION_IMPORT_TF_STATE = "IMPORT_TF_STATE" 39 40 #: A constant which can be used with the lifecycle_state property of a Job. 41 #: This constant has a value of "ACCEPTED" 42 LIFECYCLE_STATE_ACCEPTED = "ACCEPTED" 43 44 #: A constant which can be used with the lifecycle_state property of a Job. 45 #: This constant has a value of "IN_PROGRESS" 46 LIFECYCLE_STATE_IN_PROGRESS = "IN_PROGRESS" 47 48 #: A constant which can be used with the lifecycle_state property of a Job. 49 #: This constant has a value of "FAILED" 50 LIFECYCLE_STATE_FAILED = "FAILED" 51 52 #: A constant which can be used with the lifecycle_state property of a Job. 53 #: This constant has a value of "SUCCEEDED" 54 LIFECYCLE_STATE_SUCCEEDED = "SUCCEEDED" 55 56 #: A constant which can be used with the lifecycle_state property of a Job. 57 #: This constant has a value of "CANCELING" 58 LIFECYCLE_STATE_CANCELING = "CANCELING" 59 60 #: A constant which can be used with the lifecycle_state property of a Job. 61 #: This constant has a value of "CANCELED" 62 LIFECYCLE_STATE_CANCELED = "CANCELED" 63 64 def __init__(self, **kwargs): 65 """ 66 Initializes a new Job object with values from keyword arguments. 67 The following keyword arguments are supported (corresponding to the getters/setters of this class): 68 69 :param id: 70 The value to assign to the id property of this Job. 71 :type id: str 72 73 :param stack_id: 74 The value to assign to the stack_id property of this Job. 75 :type stack_id: str 76 77 :param compartment_id: 78 The value to assign to the compartment_id property of this Job. 79 :type compartment_id: str 80 81 :param display_name: 82 The value to assign to the display_name property of this Job. 83 :type display_name: str 84 85 :param operation: 86 The value to assign to the operation property of this Job. 87 Allowed values for this property are: "PLAN", "APPLY", "DESTROY", "IMPORT_TF_STATE", 'UNKNOWN_ENUM_VALUE'. 88 Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. 89 :type operation: str 90 91 :param job_operation_details: 92 The value to assign to the job_operation_details property of this Job. 93 :type job_operation_details: oci.resource_manager.models.JobOperationDetails 94 95 :param apply_job_plan_resolution: 96 The value to assign to the apply_job_plan_resolution property of this Job. 97 :type apply_job_plan_resolution: oci.resource_manager.models.ApplyJobPlanResolution 98 99 :param resolved_plan_job_id: 100 The value to assign to the resolved_plan_job_id property of this Job. 101 :type resolved_plan_job_id: str 102 103 :param time_created: 104 The value to assign to the time_created property of this Job. 105 :type time_created: datetime 106 107 :param time_finished: 108 The value to assign to the time_finished property of this Job. 109 :type time_finished: datetime 110 111 :param lifecycle_state: 112 The value to assign to the lifecycle_state property of this Job. 113 Allowed values for this property are: "ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", 'UNKNOWN_ENUM_VALUE'. 114 Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. 115 :type lifecycle_state: str 116 117 :param failure_details: 118 The value to assign to the failure_details property of this Job. 119 :type failure_details: oci.resource_manager.models.FailureDetails 120 121 :param cancellation_details: 122 The value to assign to the cancellation_details property of this Job. 123 :type cancellation_details: oci.resource_manager.models.CancellationDetails 124 125 :param working_directory: 126 The value to assign to the working_directory property of this Job. 127 :type working_directory: str 128 129 :param variables: 130 The value to assign to the variables property of this Job. 131 :type variables: dict(str, str) 132 133 :param config_source: 134 The value to assign to the config_source property of this Job. 135 :type config_source: oci.resource_manager.models.ConfigSourceRecord 136 137 :param freeform_tags: 138 The value to assign to the freeform_tags property of this Job. 139 :type freeform_tags: dict(str, str) 140 141 :param defined_tags: 142 The value to assign to the defined_tags property of this Job. 143 :type defined_tags: dict(str, dict(str, object)) 144 145 """ 146 self.swagger_types = { 147 'id': 'str', 148 'stack_id': 'str', 149 'compartment_id': 'str', 150 'display_name': 'str', 151 'operation': 'str', 152 'job_operation_details': 'JobOperationDetails', 153 'apply_job_plan_resolution': 'ApplyJobPlanResolution', 154 'resolved_plan_job_id': 'str', 155 'time_created': 'datetime', 156 'time_finished': 'datetime', 157 'lifecycle_state': 'str', 158 'failure_details': 'FailureDetails', 159 'cancellation_details': 'CancellationDetails', 160 'working_directory': 'str', 161 'variables': 'dict(str, str)', 162 'config_source': 'ConfigSourceRecord', 163 'freeform_tags': 'dict(str, str)', 164 'defined_tags': 'dict(str, dict(str, object))' 165 } 166 167 self.attribute_map = { 168 'id': 'id', 169 'stack_id': 'stackId', 170 'compartment_id': 'compartmentId', 171 'display_name': 'displayName', 172 'operation': 'operation', 173 'job_operation_details': 'jobOperationDetails', 174 'apply_job_plan_resolution': 'applyJobPlanResolution', 175 'resolved_plan_job_id': 'resolvedPlanJobId', 176 'time_created': 'timeCreated', 177 'time_finished': 'timeFinished', 178 'lifecycle_state': 'lifecycleState', 179 'failure_details': 'failureDetails', 180 'cancellation_details': 'cancellationDetails', 181 'working_directory': 'workingDirectory', 182 'variables': 'variables', 183 'config_source': 'configSource', 184 'freeform_tags': 'freeformTags', 185 'defined_tags': 'definedTags' 186 } 187 188 self._id = None 189 self._stack_id = None 190 self._compartment_id = None 191 self._display_name = None 192 self._operation = None 193 self._job_operation_details = None 194 self._apply_job_plan_resolution = None 195 self._resolved_plan_job_id = None 196 self._time_created = None 197 self._time_finished = None 198 self._lifecycle_state = None 199 self._failure_details = None 200 self._cancellation_details = None 201 self._working_directory = None 202 self._variables = None 203 self._config_source = None 204 self._freeform_tags = None 205 self._defined_tags = None 206 207 @property 208 def id(self): 209 """ 210 Gets the id of this Job. 211 The `OCID`__ of the job. 212 213 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm 214 215 216 :return: The id of this Job. 217 :rtype: str 218 """ 219 return self._id 220 221 @id.setter 222 def id(self, id): 223 """ 224 Sets the id of this Job. 225 The `OCID`__ of the job. 226 227 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm 228 229 230 :param id: The id of this Job. 231 :type: str 232 """ 233 self._id = id 234 235 @property 236 def stack_id(self): 237 """ 238 Gets the stack_id of this Job. 239 The `OCID`__ of the stack that is associated with the job. 240 241 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm 242 243 244 :return: The stack_id of this Job. 245 :rtype: str 246 """ 247 return self._stack_id 248 249 @stack_id.setter 250 def stack_id(self, stack_id): 251 """ 252 Sets the stack_id of this Job. 253 The `OCID`__ of the stack that is associated with the job. 254 255 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm 256 257 258 :param stack_id: The stack_id of this Job. 259 :type: str 260 """ 261 self._stack_id = stack_id 262 263 @property 264 def compartment_id(self): 265 """ 266 Gets the compartment_id of this Job. 267 The `OCID`__ of the compartment in which the job's associated stack resides. 268 269 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm 270 271 272 :return: The compartment_id of this Job. 273 :rtype: str 274 """ 275 return self._compartment_id 276 277 @compartment_id.setter 278 def compartment_id(self, compartment_id): 279 """ 280 Sets the compartment_id of this Job. 281 The `OCID`__ of the compartment in which the job's associated stack resides. 282 283 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm 284 285 286 :param compartment_id: The compartment_id of this Job. 287 :type: str 288 """ 289 self._compartment_id = compartment_id 290 291 @property 292 def display_name(self): 293 """ 294 Gets the display_name of this Job. 295 The job's display name. 296 297 298 :return: The display_name of this Job. 299 :rtype: str 300 """ 301 return self._display_name 302 303 @display_name.setter 304 def display_name(self, display_name): 305 """ 306 Sets the display_name of this Job. 307 The job's display name. 308 309 310 :param display_name: The display_name of this Job. 311 :type: str 312 """ 313 self._display_name = display_name 314 315 @property 316 def operation(self): 317 """ 318 Gets the operation of this Job. 319 The type of job executing. 320 321 Allowed values for this property are: "PLAN", "APPLY", "DESTROY", "IMPORT_TF_STATE", 'UNKNOWN_ENUM_VALUE'. 322 Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. 323 324 325 :return: The operation of this Job. 326 :rtype: str 327 """ 328 return self._operation 329 330 @operation.setter 331 def operation(self, operation): 332 """ 333 Sets the operation of this Job. 334 The type of job executing. 335 336 337 :param operation: The operation of this Job. 338 :type: str 339 """ 340 allowed_values = ["PLAN", "APPLY", "DESTROY", "IMPORT_TF_STATE"] 341 if not value_allowed_none_or_none_sentinel(operation, allowed_values): 342 operation = 'UNKNOWN_ENUM_VALUE' 343 self._operation = operation 344 345 @property 346 def job_operation_details(self): 347 """ 348 Gets the job_operation_details of this Job. 349 350 :return: The job_operation_details of this Job. 351 :rtype: oci.resource_manager.models.JobOperationDetails 352 """ 353 return self._job_operation_details 354 355 @job_operation_details.setter 356 def job_operation_details(self, job_operation_details): 357 """ 358 Sets the job_operation_details of this Job. 359 360 :param job_operation_details: The job_operation_details of this Job. 361 :type: oci.resource_manager.models.JobOperationDetails 362 """ 363 self._job_operation_details = job_operation_details 364 365 @property 366 def apply_job_plan_resolution(self): 367 """ 368 Gets the apply_job_plan_resolution of this Job. 369 370 :return: The apply_job_plan_resolution of this Job. 371 :rtype: oci.resource_manager.models.ApplyJobPlanResolution 372 """ 373 return self._apply_job_plan_resolution 374 375 @apply_job_plan_resolution.setter 376 def apply_job_plan_resolution(self, apply_job_plan_resolution): 377 """ 378 Sets the apply_job_plan_resolution of this Job. 379 380 :param apply_job_plan_resolution: The apply_job_plan_resolution of this Job. 381 :type: oci.resource_manager.models.ApplyJobPlanResolution 382 """ 383 self._apply_job_plan_resolution = apply_job_plan_resolution 384 385 @property 386 def resolved_plan_job_id(self): 387 """ 388 Gets the resolved_plan_job_id of this Job. 389 Deprecated. Use the property `executionPlanJobId` in `jobOperationDetails` instead. 390 The plan job `OCID`__ that was used (if this was an apply job and was not auto-approved). 391 392 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm 393 394 395 :return: The resolved_plan_job_id of this Job. 396 :rtype: str 397 """ 398 return self._resolved_plan_job_id 399 400 @resolved_plan_job_id.setter 401 def resolved_plan_job_id(self, resolved_plan_job_id): 402 """ 403 Sets the resolved_plan_job_id of this Job. 404 Deprecated. Use the property `executionPlanJobId` in `jobOperationDetails` instead. 405 The plan job `OCID`__ that was used (if this was an apply job and was not auto-approved). 406 407 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm 408 409 410 :param resolved_plan_job_id: The resolved_plan_job_id of this Job. 411 :type: str 412 """ 413 self._resolved_plan_job_id = resolved_plan_job_id 414 415 @property 416 def time_created(self): 417 """ 418 Gets the time_created of this Job. 419 The date and time when the job was created. 420 Format is defined by RFC3339. 421 Example: `2020-01-25T21:10:29.600Z` 422 423 424 :return: The time_created of this Job. 425 :rtype: datetime 426 """ 427 return self._time_created 428 429 @time_created.setter 430 def time_created(self, time_created): 431 """ 432 Sets the time_created of this Job. 433 The date and time when the job was created. 434 Format is defined by RFC3339. 435 Example: `2020-01-25T21:10:29.600Z` 436 437 438 :param time_created: The time_created of this Job. 439 :type: datetime 440 """ 441 self._time_created = time_created 442 443 @property 444 def time_finished(self): 445 """ 446 Gets the time_finished of this Job. 447 The date and time when the job stopped running, irrespective of whether the job ran successfully. 448 Format is defined by RFC3339. 449 Example: `2020-01-25T21:10:29.600Z` 450 451 452 :return: The time_finished of this Job. 453 :rtype: datetime 454 """ 455 return self._time_finished 456 457 @time_finished.setter 458 def time_finished(self, time_finished): 459 """ 460 Sets the time_finished of this Job. 461 The date and time when the job stopped running, irrespective of whether the job ran successfully. 462 Format is defined by RFC3339. 463 Example: `2020-01-25T21:10:29.600Z` 464 465 466 :param time_finished: The time_finished of this Job. 467 :type: datetime 468 """ 469 self._time_finished = time_finished 470 471 @property 472 def lifecycle_state(self): 473 """ 474 Gets the lifecycle_state of this Job. 475 Current state of the specified job. 476 For more information about job lifecycle states in Resource Manager, see 477 `Key Concepts`__. 478 479 __ https://docs.cloud.oracle.com/iaas/Content/ResourceManager/Concepts/resourcemanager.htm#concepts__JobStates 480 481 Allowed values for this property are: "ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", 'UNKNOWN_ENUM_VALUE'. 482 Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. 483 484 485 :return: The lifecycle_state of this Job. 486 :rtype: str 487 """ 488 return self._lifecycle_state 489 490 @lifecycle_state.setter 491 def lifecycle_state(self, lifecycle_state): 492 """ 493 Sets the lifecycle_state of this Job. 494 Current state of the specified job. 495 For more information about job lifecycle states in Resource Manager, see 496 `Key Concepts`__. 497 498 __ https://docs.cloud.oracle.com/iaas/Content/ResourceManager/Concepts/resourcemanager.htm#concepts__JobStates 499 500 501 :param lifecycle_state: The lifecycle_state of this Job. 502 :type: str 503 """ 504 allowed_values = ["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED"] 505 if not value_allowed_none_or_none_sentinel(lifecycle_state, allowed_values): 506 lifecycle_state = 'UNKNOWN_ENUM_VALUE' 507 self._lifecycle_state = lifecycle_state 508 509 @property 510 def failure_details(self): 511 """ 512 Gets the failure_details of this Job. 513 514 :return: The failure_details of this Job. 515 :rtype: oci.resource_manager.models.FailureDetails 516 """ 517 return self._failure_details 518 519 @failure_details.setter 520 def failure_details(self, failure_details): 521 """ 522 Sets the failure_details of this Job. 523 524 :param failure_details: The failure_details of this Job. 525 :type: oci.resource_manager.models.FailureDetails 526 """ 527 self._failure_details = failure_details 528 529 @property 530 def cancellation_details(self): 531 """ 532 Gets the cancellation_details of this Job. 533 534 :return: The cancellation_details of this Job. 535 :rtype: oci.resource_manager.models.CancellationDetails 536 """ 537 return self._cancellation_details 538 539 @cancellation_details.setter 540 def cancellation_details(self, cancellation_details): 541 """ 542 Sets the cancellation_details of this Job. 543 544 :param cancellation_details: The cancellation_details of this Job. 545 :type: oci.resource_manager.models.CancellationDetails 546 """ 547 self._cancellation_details = cancellation_details 548 549 @property 550 def working_directory(self): 551 """ 552 Gets the working_directory of this Job. 553 File path to the directory from which Terraform runs. 554 If not specified, the root directory is used. 555 This parameter is ignored for the `configSourceType` value of `COMPARTMENT_CONFIG_SOURCE`. 556 557 558 :return: The working_directory of this Job. 559 :rtype: str 560 """ 561 return self._working_directory 562 563 @working_directory.setter 564 def working_directory(self, working_directory): 565 """ 566 Sets the working_directory of this Job. 567 File path to the directory from which Terraform runs. 568 If not specified, the root directory is used. 569 This parameter is ignored for the `configSourceType` value of `COMPARTMENT_CONFIG_SOURCE`. 570 571 572 :param working_directory: The working_directory of this Job. 573 :type: str 574 """ 575 self._working_directory = working_directory 576 577 @property 578 def variables(self): 579 """ 580 Gets the variables of this Job. 581 Terraform variables associated with this resource. 582 Maximum number of variables supported is 250. 583 The maximum size of each variable, including both name and value, is 8192 bytes. 584 Example: `{\"CompartmentId\": \"compartment-id-value\"}` 585 586 587 :return: The variables of this Job. 588 :rtype: dict(str, str) 589 """ 590 return self._variables 591 592 @variables.setter 593 def variables(self, variables): 594 """ 595 Sets the variables of this Job. 596 Terraform variables associated with this resource. 597 Maximum number of variables supported is 250. 598 The maximum size of each variable, including both name and value, is 8192 bytes. 599 Example: `{\"CompartmentId\": \"compartment-id-value\"}` 600 601 602 :param variables: The variables of this Job. 603 :type: dict(str, str) 604 """ 605 self._variables = variables 606 607 @property 608 def config_source(self): 609 """ 610 Gets the config_source of this Job. 611 612 :return: The config_source of this Job. 613 :rtype: oci.resource_manager.models.ConfigSourceRecord 614 """ 615 return self._config_source 616 617 @config_source.setter 618 def config_source(self, config_source): 619 """ 620 Sets the config_source of this Job. 621 622 :param config_source: The config_source of this Job. 623 :type: oci.resource_manager.models.ConfigSourceRecord 624 """ 625 self._config_source = config_source 626 627 @property 628 def freeform_tags(self): 629 """ 630 Gets the freeform_tags of this Job. 631 Free-form tags associated with this resource. Each tag is a key-value pair with no predefined name, type, or namespace. 632 For more information, see `Resource Tags`__. 633 Example: `{\"Department\": \"Finance\"}` 634 635 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm 636 637 638 :return: The freeform_tags of this Job. 639 :rtype: dict(str, str) 640 """ 641 return self._freeform_tags 642 643 @freeform_tags.setter 644 def freeform_tags(self, freeform_tags): 645 """ 646 Sets the freeform_tags of this Job. 647 Free-form tags associated with this resource. Each tag is a key-value pair with no predefined name, type, or namespace. 648 For more information, see `Resource Tags`__. 649 Example: `{\"Department\": \"Finance\"}` 650 651 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm 652 653 654 :param freeform_tags: The freeform_tags of this Job. 655 :type: dict(str, str) 656 """ 657 self._freeform_tags = freeform_tags 658 659 @property 660 def defined_tags(self): 661 """ 662 Gets the defined_tags of this Job. 663 Defined tags for this resource. Each key is predefined and scoped to a namespace. 664 For more information, see `Resource Tags`__. 665 Example: `{\"Operations\": {\"CostCenter\": \"42\"}}` 666 667 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm 668 669 670 :return: The defined_tags of this Job. 671 :rtype: dict(str, dict(str, object)) 672 """ 673 return self._defined_tags 674 675 @defined_tags.setter 676 def defined_tags(self, defined_tags): 677 """ 678 Sets the defined_tags of this Job. 679 Defined tags for this resource. Each key is predefined and scoped to a namespace. 680 For more information, see `Resource Tags`__. 681 Example: `{\"Operations\": {\"CostCenter\": \"42\"}}` 682 683 __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm 684 685 686 :param defined_tags: The defined_tags of this Job. 687 :type: dict(str, dict(str, object)) 688 """ 689 self._defined_tags = defined_tags 690 691 def __repr__(self): 692 return formatted_flat_dict(self) 693 694 def __eq__(self, other): 695 if other is None: 696 return False 697 698 return self.__dict__ == other.__dict__ 699 700 def __ne__(self, other): 701 return not self == other 702