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 SteeringPolicy(object):
12    """
13    A DNS steering policy.
14
15    **Warning:** Oracle recommends that you avoid using any confidential information when you supply string values using the API.
16    """
17
18    #: A constant which can be used with the template property of a SteeringPolicy.
19    #: This constant has a value of "FAILOVER"
20    TEMPLATE_FAILOVER = "FAILOVER"
21
22    #: A constant which can be used with the template property of a SteeringPolicy.
23    #: This constant has a value of "LOAD_BALANCE"
24    TEMPLATE_LOAD_BALANCE = "LOAD_BALANCE"
25
26    #: A constant which can be used with the template property of a SteeringPolicy.
27    #: This constant has a value of "ROUTE_BY_GEO"
28    TEMPLATE_ROUTE_BY_GEO = "ROUTE_BY_GEO"
29
30    #: A constant which can be used with the template property of a SteeringPolicy.
31    #: This constant has a value of "ROUTE_BY_ASN"
32    TEMPLATE_ROUTE_BY_ASN = "ROUTE_BY_ASN"
33
34    #: A constant which can be used with the template property of a SteeringPolicy.
35    #: This constant has a value of "ROUTE_BY_IP"
36    TEMPLATE_ROUTE_BY_IP = "ROUTE_BY_IP"
37
38    #: A constant which can be used with the template property of a SteeringPolicy.
39    #: This constant has a value of "CUSTOM"
40    TEMPLATE_CUSTOM = "CUSTOM"
41
42    #: A constant which can be used with the lifecycle_state property of a SteeringPolicy.
43    #: This constant has a value of "ACTIVE"
44    LIFECYCLE_STATE_ACTIVE = "ACTIVE"
45
46    #: A constant which can be used with the lifecycle_state property of a SteeringPolicy.
47    #: This constant has a value of "CREATING"
48    LIFECYCLE_STATE_CREATING = "CREATING"
49
50    #: A constant which can be used with the lifecycle_state property of a SteeringPolicy.
51    #: This constant has a value of "DELETED"
52    LIFECYCLE_STATE_DELETED = "DELETED"
53
54    #: A constant which can be used with the lifecycle_state property of a SteeringPolicy.
55    #: This constant has a value of "DELETING"
56    LIFECYCLE_STATE_DELETING = "DELETING"
57
58    def __init__(self, **kwargs):
59        """
60        Initializes a new SteeringPolicy object with values from keyword arguments.
61        The following keyword arguments are supported (corresponding to the getters/setters of this class):
62
63        :param compartment_id:
64            The value to assign to the compartment_id property of this SteeringPolicy.
65        :type compartment_id: str
66
67        :param display_name:
68            The value to assign to the display_name property of this SteeringPolicy.
69        :type display_name: str
70
71        :param ttl:
72            The value to assign to the ttl property of this SteeringPolicy.
73        :type ttl: int
74
75        :param health_check_monitor_id:
76            The value to assign to the health_check_monitor_id property of this SteeringPolicy.
77        :type health_check_monitor_id: str
78
79        :param template:
80            The value to assign to the template property of this SteeringPolicy.
81            Allowed values for this property are: "FAILOVER", "LOAD_BALANCE", "ROUTE_BY_GEO", "ROUTE_BY_ASN", "ROUTE_BY_IP", "CUSTOM", 'UNKNOWN_ENUM_VALUE'.
82            Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'.
83        :type template: str
84
85        :param freeform_tags:
86            The value to assign to the freeform_tags property of this SteeringPolicy.
87        :type freeform_tags: dict(str, str)
88
89        :param defined_tags:
90            The value to assign to the defined_tags property of this SteeringPolicy.
91        :type defined_tags: dict(str, dict(str, object))
92
93        :param answers:
94            The value to assign to the answers property of this SteeringPolicy.
95        :type answers: list[oci.dns.models.SteeringPolicyAnswer]
96
97        :param rules:
98            The value to assign to the rules property of this SteeringPolicy.
99        :type rules: list[oci.dns.models.SteeringPolicyRule]
100
101        :param _self:
102            The value to assign to the _self property of this SteeringPolicy.
103        :type _self: str
104
105        :param id:
106            The value to assign to the id property of this SteeringPolicy.
107        :type id: str
108
109        :param time_created:
110            The value to assign to the time_created property of this SteeringPolicy.
111        :type time_created: datetime
112
113        :param lifecycle_state:
114            The value to assign to the lifecycle_state property of this SteeringPolicy.
115            Allowed values for this property are: "ACTIVE", "CREATING", "DELETED", "DELETING", 'UNKNOWN_ENUM_VALUE'.
116            Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'.
117        :type lifecycle_state: str
118
119        """
120        self.swagger_types = {
121            'compartment_id': 'str',
122            'display_name': 'str',
123            'ttl': 'int',
124            'health_check_monitor_id': 'str',
125            'template': 'str',
126            'freeform_tags': 'dict(str, str)',
127            'defined_tags': 'dict(str, dict(str, object))',
128            'answers': 'list[SteeringPolicyAnswer]',
129            'rules': 'list[SteeringPolicyRule]',
130            '_self': 'str',
131            'id': 'str',
132            'time_created': 'datetime',
133            'lifecycle_state': 'str'
134        }
135
136        self.attribute_map = {
137            'compartment_id': 'compartmentId',
138            'display_name': 'displayName',
139            'ttl': 'ttl',
140            'health_check_monitor_id': 'healthCheckMonitorId',
141            'template': 'template',
142            'freeform_tags': 'freeformTags',
143            'defined_tags': 'definedTags',
144            'answers': 'answers',
145            'rules': 'rules',
146            '_self': 'self',
147            'id': 'id',
148            'time_created': 'timeCreated',
149            'lifecycle_state': 'lifecycleState'
150        }
151
152        self._compartment_id = None
153        self._display_name = None
154        self._ttl = None
155        self._health_check_monitor_id = None
156        self._template = None
157        self._freeform_tags = None
158        self._defined_tags = None
159        self._answers = None
160        self._rules = None
161        self.__self = None
162        self._id = None
163        self._time_created = None
164        self._lifecycle_state = None
165
166    @property
167    def compartment_id(self):
168        """
169        **[Required]** Gets the compartment_id of this SteeringPolicy.
170        The OCID of the compartment containing the steering policy.
171
172
173        :return: The compartment_id of this SteeringPolicy.
174        :rtype: str
175        """
176        return self._compartment_id
177
178    @compartment_id.setter
179    def compartment_id(self, compartment_id):
180        """
181        Sets the compartment_id of this SteeringPolicy.
182        The OCID of the compartment containing the steering policy.
183
184
185        :param compartment_id: The compartment_id of this SteeringPolicy.
186        :type: str
187        """
188        self._compartment_id = compartment_id
189
190    @property
191    def display_name(self):
192        """
193        **[Required]** Gets the display_name of this SteeringPolicy.
194        A user-friendly name for the steering policy. Does not have to be unique and can be changed.
195        Avoid entering confidential information.
196
197
198        :return: The display_name of this SteeringPolicy.
199        :rtype: str
200        """
201        return self._display_name
202
203    @display_name.setter
204    def display_name(self, display_name):
205        """
206        Sets the display_name of this SteeringPolicy.
207        A user-friendly name for the steering policy. Does not have to be unique and can be changed.
208        Avoid entering confidential information.
209
210
211        :param display_name: The display_name of this SteeringPolicy.
212        :type: str
213        """
214        self._display_name = display_name
215
216    @property
217    def ttl(self):
218        """
219        **[Required]** Gets the ttl of this SteeringPolicy.
220        The Time To Live (TTL) for responses from the steering policy, in seconds.
221        If not specified during creation, a value of 30 seconds will be used.
222
223
224        :return: The ttl of this SteeringPolicy.
225        :rtype: int
226        """
227        return self._ttl
228
229    @ttl.setter
230    def ttl(self, ttl):
231        """
232        Sets the ttl of this SteeringPolicy.
233        The Time To Live (TTL) for responses from the steering policy, in seconds.
234        If not specified during creation, a value of 30 seconds will be used.
235
236
237        :param ttl: The ttl of this SteeringPolicy.
238        :type: int
239        """
240        self._ttl = ttl
241
242    @property
243    def health_check_monitor_id(self):
244        """
245        Gets the health_check_monitor_id of this SteeringPolicy.
246        The OCID of the health check monitor providing health data about the answers of the
247        steering policy. A steering policy answer with `rdata` matching a monitored endpoint
248        will use the health data of that endpoint. A steering policy answer with `rdata` not
249        matching any monitored endpoint will be assumed healthy.
250
251
252        **Note:** To use the Health Check monitoring feature in a steering policy, a monitor
253        must be created using the Health Checks service first. For more information on how to
254        create a monitor, please see `Managing Health Checks`__.
255
256        __ https://docs.cloud.oracle.com/iaas/Content/HealthChecks/Tasks/managinghealthchecks.htm
257
258
259        :return: The health_check_monitor_id of this SteeringPolicy.
260        :rtype: str
261        """
262        return self._health_check_monitor_id
263
264    @health_check_monitor_id.setter
265    def health_check_monitor_id(self, health_check_monitor_id):
266        """
267        Sets the health_check_monitor_id of this SteeringPolicy.
268        The OCID of the health check monitor providing health data about the answers of the
269        steering policy. A steering policy answer with `rdata` matching a monitored endpoint
270        will use the health data of that endpoint. A steering policy answer with `rdata` not
271        matching any monitored endpoint will be assumed healthy.
272
273
274        **Note:** To use the Health Check monitoring feature in a steering policy, a monitor
275        must be created using the Health Checks service first. For more information on how to
276        create a monitor, please see `Managing Health Checks`__.
277
278        __ https://docs.cloud.oracle.com/iaas/Content/HealthChecks/Tasks/managinghealthchecks.htm
279
280
281        :param health_check_monitor_id: The health_check_monitor_id of this SteeringPolicy.
282        :type: str
283        """
284        self._health_check_monitor_id = health_check_monitor_id
285
286    @property
287    def template(self):
288        """
289        **[Required]** Gets the template of this SteeringPolicy.
290        A set of predefined rules based on the desired purpose of the steering policy. Each
291        template utilizes Traffic Management's rules in a different order to produce the desired
292        results when answering DNS queries.
293
294
295        **Example:** The `FAILOVER` template determines answers by filtering the policy's answers
296        using the `FILTER` rule first, then the following rules in succession: `HEALTH`, `PRIORITY`,
297        and `LIMIT`. This gives the domain dynamic failover capability.
298
299
300        It is **strongly recommended** to use a template other than `CUSTOM` when creating
301        a steering policy.
302
303
304        All templates require the rule order to begin with an unconditional `FILTER` rule that keeps
305        answers contingent upon `answer.isDisabled != true`, except for `CUSTOM`. A defined
306        `HEALTH` rule must follow the `FILTER` rule if the policy references a `healthCheckMonitorId`.
307        The last rule of a template must must be a `LIMIT` rule. For more information about templates
308        and code examples, see `Traffic Management API Guide`__.
309
310        **Template Types**
311
312        * `FAILOVER` - Uses health check information on your endpoints to determine which DNS answers
313        to serve. If an endpoint fails a health check, the answer for that endpoint will be removed
314        from the list of available answers until the endpoint is detected as healthy.
315
316
317        * `LOAD_BALANCE` - Distributes web traffic to specified endpoints based on defined weights.
318
319
320        * `ROUTE_BY_GEO` - Answers DNS queries based on the query's geographic location. For a list of geographic
321        locations to route by, see `Traffic Management Geographic Locations`__.
322
323
324        * `ROUTE_BY_ASN` - Answers DNS queries based on the query's originating ASN.
325
326
327        * `ROUTE_BY_IP` - Answers DNS queries based on the query's IP address.
328
329
330        * `CUSTOM` - Allows a customized configuration of rules.
331
332        __ https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Concepts/trafficmanagementapi.htm
333        __ https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Reference/trafficmanagementgeo.htm
334
335        Allowed values for this property are: "FAILOVER", "LOAD_BALANCE", "ROUTE_BY_GEO", "ROUTE_BY_ASN", "ROUTE_BY_IP", "CUSTOM", 'UNKNOWN_ENUM_VALUE'.
336        Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'.
337
338
339        :return: The template of this SteeringPolicy.
340        :rtype: str
341        """
342        return self._template
343
344    @template.setter
345    def template(self, template):
346        """
347        Sets the template of this SteeringPolicy.
348        A set of predefined rules based on the desired purpose of the steering policy. Each
349        template utilizes Traffic Management's rules in a different order to produce the desired
350        results when answering DNS queries.
351
352
353        **Example:** The `FAILOVER` template determines answers by filtering the policy's answers
354        using the `FILTER` rule first, then the following rules in succession: `HEALTH`, `PRIORITY`,
355        and `LIMIT`. This gives the domain dynamic failover capability.
356
357
358        It is **strongly recommended** to use a template other than `CUSTOM` when creating
359        a steering policy.
360
361
362        All templates require the rule order to begin with an unconditional `FILTER` rule that keeps
363        answers contingent upon `answer.isDisabled != true`, except for `CUSTOM`. A defined
364        `HEALTH` rule must follow the `FILTER` rule if the policy references a `healthCheckMonitorId`.
365        The last rule of a template must must be a `LIMIT` rule. For more information about templates
366        and code examples, see `Traffic Management API Guide`__.
367
368        **Template Types**
369
370        * `FAILOVER` - Uses health check information on your endpoints to determine which DNS answers
371        to serve. If an endpoint fails a health check, the answer for that endpoint will be removed
372        from the list of available answers until the endpoint is detected as healthy.
373
374
375        * `LOAD_BALANCE` - Distributes web traffic to specified endpoints based on defined weights.
376
377
378        * `ROUTE_BY_GEO` - Answers DNS queries based on the query's geographic location. For a list of geographic
379        locations to route by, see `Traffic Management Geographic Locations`__.
380
381
382        * `ROUTE_BY_ASN` - Answers DNS queries based on the query's originating ASN.
383
384
385        * `ROUTE_BY_IP` - Answers DNS queries based on the query's IP address.
386
387
388        * `CUSTOM` - Allows a customized configuration of rules.
389
390        __ https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Concepts/trafficmanagementapi.htm
391        __ https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Reference/trafficmanagementgeo.htm
392
393
394        :param template: The template of this SteeringPolicy.
395        :type: str
396        """
397        allowed_values = ["FAILOVER", "LOAD_BALANCE", "ROUTE_BY_GEO", "ROUTE_BY_ASN", "ROUTE_BY_IP", "CUSTOM"]
398        if not value_allowed_none_or_none_sentinel(template, allowed_values):
399            template = 'UNKNOWN_ENUM_VALUE'
400        self._template = template
401
402    @property
403    def freeform_tags(self):
404        """
405        **[Required]** Gets the freeform_tags of this SteeringPolicy.
406        Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace.
407        For more information, see `Resource Tags`__.
408
409
410        **Example:** `{\"Department\": \"Finance\"}`
411
412        __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm
413
414
415        :return: The freeform_tags of this SteeringPolicy.
416        :rtype: dict(str, str)
417        """
418        return self._freeform_tags
419
420    @freeform_tags.setter
421    def freeform_tags(self, freeform_tags):
422        """
423        Sets the freeform_tags of this SteeringPolicy.
424        Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace.
425        For more information, see `Resource Tags`__.
426
427
428        **Example:** `{\"Department\": \"Finance\"}`
429
430        __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm
431
432
433        :param freeform_tags: The freeform_tags of this SteeringPolicy.
434        :type: dict(str, str)
435        """
436        self._freeform_tags = freeform_tags
437
438    @property
439    def defined_tags(self):
440        """
441        **[Required]** Gets the defined_tags of this SteeringPolicy.
442        Defined tags for this resource. Each key is predefined and scoped to a namespace.
443        For more information, see `Resource Tags`__.
444
445
446        **Example:** `{\"Operations\": {\"CostCenter\": \"42\"}}`
447
448        __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm
449
450
451        :return: The defined_tags of this SteeringPolicy.
452        :rtype: dict(str, dict(str, object))
453        """
454        return self._defined_tags
455
456    @defined_tags.setter
457    def defined_tags(self, defined_tags):
458        """
459        Sets the defined_tags of this SteeringPolicy.
460        Defined tags for this resource. Each key is predefined and scoped to a namespace.
461        For more information, see `Resource Tags`__.
462
463
464        **Example:** `{\"Operations\": {\"CostCenter\": \"42\"}}`
465
466        __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm
467
468
469        :param defined_tags: The defined_tags of this SteeringPolicy.
470        :type: dict(str, dict(str, object))
471        """
472        self._defined_tags = defined_tags
473
474    @property
475    def answers(self):
476        """
477        **[Required]** Gets the answers of this SteeringPolicy.
478        The set of all answers that can potentially issue from the steering policy.
479
480
481        :return: The answers of this SteeringPolicy.
482        :rtype: list[oci.dns.models.SteeringPolicyAnswer]
483        """
484        return self._answers
485
486    @answers.setter
487    def answers(self, answers):
488        """
489        Sets the answers of this SteeringPolicy.
490        The set of all answers that can potentially issue from the steering policy.
491
492
493        :param answers: The answers of this SteeringPolicy.
494        :type: list[oci.dns.models.SteeringPolicyAnswer]
495        """
496        self._answers = answers
497
498    @property
499    def rules(self):
500        """
501        **[Required]** Gets the rules of this SteeringPolicy.
502        The series of rules that will be processed in sequence to reduce the pool of answers
503        to a response for any given request.
504
505
506        The first rule receives a shuffled list of all answers, and every other rule receives
507        the list of answers emitted by the one preceding it. The last rule populates the
508        response.
509
510
511        :return: The rules of this SteeringPolicy.
512        :rtype: list[oci.dns.models.SteeringPolicyRule]
513        """
514        return self._rules
515
516    @rules.setter
517    def rules(self, rules):
518        """
519        Sets the rules of this SteeringPolicy.
520        The series of rules that will be processed in sequence to reduce the pool of answers
521        to a response for any given request.
522
523
524        The first rule receives a shuffled list of all answers, and every other rule receives
525        the list of answers emitted by the one preceding it. The last rule populates the
526        response.
527
528
529        :param rules: The rules of this SteeringPolicy.
530        :type: list[oci.dns.models.SteeringPolicyRule]
531        """
532        self._rules = rules
533
534    @property
535    def _self(self):
536        """
537        **[Required]** Gets the _self of this SteeringPolicy.
538        The canonical absolute URL of the resource.
539
540
541        :return: The _self of this SteeringPolicy.
542        :rtype: str
543        """
544        return self.__self
545
546    @_self.setter
547    def _self(self, _self):
548        """
549        Sets the _self of this SteeringPolicy.
550        The canonical absolute URL of the resource.
551
552
553        :param _self: The _self of this SteeringPolicy.
554        :type: str
555        """
556        self.__self = _self
557
558    @property
559    def id(self):
560        """
561        **[Required]** Gets the id of this SteeringPolicy.
562        The OCID of the resource.
563
564
565        :return: The id of this SteeringPolicy.
566        :rtype: str
567        """
568        return self._id
569
570    @id.setter
571    def id(self, id):
572        """
573        Sets the id of this SteeringPolicy.
574        The OCID of the resource.
575
576
577        :param id: The id of this SteeringPolicy.
578        :type: str
579        """
580        self._id = id
581
582    @property
583    def time_created(self):
584        """
585        **[Required]** Gets the time_created of this SteeringPolicy.
586        The date and time the resource was created, expressed in RFC 3339 timestamp format.
587
588        **Example:** `2016-07-22T17:23:59:60Z`
589
590
591        :return: The time_created of this SteeringPolicy.
592        :rtype: datetime
593        """
594        return self._time_created
595
596    @time_created.setter
597    def time_created(self, time_created):
598        """
599        Sets the time_created of this SteeringPolicy.
600        The date and time the resource was created, expressed in RFC 3339 timestamp format.
601
602        **Example:** `2016-07-22T17:23:59:60Z`
603
604
605        :param time_created: The time_created of this SteeringPolicy.
606        :type: datetime
607        """
608        self._time_created = time_created
609
610    @property
611    def lifecycle_state(self):
612        """
613        **[Required]** Gets the lifecycle_state of this SteeringPolicy.
614        The current state of the resource.
615
616        Allowed values for this property are: "ACTIVE", "CREATING", "DELETED", "DELETING", 'UNKNOWN_ENUM_VALUE'.
617        Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'.
618
619
620        :return: The lifecycle_state of this SteeringPolicy.
621        :rtype: str
622        """
623        return self._lifecycle_state
624
625    @lifecycle_state.setter
626    def lifecycle_state(self, lifecycle_state):
627        """
628        Sets the lifecycle_state of this SteeringPolicy.
629        The current state of the resource.
630
631
632        :param lifecycle_state: The lifecycle_state of this SteeringPolicy.
633        :type: str
634        """
635        allowed_values = ["ACTIVE", "CREATING", "DELETED", "DELETING"]
636        if not value_allowed_none_or_none_sentinel(lifecycle_state, allowed_values):
637            lifecycle_state = 'UNKNOWN_ENUM_VALUE'
638        self._lifecycle_state = lifecycle_state
639
640    def __repr__(self):
641        return formatted_flat_dict(self)
642
643    def __eq__(self, other):
644        if other is None:
645            return False
646
647        return self.__dict__ == other.__dict__
648
649    def __ne__(self, other):
650        return not self == other
651