ibm_scc.configuration_governance_v1
API specification for the Configuration Governance service.
1# coding: utf-8 2 3# (C) Copyright IBM Corp. 2021. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# IBM OpenAPI SDK Code Generator Version: 3.32.0-4c6a3129-20210514-210323 18 19""" 20API specification for the Configuration Governance service. 21""" 22 23from datetime import datetime 24from enum import Enum 25from typing import Dict, List 26import json 27 28from ibm_cloud_sdk_core import BaseService, DetailedResponse 29from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator 30from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment 31from ibm_cloud_sdk_core.utils import convert_model, datetime_to_string, string_to_datetime 32 33from .common import get_sdk_headers 34 35############################################################################## 36# Service 37############################################################################## 38 39class ConfigurationGovernanceV1(BaseService): 40 """The Configuration Governance V1 service.""" 41 42 DEFAULT_SERVICE_URL = 'https://us.compliance.cloud.ibm.com' 43 DEFAULT_SERVICE_NAME = 'configuration_governance' 44 45 @classmethod 46 def new_instance(cls, 47 service_name: str = DEFAULT_SERVICE_NAME, 48 ) -> 'ConfigurationGovernanceV1': 49 """ 50 Return a new client for the Configuration Governance service using the 51 specified parameters and external configuration. 52 """ 53 authenticator = get_authenticator_from_environment(service_name) 54 service = cls( 55 authenticator 56 ) 57 service.configure_service(service_name) 58 return service 59 60 def __init__(self, 61 authenticator: Authenticator = None, 62 ) -> None: 63 """ 64 Construct a new client for the Configuration Governance service. 65 66 :param Authenticator authenticator: The authenticator specifies the authentication mechanism. 67 Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md 68 about initializing the authenticator of your choice. 69 """ 70 BaseService.__init__(self, 71 service_url=self.DEFAULT_SERVICE_URL, 72 authenticator=authenticator) 73 74 75 ######################### 76 # Rules 77 ######################### 78 79 80 def create_rules(self, 81 rules: List['CreateRuleRequest'], 82 *, 83 transaction_id: str = None, 84 **kwargs 85 ) -> DetailedResponse: 86 """ 87 Create rules. 88 89 Creates one or more rules that you can use to govern the way that IBM Cloud 90 resources can be provisioned and configured. 91 A successful `POST /config/rules` request defines a rule based on the target, 92 conditions, and enforcement actions that you specify. The response returns the ID 93 value for your rule, along with other metadata. 94 To learn more about rules, check out the 95 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule). 96 97 :param List[CreateRuleRequest] rules: A list of rules to be created. 98 :param str transaction_id: (optional) The unique identifier that is used to 99 trace an entire request. If you omit this field, the service generates and 100 sends a transaction ID as a response header of the request. In the case of 101 an error, the transaction ID is set in the `trace` field of the response 102 body. 103 **Note:** To help with debugging logs, it is strongly recommended that you 104 generate and supply a `Transaction-Id` with each request. 105 :param dict headers: A `dict` containing the request headers 106 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 107 :rtype: DetailedResponse with `dict` result representing a `CreateRulesResponse` object 108 """ 109 110 if rules is None: 111 raise ValueError('rules must be provided') 112 rules = [convert_model(x) for x in rules] 113 headers = { 114 'Transaction-Id': transaction_id 115 } 116 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 117 service_version='V1', 118 operation_id='create_rules') 119 headers.update(sdk_headers) 120 121 data = { 122 'rules': rules 123 } 124 data = {k: v for (k, v) in data.items() if v is not None} 125 data = json.dumps(data) 126 headers['content-type'] = 'application/json' 127 128 if 'headers' in kwargs: 129 headers.update(kwargs.get('headers')) 130 headers['Accept'] = 'application/json' 131 132 url = '/config/v1/rules' 133 request = self.prepare_request(method='POST', 134 url=url, 135 headers=headers, 136 data=data) 137 138 response = self.send(request) 139 return response 140 141 142 def list_rules(self, 143 account_id: str, 144 *, 145 transaction_id: str = None, 146 attached: bool = None, 147 labels: str = None, 148 scopes: str = None, 149 limit: int = None, 150 offset: int = None, 151 **kwargs 152 ) -> DetailedResponse: 153 """ 154 List rules. 155 156 Retrieves a list of the rules that are available in your account. 157 158 :param str account_id: Your IBM Cloud account ID. 159 :param str transaction_id: (optional) The unique identifier that is used to 160 trace an entire request. If you omit this field, the service generates and 161 sends a transaction ID as a response header of the request. In the case of 162 an error, the transaction ID is set in the `trace` field of the response 163 body. 164 **Note:** To help with debugging logs, it is strongly recommended that you 165 generate and supply a `Transaction-Id` with each request. 166 :param bool attached: (optional) Retrieves a list of rules that have scope 167 attachments. 168 :param str labels: (optional) Retrieves a list of rules that match the 169 labels that you specify. 170 :param str scopes: (optional) Retrieves a list of rules that match the 171 scope ID that you specify. 172 :param int limit: (optional) The number of resources to retrieve. By 173 default, list operations return the first 100 items. To retrieve a 174 different set of items, use `limit` with `offset` to page through your 175 available resources. 176 **Usage:** If you have 20 rules, and you want to retrieve only the first 5 177 rules, use `../rules?account_id={account_id}&limit=5`. 178 :param int offset: (optional) The number of resources to skip. By 179 specifying `offset`, you retrieve a subset of resources that starts with 180 the `offset` value. Use `offset` with `limit` to page through your 181 available resources. 182 **Usage:** If you have 100 rules, and you want to retrieve rules 26 through 183 50, use `../rules?account_id={account_id}&offset=25&limit=5`. 184 :param dict headers: A `dict` containing the request headers 185 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 186 :rtype: DetailedResponse with `dict` result representing a `RuleList` object 187 """ 188 189 if account_id is None: 190 raise ValueError('account_id must be provided') 191 headers = { 192 'Transaction-Id': transaction_id 193 } 194 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 195 service_version='V1', 196 operation_id='list_rules') 197 headers.update(sdk_headers) 198 199 params = { 200 'account_id': account_id, 201 'attached': attached, 202 'labels': labels, 203 'scopes': scopes, 204 'limit': limit, 205 'offset': offset 206 } 207 208 if 'headers' in kwargs: 209 headers.update(kwargs.get('headers')) 210 headers['Accept'] = 'application/json' 211 212 url = '/config/v1/rules' 213 request = self.prepare_request(method='GET', 214 url=url, 215 headers=headers, 216 params=params) 217 218 response = self.send(request) 219 return response 220 221 222 def get_rule(self, 223 rule_id: str, 224 *, 225 transaction_id: str = None, 226 **kwargs 227 ) -> DetailedResponse: 228 """ 229 Get a rule. 230 231 Retrieves an existing rule and its details. 232 233 :param str rule_id: The UUID that uniquely identifies the rule. 234 :param str transaction_id: (optional) The unique identifier that is used to 235 trace an entire request. If you omit this field, the service generates and 236 sends a transaction ID as a response header of the request. In the case of 237 an error, the transaction ID is set in the `trace` field of the response 238 body. 239 **Note:** To help with debugging logs, it is strongly recommended that you 240 generate and supply a `Transaction-Id` with each request. 241 :param dict headers: A `dict` containing the request headers 242 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 243 :rtype: DetailedResponse with `dict` result representing a `Rule` object 244 """ 245 246 if rule_id is None: 247 raise ValueError('rule_id must be provided') 248 headers = { 249 'Transaction-Id': transaction_id 250 } 251 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 252 service_version='V1', 253 operation_id='get_rule') 254 headers.update(sdk_headers) 255 256 if 'headers' in kwargs: 257 headers.update(kwargs.get('headers')) 258 headers['Accept'] = 'application/json' 259 260 path_param_keys = ['rule_id'] 261 path_param_values = self.encode_path_vars(rule_id) 262 path_param_dict = dict(zip(path_param_keys, path_param_values)) 263 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 264 request = self.prepare_request(method='GET', 265 url=url, 266 headers=headers) 267 268 response = self.send(request) 269 return response 270 271 272 def update_rule(self, 273 rule_id: str, 274 if_match: str, 275 name: str, 276 description: str, 277 target: 'TargetResource', 278 required_config: 'RuleRequiredConfig', 279 enforcement_actions: List['EnforcementAction'], 280 *, 281 account_id: str = None, 282 rule_type: str = None, 283 labels: List[str] = None, 284 transaction_id: str = None, 285 **kwargs 286 ) -> DetailedResponse: 287 """ 288 Update a rule. 289 290 Updates an existing rule based on the properties that you specify. 291 292 :param str rule_id: The UUID that uniquely identifies the rule. 293 :param str if_match: Compares a supplied `Etag` value with the version that 294 is stored for the requested resource. If the values match, the server 295 allows the request method to continue. 296 To find the `Etag` value, run a GET request on the resource that you want 297 to modify, and check the response headers. 298 :param str name: A human-readable alias to assign to your rule. 299 :param str description: An extended description of your rule. 300 :param TargetResource target: The properties that describe the resource 301 that you want to target 302 with the rule or template. 303 :param RuleRequiredConfig required_config: 304 :param List[EnforcementAction] enforcement_actions: The actions that the 305 service must run on your behalf when a request to create or modify the 306 target resource does not comply with your conditions. 307 :param str account_id: (optional) Your IBM Cloud account ID. 308 :param str rule_type: (optional) The type of rule. Rules that you create 309 are `user_defined`. 310 :param List[str] labels: (optional) Labels that you can use to group and 311 search for similar rules, such as those that help you to meet a specific 312 organization guideline. 313 :param str transaction_id: (optional) The unique identifier that is used to 314 trace an entire request. If you omit this field, the service generates and 315 sends a transaction ID as a response header of the request. In the case of 316 an error, the transaction ID is set in the `trace` field of the response 317 body. 318 **Note:** To help with debugging logs, it is strongly recommended that you 319 generate and supply a `Transaction-Id` with each request. 320 :param dict headers: A `dict` containing the request headers 321 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 322 :rtype: DetailedResponse with `dict` result representing a `Rule` object 323 """ 324 325 if rule_id is None: 326 raise ValueError('rule_id must be provided') 327 if if_match is None: 328 raise ValueError('if_match must be provided') 329 if name is None: 330 raise ValueError('name must be provided') 331 if description is None: 332 raise ValueError('description must be provided') 333 if target is None: 334 raise ValueError('target must be provided') 335 if required_config is None: 336 raise ValueError('required_config must be provided') 337 if enforcement_actions is None: 338 raise ValueError('enforcement_actions must be provided') 339 target = convert_model(target) 340 required_config = convert_model(required_config) 341 enforcement_actions = [convert_model(x) for x in enforcement_actions] 342 headers = { 343 'If-Match': if_match, 344 'Transaction-Id': transaction_id 345 } 346 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 347 service_version='V1', 348 operation_id='update_rule') 349 headers.update(sdk_headers) 350 351 data = { 352 'name': name, 353 'description': description, 354 'target': target, 355 'required_config': required_config, 356 'enforcement_actions': enforcement_actions, 357 'account_id': account_id, 358 'rule_type': rule_type, 359 'labels': labels 360 } 361 data = {k: v for (k, v) in data.items() if v is not None} 362 data = json.dumps(data) 363 headers['content-type'] = 'application/json' 364 365 if 'headers' in kwargs: 366 headers.update(kwargs.get('headers')) 367 headers['Accept'] = 'application/json' 368 369 path_param_keys = ['rule_id'] 370 path_param_values = self.encode_path_vars(rule_id) 371 path_param_dict = dict(zip(path_param_keys, path_param_values)) 372 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 373 request = self.prepare_request(method='PUT', 374 url=url, 375 headers=headers, 376 data=data) 377 378 response = self.send(request) 379 return response 380 381 382 def delete_rule(self, 383 rule_id: str, 384 *, 385 transaction_id: str = None, 386 **kwargs 387 ) -> DetailedResponse: 388 """ 389 Delete a rule. 390 391 Deletes an existing rule. 392 393 :param str rule_id: The UUID that uniquely identifies the rule. 394 :param str transaction_id: (optional) The unique identifier that is used to 395 trace an entire request. If you omit this field, the service generates and 396 sends a transaction ID as a response header of the request. In the case of 397 an error, the transaction ID is set in the `trace` field of the response 398 body. 399 **Note:** To help with debugging logs, it is strongly recommended that you 400 generate and supply a `Transaction-Id` with each request. 401 :param dict headers: A `dict` containing the request headers 402 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 403 :rtype: DetailedResponse 404 """ 405 406 if rule_id is None: 407 raise ValueError('rule_id must be provided') 408 headers = { 409 'Transaction-Id': transaction_id 410 } 411 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 412 service_version='V1', 413 operation_id='delete_rule') 414 headers.update(sdk_headers) 415 416 if 'headers' in kwargs: 417 headers.update(kwargs.get('headers')) 418 419 path_param_keys = ['rule_id'] 420 path_param_values = self.encode_path_vars(rule_id) 421 path_param_dict = dict(zip(path_param_keys, path_param_values)) 422 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 423 request = self.prepare_request(method='DELETE', 424 url=url, 425 headers=headers) 426 427 response = self.send(request) 428 return response 429 430 431 def create_rule_attachments(self, 432 rule_id: str, 433 attachments: List['RuleAttachmentRequest'], 434 *, 435 transaction_id: str = None, 436 **kwargs 437 ) -> DetailedResponse: 438 """ 439 Create attachments. 440 441 Creates one or more scope attachments for an existing rule. 442 You can attach an existing rule to a scope, such as a specific IBM Cloud account, 443 to start evaluating the rule for compliance. A successful 444 `POST /config/v1/rules/{rule_id}/attachments` returns the ID value for the 445 attachment, along with other metadata. 446 447 :param str rule_id: The UUID that uniquely identifies the rule. 448 :param List[RuleAttachmentRequest] attachments: 449 :param str transaction_id: (optional) The unique identifier that is used to 450 trace an entire request. If you omit this field, the service generates and 451 sends a transaction ID as a response header of the request. In the case of 452 an error, the transaction ID is set in the `trace` field of the response 453 body. 454 **Note:** To help with debugging logs, it is strongly recommended that you 455 generate and supply a `Transaction-Id` with each request. 456 :param dict headers: A `dict` containing the request headers 457 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 458 :rtype: DetailedResponse with `dict` result representing a `CreateRuleAttachmentsResponse` object 459 """ 460 461 if rule_id is None: 462 raise ValueError('rule_id must be provided') 463 if attachments is None: 464 raise ValueError('attachments must be provided') 465 attachments = [convert_model(x) for x in attachments] 466 headers = { 467 'Transaction-Id': transaction_id 468 } 469 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 470 service_version='V1', 471 operation_id='create_rule_attachments') 472 headers.update(sdk_headers) 473 474 data = { 475 'attachments': attachments 476 } 477 data = {k: v for (k, v) in data.items() if v is not None} 478 data = json.dumps(data) 479 headers['content-type'] = 'application/json' 480 481 if 'headers' in kwargs: 482 headers.update(kwargs.get('headers')) 483 headers['Accept'] = 'application/json' 484 485 path_param_keys = ['rule_id'] 486 path_param_values = self.encode_path_vars(rule_id) 487 path_param_dict = dict(zip(path_param_keys, path_param_values)) 488 url = '/config/v1/rules/{rule_id}/attachments'.format(**path_param_dict) 489 request = self.prepare_request(method='POST', 490 url=url, 491 headers=headers, 492 data=data) 493 494 response = self.send(request) 495 return response 496 497 498 def list_rule_attachments(self, 499 rule_id: str, 500 *, 501 transaction_id: str = None, 502 limit: int = None, 503 offset: int = None, 504 **kwargs 505 ) -> DetailedResponse: 506 """ 507 List attachments. 508 509 Retrieves a list of scope attachments that are associated with the specified rule. 510 511 :param str rule_id: The UUID that uniquely identifies the rule. 512 :param str transaction_id: (optional) The unique identifier that is used to 513 trace an entire request. If you omit this field, the service generates and 514 sends a transaction ID as a response header of the request. In the case of 515 an error, the transaction ID is set in the `trace` field of the response 516 body. 517 **Note:** To help with debugging logs, it is strongly recommended that you 518 generate and supply a `Transaction-Id` with each request. 519 :param int limit: (optional) The number of resources to retrieve. By 520 default, list operations return the first 100 items. To retrieve a 521 different set of items, use `limit` with `offset` to page through your 522 available resources. 523 **Usage:** If you have 20 rules, and you want to retrieve only the first 5 524 rules, use `../rules?account_id={account_id}&limit=5`. 525 :param int offset: (optional) The number of resources to skip. By 526 specifying `offset`, you retrieve a subset of resources that starts with 527 the `offset` value. Use `offset` with `limit` to page through your 528 available resources. 529 **Usage:** If you have 100 rules, and you want to retrieve rules 26 through 530 50, use `../rules?account_id={account_id}&offset=25&limit=5`. 531 :param dict headers: A `dict` containing the request headers 532 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 533 :rtype: DetailedResponse with `dict` result representing a `RuleAttachmentList` object 534 """ 535 536 if rule_id is None: 537 raise ValueError('rule_id must be provided') 538 headers = { 539 'Transaction-Id': transaction_id 540 } 541 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 542 service_version='V1', 543 operation_id='list_rule_attachments') 544 headers.update(sdk_headers) 545 546 params = { 547 'limit': limit, 548 'offset': offset 549 } 550 551 if 'headers' in kwargs: 552 headers.update(kwargs.get('headers')) 553 headers['Accept'] = 'application/json' 554 555 path_param_keys = ['rule_id'] 556 path_param_values = self.encode_path_vars(rule_id) 557 path_param_dict = dict(zip(path_param_keys, path_param_values)) 558 url = '/config/v1/rules/{rule_id}/attachments'.format(**path_param_dict) 559 request = self.prepare_request(method='GET', 560 url=url, 561 headers=headers, 562 params=params) 563 564 response = self.send(request) 565 return response 566 567 568 def get_rule_attachment(self, 569 rule_id: str, 570 attachment_id: str, 571 *, 572 transaction_id: str = None, 573 **kwargs 574 ) -> DetailedResponse: 575 """ 576 Get an attachment. 577 578 Retrieves an existing scope attachment for a rule. 579 580 :param str rule_id: The UUID that uniquely identifies the rule. 581 :param str attachment_id: The UUID that uniquely identifies the attachment. 582 :param str transaction_id: (optional) The unique identifier that is used to 583 trace an entire request. If you omit this field, the service generates and 584 sends a transaction ID as a response header of the request. In the case of 585 an error, the transaction ID is set in the `trace` field of the response 586 body. 587 **Note:** To help with debugging logs, it is strongly recommended that you 588 generate and supply a `Transaction-Id` with each request. 589 :param dict headers: A `dict` containing the request headers 590 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 591 :rtype: DetailedResponse with `dict` result representing a `RuleAttachment` object 592 """ 593 594 if rule_id is None: 595 raise ValueError('rule_id must be provided') 596 if attachment_id is None: 597 raise ValueError('attachment_id must be provided') 598 headers = { 599 'Transaction-Id': transaction_id 600 } 601 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 602 service_version='V1', 603 operation_id='get_rule_attachment') 604 headers.update(sdk_headers) 605 606 if 'headers' in kwargs: 607 headers.update(kwargs.get('headers')) 608 headers['Accept'] = 'application/json' 609 610 path_param_keys = ['rule_id', 'attachment_id'] 611 path_param_values = self.encode_path_vars(rule_id, attachment_id) 612 path_param_dict = dict(zip(path_param_keys, path_param_values)) 613 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 614 request = self.prepare_request(method='GET', 615 url=url, 616 headers=headers) 617 618 response = self.send(request) 619 return response 620 621 622 def update_rule_attachment(self, 623 rule_id: str, 624 attachment_id: str, 625 if_match: str, 626 account_id: str, 627 included_scope: 'RuleScope', 628 *, 629 excluded_scopes: List['RuleScope'] = None, 630 transaction_id: str = None, 631 **kwargs 632 ) -> DetailedResponse: 633 """ 634 Update an attachment. 635 636 Updates an existing scope attachment based on the properties that you specify. 637 638 :param str rule_id: The UUID that uniquely identifies the rule. 639 :param str attachment_id: The UUID that uniquely identifies the attachment. 640 :param str if_match: Compares a supplied `Etag` value with the version that 641 is stored for the requested resource. If the values match, the server 642 allows the request method to continue. 643 To find the `Etag` value, run a GET request on the resource that you want 644 to modify, and check the response headers. 645 :param str account_id: Your IBM Cloud account ID. 646 :param RuleScope included_scope: The extent at which the rule can be 647 attached across your accounts. 648 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 649 rule can be excluded from the included scope. 650 :param str transaction_id: (optional) The unique identifier that is used to 651 trace an entire request. If you omit this field, the service generates and 652 sends a transaction ID as a response header of the request. In the case of 653 an error, the transaction ID is set in the `trace` field of the response 654 body. 655 **Note:** To help with debugging logs, it is strongly recommended that you 656 generate and supply a `Transaction-Id` with each request. 657 :param dict headers: A `dict` containing the request headers 658 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 659 :rtype: DetailedResponse with `dict` result representing a `TemplateAttachment` object 660 """ 661 662 if rule_id is None: 663 raise ValueError('rule_id must be provided') 664 if attachment_id is None: 665 raise ValueError('attachment_id must be provided') 666 if if_match is None: 667 raise ValueError('if_match must be provided') 668 if account_id is None: 669 raise ValueError('account_id must be provided') 670 if included_scope is None: 671 raise ValueError('included_scope must be provided') 672 included_scope = convert_model(included_scope) 673 if excluded_scopes is not None: 674 excluded_scopes = [convert_model(x) for x in excluded_scopes] 675 headers = { 676 'If-Match': if_match, 677 'Transaction-Id': transaction_id 678 } 679 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 680 service_version='V1', 681 operation_id='update_rule_attachment') 682 headers.update(sdk_headers) 683 684 data = { 685 'account_id': account_id, 686 'included_scope': included_scope, 687 'excluded_scopes': excluded_scopes 688 } 689 data = {k: v for (k, v) in data.items() if v is not None} 690 data = json.dumps(data) 691 headers['content-type'] = 'application/json' 692 693 if 'headers' in kwargs: 694 headers.update(kwargs.get('headers')) 695 headers['Accept'] = 'application/json' 696 697 path_param_keys = ['rule_id', 'attachment_id'] 698 path_param_values = self.encode_path_vars(rule_id, attachment_id) 699 path_param_dict = dict(zip(path_param_keys, path_param_values)) 700 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 701 request = self.prepare_request(method='PUT', 702 url=url, 703 headers=headers, 704 data=data) 705 706 response = self.send(request) 707 return response 708 709 710 def delete_rule_attachment(self, 711 rule_id: str, 712 attachment_id: str, 713 *, 714 transaction_id: str = None, 715 **kwargs 716 ) -> DetailedResponse: 717 """ 718 Delete an attachment. 719 720 Deletes an existing scope attachment. 721 722 :param str rule_id: The UUID that uniquely identifies the rule. 723 :param str attachment_id: The UUID that uniquely identifies the attachment. 724 :param str transaction_id: (optional) The unique identifier that is used to 725 trace an entire request. If you omit this field, the service generates and 726 sends a transaction ID as a response header of the request. In the case of 727 an error, the transaction ID is set in the `trace` field of the response 728 body. 729 **Note:** To help with debugging logs, it is strongly recommended that you 730 generate and supply a `Transaction-Id` with each request. 731 :param dict headers: A `dict` containing the request headers 732 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 733 :rtype: DetailedResponse 734 """ 735 736 if rule_id is None: 737 raise ValueError('rule_id must be provided') 738 if attachment_id is None: 739 raise ValueError('attachment_id must be provided') 740 headers = { 741 'Transaction-Id': transaction_id 742 } 743 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 744 service_version='V1', 745 operation_id='delete_rule_attachment') 746 headers.update(sdk_headers) 747 748 if 'headers' in kwargs: 749 headers.update(kwargs.get('headers')) 750 751 path_param_keys = ['rule_id', 'attachment_id'] 752 path_param_values = self.encode_path_vars(rule_id, attachment_id) 753 path_param_dict = dict(zip(path_param_keys, path_param_values)) 754 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 755 request = self.prepare_request(method='DELETE', 756 url=url, 757 headers=headers) 758 759 response = self.send(request) 760 return response 761 762 763############################################################################## 764# Models 765############################################################################## 766 767 768class CreateRuleAttachmentsResponse(): 769 """ 770 CreateRuleAttachmentsResponse. 771 772 :attr List[RuleAttachment] attachments: 773 """ 774 775 def __init__(self, 776 attachments: List['RuleAttachment']) -> None: 777 """ 778 Initialize a CreateRuleAttachmentsResponse object. 779 780 :param List[RuleAttachment] attachments: 781 """ 782 self.attachments = attachments 783 784 @classmethod 785 def from_dict(cls, _dict: Dict) -> 'CreateRuleAttachmentsResponse': 786 """Initialize a CreateRuleAttachmentsResponse object from a json dictionary.""" 787 args = {} 788 if 'attachments' in _dict: 789 args['attachments'] = [RuleAttachment.from_dict(x) for x in _dict.get('attachments')] 790 else: 791 raise ValueError('Required property \'attachments\' not present in CreateRuleAttachmentsResponse JSON') 792 return cls(**args) 793 794 @classmethod 795 def _from_dict(cls, _dict): 796 """Initialize a CreateRuleAttachmentsResponse object from a json dictionary.""" 797 return cls.from_dict(_dict) 798 799 def to_dict(self) -> Dict: 800 """Return a json dictionary representing this model.""" 801 _dict = {} 802 if hasattr(self, 'attachments') and self.attachments is not None: 803 _dict['attachments'] = [x.to_dict() for x in self.attachments] 804 return _dict 805 806 def _to_dict(self): 807 """Return a json dictionary representing this model.""" 808 return self.to_dict() 809 810 def __str__(self) -> str: 811 """Return a `str` version of this CreateRuleAttachmentsResponse object.""" 812 return json.dumps(self.to_dict(), indent=2) 813 814 def __eq__(self, other: 'CreateRuleAttachmentsResponse') -> bool: 815 """Return `true` when self and other are equal, false otherwise.""" 816 if not isinstance(other, self.__class__): 817 return False 818 return self.__dict__ == other.__dict__ 819 820 def __ne__(self, other: 'CreateRuleAttachmentsResponse') -> bool: 821 """Return `true` when self and other are not equal, false otherwise.""" 822 return not self == other 823 824class CreateRuleRequest(): 825 """ 826 A rule to be created. 827 828 :attr str request_id: (optional) A field that you can use in bulk operations to 829 store a custom identifier for an individual request. If you omit this field, the 830 service generates and sends a `request_id` string for each new rule. The 831 generated string corresponds with the numerical order of the rules request 832 array. For example, `"request_id": "1"`, `"request_id": "2"`. 833 **Note:** To help with debugging logs, it is strongly recommended that you 834 generate and supply a `request_id` with each request. 835 :attr RuleRequest rule: Properties that you can associate with a rule. 836 """ 837 838 def __init__(self, 839 rule: 'RuleRequest', 840 *, 841 request_id: str = None) -> None: 842 """ 843 Initialize a CreateRuleRequest object. 844 845 :param RuleRequest rule: Properties that you can associate with a rule. 846 :param str request_id: (optional) A field that you can use in bulk 847 operations to store a custom identifier for an individual request. If you 848 omit this field, the service generates and sends a `request_id` string for 849 each new rule. The generated string corresponds with the numerical order of 850 the rules request array. For example, `"request_id": "1"`, `"request_id": 851 "2"`. 852 **Note:** To help with debugging logs, it is strongly recommended that you 853 generate and supply a `request_id` with each request. 854 """ 855 self.request_id = request_id 856 self.rule = rule 857 858 @classmethod 859 def from_dict(cls, _dict: Dict) -> 'CreateRuleRequest': 860 """Initialize a CreateRuleRequest object from a json dictionary.""" 861 args = {} 862 if 'request_id' in _dict: 863 args['request_id'] = _dict.get('request_id') 864 if 'rule' in _dict: 865 args['rule'] = RuleRequest.from_dict(_dict.get('rule')) 866 else: 867 raise ValueError('Required property \'rule\' not present in CreateRuleRequest JSON') 868 return cls(**args) 869 870 @classmethod 871 def _from_dict(cls, _dict): 872 """Initialize a CreateRuleRequest object from a json dictionary.""" 873 return cls.from_dict(_dict) 874 875 def to_dict(self) -> Dict: 876 """Return a json dictionary representing this model.""" 877 _dict = {} 878 if hasattr(self, 'request_id') and self.request_id is not None: 879 _dict['request_id'] = self.request_id 880 if hasattr(self, 'rule') and self.rule is not None: 881 _dict['rule'] = self.rule.to_dict() 882 return _dict 883 884 def _to_dict(self): 885 """Return a json dictionary representing this model.""" 886 return self.to_dict() 887 888 def __str__(self) -> str: 889 """Return a `str` version of this CreateRuleRequest object.""" 890 return json.dumps(self.to_dict(), indent=2) 891 892 def __eq__(self, other: 'CreateRuleRequest') -> bool: 893 """Return `true` when self and other are equal, false otherwise.""" 894 if not isinstance(other, self.__class__): 895 return False 896 return self.__dict__ == other.__dict__ 897 898 def __ne__(self, other: 'CreateRuleRequest') -> bool: 899 """Return `true` when self and other are not equal, false otherwise.""" 900 return not self == other 901 902class CreateRuleResponse(): 903 """ 904 Response information for a rule request. 905 If the 'status_code' property indicates success, the 'request_id' and 'rule' 906 properties are returned in the response. If the 'status_code' property indicates an 907 error, the 'request_id', 'errors', and 'trace' fields are returned. 908 909 :attr str request_id: (optional) The identifier that is used to correlate an 910 individual request. 911 To assist with debugging, you can use this ID to identify and inspect only one 912 request that was made as part of a bulk operation. 913 :attr int status_code: (optional) The HTTP response status code. 914 :attr Rule rule: (optional) Information about a newly-created rule. 915 This field is present for successful requests. 916 :attr List[RuleResponseError] errors: (optional) The error contents of the 917 multi-status response. 918 This field is present for unsuccessful requests. 919 :attr str trace: (optional) The UUID that uniquely identifies the request. 920 This field is present for unsuccessful requests. 921 """ 922 923 def __init__(self, 924 *, 925 request_id: str = None, 926 status_code: int = None, 927 rule: 'Rule' = None, 928 errors: List['RuleResponseError'] = None, 929 trace: str = None) -> None: 930 """ 931 Initialize a CreateRuleResponse object. 932 933 :param str request_id: (optional) The identifier that is used to correlate 934 an individual request. 935 To assist with debugging, you can use this ID to identify and inspect only 936 one request that was made as part of a bulk operation. 937 :param int status_code: (optional) The HTTP response status code. 938 :param Rule rule: (optional) Information about a newly-created rule. 939 This field is present for successful requests. 940 :param List[RuleResponseError] errors: (optional) The error contents of the 941 multi-status response. 942 This field is present for unsuccessful requests. 943 :param str trace: (optional) The UUID that uniquely identifies the request. 944 This field is present for unsuccessful requests. 945 """ 946 self.request_id = request_id 947 self.status_code = status_code 948 self.rule = rule 949 self.errors = errors 950 self.trace = trace 951 952 @classmethod 953 def from_dict(cls, _dict: Dict) -> 'CreateRuleResponse': 954 """Initialize a CreateRuleResponse object from a json dictionary.""" 955 args = {} 956 if 'request_id' in _dict: 957 args['request_id'] = _dict.get('request_id') 958 if 'status_code' in _dict: 959 args['status_code'] = _dict.get('status_code') 960 if 'rule' in _dict: 961 args['rule'] = Rule.from_dict(_dict.get('rule')) 962 if 'errors' in _dict: 963 args['errors'] = [RuleResponseError.from_dict(x) for x in _dict.get('errors')] 964 if 'trace' in _dict: 965 args['trace'] = _dict.get('trace') 966 return cls(**args) 967 968 @classmethod 969 def _from_dict(cls, _dict): 970 """Initialize a CreateRuleResponse object from a json dictionary.""" 971 return cls.from_dict(_dict) 972 973 def to_dict(self) -> Dict: 974 """Return a json dictionary representing this model.""" 975 _dict = {} 976 if hasattr(self, 'request_id') and self.request_id is not None: 977 _dict['request_id'] = self.request_id 978 if hasattr(self, 'status_code') and self.status_code is not None: 979 _dict['status_code'] = self.status_code 980 if hasattr(self, 'rule') and self.rule is not None: 981 _dict['rule'] = self.rule.to_dict() 982 if hasattr(self, 'errors') and self.errors is not None: 983 _dict['errors'] = [x.to_dict() for x in self.errors] 984 if hasattr(self, 'trace') and self.trace is not None: 985 _dict['trace'] = self.trace 986 return _dict 987 988 def _to_dict(self): 989 """Return a json dictionary representing this model.""" 990 return self.to_dict() 991 992 def __str__(self) -> str: 993 """Return a `str` version of this CreateRuleResponse object.""" 994 return json.dumps(self.to_dict(), indent=2) 995 996 def __eq__(self, other: 'CreateRuleResponse') -> bool: 997 """Return `true` when self and other are equal, false otherwise.""" 998 if not isinstance(other, self.__class__): 999 return False 1000 return self.__dict__ == other.__dict__ 1001 1002 def __ne__(self, other: 'CreateRuleResponse') -> bool: 1003 """Return `true` when self and other are not equal, false otherwise.""" 1004 return not self == other 1005 1006class CreateRulesResponse(): 1007 """ 1008 The response associated with a request to create one or more rules. 1009 1010 :attr List[CreateRuleResponse] rules: An array of rule responses. 1011 """ 1012 1013 def __init__(self, 1014 rules: List['CreateRuleResponse']) -> None: 1015 """ 1016 Initialize a CreateRulesResponse object. 1017 1018 :param List[CreateRuleResponse] rules: An array of rule responses. 1019 """ 1020 self.rules = rules 1021 1022 @classmethod 1023 def from_dict(cls, _dict: Dict) -> 'CreateRulesResponse': 1024 """Initialize a CreateRulesResponse object from a json dictionary.""" 1025 args = {} 1026 if 'rules' in _dict: 1027 args['rules'] = [CreateRuleResponse.from_dict(x) for x in _dict.get('rules')] 1028 else: 1029 raise ValueError('Required property \'rules\' not present in CreateRulesResponse JSON') 1030 return cls(**args) 1031 1032 @classmethod 1033 def _from_dict(cls, _dict): 1034 """Initialize a CreateRulesResponse object from a json dictionary.""" 1035 return cls.from_dict(_dict) 1036 1037 def to_dict(self) -> Dict: 1038 """Return a json dictionary representing this model.""" 1039 _dict = {} 1040 if hasattr(self, 'rules') and self.rules is not None: 1041 _dict['rules'] = [x.to_dict() for x in self.rules] 1042 return _dict 1043 1044 def _to_dict(self): 1045 """Return a json dictionary representing this model.""" 1046 return self.to_dict() 1047 1048 def __str__(self) -> str: 1049 """Return a `str` version of this CreateRulesResponse object.""" 1050 return json.dumps(self.to_dict(), indent=2) 1051 1052 def __eq__(self, other: 'CreateRulesResponse') -> bool: 1053 """Return `true` when self and other are equal, false otherwise.""" 1054 if not isinstance(other, self.__class__): 1055 return False 1056 return self.__dict__ == other.__dict__ 1057 1058 def __ne__(self, other: 'CreateRulesResponse') -> bool: 1059 """Return `true` when self and other are not equal, false otherwise.""" 1060 return not self == other 1061 1062class EnforcementAction(): 1063 """ 1064 EnforcementAction. 1065 1066 :attr str action: To block a request from completing, use `disallow`. To log the 1067 request to Activity Tracker with LogDNA, use `audit_log`. 1068 """ 1069 1070 def __init__(self, 1071 action: str) -> None: 1072 """ 1073 Initialize a EnforcementAction object. 1074 1075 :param str action: To block a request from completing, use `disallow`. To 1076 log the request to Activity Tracker with LogDNA, use `audit_log`. 1077 """ 1078 self.action = action 1079 1080 @classmethod 1081 def from_dict(cls, _dict: Dict) -> 'EnforcementAction': 1082 """Initialize a EnforcementAction object from a json dictionary.""" 1083 args = {} 1084 if 'action' in _dict: 1085 args['action'] = _dict.get('action') 1086 else: 1087 raise ValueError('Required property \'action\' not present in EnforcementAction JSON') 1088 return cls(**args) 1089 1090 @classmethod 1091 def _from_dict(cls, _dict): 1092 """Initialize a EnforcementAction object from a json dictionary.""" 1093 return cls.from_dict(_dict) 1094 1095 def to_dict(self) -> Dict: 1096 """Return a json dictionary representing this model.""" 1097 _dict = {} 1098 if hasattr(self, 'action') and self.action is not None: 1099 _dict['action'] = self.action 1100 return _dict 1101 1102 def _to_dict(self): 1103 """Return a json dictionary representing this model.""" 1104 return self.to_dict() 1105 1106 def __str__(self) -> str: 1107 """Return a `str` version of this EnforcementAction object.""" 1108 return json.dumps(self.to_dict(), indent=2) 1109 1110 def __eq__(self, other: 'EnforcementAction') -> bool: 1111 """Return `true` when self and other are equal, false otherwise.""" 1112 if not isinstance(other, self.__class__): 1113 return False 1114 return self.__dict__ == other.__dict__ 1115 1116 def __ne__(self, other: 'EnforcementAction') -> bool: 1117 """Return `true` when self and other are not equal, false otherwise.""" 1118 return not self == other 1119 1120 class ActionEnum(str, Enum): 1121 """ 1122 To block a request from completing, use `disallow`. To log the request to Activity 1123 Tracker with LogDNA, use `audit_log`. 1124 """ 1125 AUDIT_LOG = 'audit_log' 1126 DISALLOW = 'disallow' 1127 1128 1129class Link(): 1130 """ 1131 A link that is used to paginate through available resources. 1132 1133 :attr str href: The URL for the first, previous, next, or last page of 1134 resources. 1135 """ 1136 1137 def __init__(self, 1138 href: str) -> None: 1139 """ 1140 Initialize a Link object. 1141 1142 :param str href: The URL for the first, previous, next, or last page of 1143 resources. 1144 """ 1145 self.href = href 1146 1147 @classmethod 1148 def from_dict(cls, _dict: Dict) -> 'Link': 1149 """Initialize a Link object from a json dictionary.""" 1150 args = {} 1151 if 'href' in _dict: 1152 args['href'] = _dict.get('href') 1153 else: 1154 raise ValueError('Required property \'href\' not present in Link JSON') 1155 return cls(**args) 1156 1157 @classmethod 1158 def _from_dict(cls, _dict): 1159 """Initialize a Link object from a json dictionary.""" 1160 return cls.from_dict(_dict) 1161 1162 def to_dict(self) -> Dict: 1163 """Return a json dictionary representing this model.""" 1164 _dict = {} 1165 if hasattr(self, 'href') and self.href is not None: 1166 _dict['href'] = self.href 1167 return _dict 1168 1169 def _to_dict(self): 1170 """Return a json dictionary representing this model.""" 1171 return self.to_dict() 1172 1173 def __str__(self) -> str: 1174 """Return a `str` version of this Link object.""" 1175 return json.dumps(self.to_dict(), indent=2) 1176 1177 def __eq__(self, other: 'Link') -> bool: 1178 """Return `true` when self and other are equal, false otherwise.""" 1179 if not isinstance(other, self.__class__): 1180 return False 1181 return self.__dict__ == other.__dict__ 1182 1183 def __ne__(self, other: 'Link') -> bool: 1184 """Return `true` when self and other are not equal, false otherwise.""" 1185 return not self == other 1186 1187class Rule(): 1188 """ 1189 Properties associated with a rule, including both user-defined and server-populated 1190 properties. 1191 1192 :attr str account_id: (optional) Your IBM Cloud account ID. 1193 :attr str name: A human-readable alias to assign to your rule. 1194 :attr str description: An extended description of your rule. 1195 :attr str rule_type: (optional) The type of rule. Rules that you create are 1196 `user_defined`. 1197 :attr TargetResource target: The properties that describe the resource that you 1198 want to target 1199 with the rule or template. 1200 :attr RuleRequiredConfig required_config: 1201 :attr List[EnforcementAction] enforcement_actions: The actions that the service 1202 must run on your behalf when a request to create or modify the target resource 1203 does not comply with your conditions. 1204 :attr List[str] labels: (optional) Labels that you can use to group and search 1205 for similar rules, such as those that help you to meet a specific organization 1206 guideline. 1207 :attr str rule_id: (optional) The UUID that uniquely identifies the rule. 1208 :attr datetime creation_date: (optional) The date the resource was created. 1209 :attr str created_by: (optional) The unique identifier for the user or 1210 application that created the resource. 1211 :attr datetime modification_date: (optional) The date the resource was last 1212 modified. 1213 :attr str modified_by: (optional) The unique identifier for the user or 1214 application that last modified the resource. 1215 :attr int number_of_attachments: (optional) The number of scope attachments that 1216 are associated with the rule. 1217 """ 1218 1219 def __init__(self, 1220 name: str, 1221 description: str, 1222 target: 'TargetResource', 1223 required_config: 'RuleRequiredConfig', 1224 enforcement_actions: List['EnforcementAction'], 1225 *, 1226 account_id: str = None, 1227 rule_type: str = None, 1228 labels: List[str] = None, 1229 rule_id: str = None, 1230 creation_date: datetime = None, 1231 created_by: str = None, 1232 modification_date: datetime = None, 1233 modified_by: str = None, 1234 number_of_attachments: int = None) -> None: 1235 """ 1236 Initialize a Rule object. 1237 1238 :param str name: A human-readable alias to assign to your rule. 1239 :param str description: An extended description of your rule. 1240 :param TargetResource target: The properties that describe the resource 1241 that you want to target 1242 with the rule or template. 1243 :param RuleRequiredConfig required_config: 1244 :param List[EnforcementAction] enforcement_actions: The actions that the 1245 service must run on your behalf when a request to create or modify the 1246 target resource does not comply with your conditions. 1247 :param str account_id: (optional) Your IBM Cloud account ID. 1248 :param str rule_type: (optional) The type of rule. Rules that you create 1249 are `user_defined`. 1250 :param List[str] labels: (optional) Labels that you can use to group and 1251 search for similar rules, such as those that help you to meet a specific 1252 organization guideline. 1253 """ 1254 self.account_id = account_id 1255 self.name = name 1256 self.description = description 1257 self.rule_type = rule_type 1258 self.target = target 1259 self.required_config = required_config 1260 self.enforcement_actions = enforcement_actions 1261 self.labels = labels 1262 self.rule_id = rule_id 1263 self.creation_date = creation_date 1264 self.created_by = created_by 1265 self.modification_date = modification_date 1266 self.modified_by = modified_by 1267 self.number_of_attachments = number_of_attachments 1268 1269 @classmethod 1270 def from_dict(cls, _dict: Dict) -> 'Rule': 1271 """Initialize a Rule object from a json dictionary.""" 1272 args = {} 1273 if 'account_id' in _dict: 1274 args['account_id'] = _dict.get('account_id') 1275 if 'name' in _dict: 1276 args['name'] = _dict.get('name') 1277 else: 1278 raise ValueError('Required property \'name\' not present in Rule JSON') 1279 if 'description' in _dict: 1280 args['description'] = _dict.get('description') 1281 else: 1282 raise ValueError('Required property \'description\' not present in Rule JSON') 1283 if 'rule_type' in _dict: 1284 args['rule_type'] = _dict.get('rule_type') 1285 if 'target' in _dict: 1286 args['target'] = TargetResource.from_dict(_dict.get('target')) 1287 else: 1288 raise ValueError('Required property \'target\' not present in Rule JSON') 1289 if 'required_config' in _dict: 1290 args['required_config'] = _dict.get('required_config') 1291 else: 1292 raise ValueError('Required property \'required_config\' not present in Rule JSON') 1293 if 'enforcement_actions' in _dict: 1294 args['enforcement_actions'] = [EnforcementAction.from_dict(x) for x in _dict.get('enforcement_actions')] 1295 else: 1296 raise ValueError('Required property \'enforcement_actions\' not present in Rule JSON') 1297 if 'labels' in _dict: 1298 args['labels'] = _dict.get('labels') 1299 if 'rule_id' in _dict: 1300 args['rule_id'] = _dict.get('rule_id') 1301 if 'creation_date' in _dict: 1302 args['creation_date'] = string_to_datetime(_dict.get('creation_date')) 1303 if 'created_by' in _dict: 1304 args['created_by'] = _dict.get('created_by') 1305 if 'modification_date' in _dict: 1306 args['modification_date'] = string_to_datetime(_dict.get('modification_date')) 1307 if 'modified_by' in _dict: 1308 args['modified_by'] = _dict.get('modified_by') 1309 if 'number_of_attachments' in _dict: 1310 args['number_of_attachments'] = _dict.get('number_of_attachments') 1311 return cls(**args) 1312 1313 @classmethod 1314 def _from_dict(cls, _dict): 1315 """Initialize a Rule object from a json dictionary.""" 1316 return cls.from_dict(_dict) 1317 1318 def to_dict(self) -> Dict: 1319 """Return a json dictionary representing this model.""" 1320 _dict = {} 1321 if hasattr(self, 'account_id') and self.account_id is not None: 1322 _dict['account_id'] = self.account_id 1323 if hasattr(self, 'name') and self.name is not None: 1324 _dict['name'] = self.name 1325 if hasattr(self, 'description') and self.description is not None: 1326 _dict['description'] = self.description 1327 if hasattr(self, 'rule_type') and self.rule_type is not None: 1328 _dict['rule_type'] = self.rule_type 1329 if hasattr(self, 'target') and self.target is not None: 1330 _dict['target'] = self.target.to_dict() 1331 if hasattr(self, 'required_config') and self.required_config is not None: 1332 if isinstance(self.required_config, dict): 1333 _dict['required_config'] = self.required_config 1334 else: 1335 _dict['required_config'] = self.required_config.to_dict() 1336 if hasattr(self, 'enforcement_actions') and self.enforcement_actions is not None: 1337 _dict['enforcement_actions'] = [x.to_dict() for x in self.enforcement_actions] 1338 if hasattr(self, 'labels') and self.labels is not None: 1339 _dict['labels'] = self.labels 1340 if hasattr(self, 'rule_id') and getattr(self, 'rule_id') is not None: 1341 _dict['rule_id'] = getattr(self, 'rule_id') 1342 if hasattr(self, 'creation_date') and getattr(self, 'creation_date') is not None: 1343 _dict['creation_date'] = datetime_to_string(getattr(self, 'creation_date')) 1344 if hasattr(self, 'created_by') and getattr(self, 'created_by') is not None: 1345 _dict['created_by'] = getattr(self, 'created_by') 1346 if hasattr(self, 'modification_date') and getattr(self, 'modification_date') is not None: 1347 _dict['modification_date'] = datetime_to_string(getattr(self, 'modification_date')) 1348 if hasattr(self, 'modified_by') and getattr(self, 'modified_by') is not None: 1349 _dict['modified_by'] = getattr(self, 'modified_by') 1350 if hasattr(self, 'number_of_attachments') and getattr(self, 'number_of_attachments') is not None: 1351 _dict['number_of_attachments'] = getattr(self, 'number_of_attachments') 1352 return _dict 1353 1354 def _to_dict(self): 1355 """Return a json dictionary representing this model.""" 1356 return self.to_dict() 1357 1358 def __str__(self) -> str: 1359 """Return a `str` version of this Rule object.""" 1360 return json.dumps(self.to_dict(), indent=2) 1361 1362 def __eq__(self, other: 'Rule') -> bool: 1363 """Return `true` when self and other are equal, false otherwise.""" 1364 if not isinstance(other, self.__class__): 1365 return False 1366 return self.__dict__ == other.__dict__ 1367 1368 def __ne__(self, other: 'Rule') -> bool: 1369 """Return `true` when self and other are not equal, false otherwise.""" 1370 return not self == other 1371 1372 class RuleTypeEnum(str, Enum): 1373 """ 1374 The type of rule. Rules that you create are `user_defined`. 1375 """ 1376 USER_DEFINED = 'user_defined' 1377 1378 1379class RuleAttachment(): 1380 """ 1381 The scopes to attach to a rule. 1382 1383 :attr str attachment_id: The UUID that uniquely identifies the attachment. 1384 :attr str rule_id: The UUID that uniquely identifies the rule. 1385 :attr str account_id: Your IBM Cloud account ID. 1386 :attr RuleScope included_scope: The extent at which the rule can be attached 1387 across your accounts. 1388 :attr List[RuleScope] excluded_scopes: (optional) The extent at which the rule 1389 can be excluded from the included scope. 1390 """ 1391 1392 def __init__(self, 1393 attachment_id: str, 1394 rule_id: str, 1395 account_id: str, 1396 included_scope: 'RuleScope', 1397 *, 1398 excluded_scopes: List['RuleScope'] = None) -> None: 1399 """ 1400 Initialize a RuleAttachment object. 1401 1402 :param str attachment_id: The UUID that uniquely identifies the attachment. 1403 :param str rule_id: The UUID that uniquely identifies the rule. 1404 :param str account_id: Your IBM Cloud account ID. 1405 :param RuleScope included_scope: The extent at which the rule can be 1406 attached across your accounts. 1407 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 1408 rule can be excluded from the included scope. 1409 """ 1410 self.attachment_id = attachment_id 1411 self.rule_id = rule_id 1412 self.account_id = account_id 1413 self.included_scope = included_scope 1414 self.excluded_scopes = excluded_scopes 1415 1416 @classmethod 1417 def from_dict(cls, _dict: Dict) -> 'RuleAttachment': 1418 """Initialize a RuleAttachment object from a json dictionary.""" 1419 args = {} 1420 if 'attachment_id' in _dict: 1421 args['attachment_id'] = _dict.get('attachment_id') 1422 else: 1423 raise ValueError('Required property \'attachment_id\' not present in RuleAttachment JSON') 1424 if 'rule_id' in _dict: 1425 args['rule_id'] = _dict.get('rule_id') 1426 else: 1427 raise ValueError('Required property \'rule_id\' not present in RuleAttachment JSON') 1428 if 'account_id' in _dict: 1429 args['account_id'] = _dict.get('account_id') 1430 else: 1431 raise ValueError('Required property \'account_id\' not present in RuleAttachment JSON') 1432 if 'included_scope' in _dict: 1433 args['included_scope'] = RuleScope.from_dict(_dict.get('included_scope')) 1434 else: 1435 raise ValueError('Required property \'included_scope\' not present in RuleAttachment JSON') 1436 if 'excluded_scopes' in _dict: 1437 args['excluded_scopes'] = [RuleScope.from_dict(x) for x in _dict.get('excluded_scopes')] 1438 return cls(**args) 1439 1440 @classmethod 1441 def _from_dict(cls, _dict): 1442 """Initialize a RuleAttachment object from a json dictionary.""" 1443 return cls.from_dict(_dict) 1444 1445 def to_dict(self) -> Dict: 1446 """Return a json dictionary representing this model.""" 1447 _dict = {} 1448 if hasattr(self, 'attachment_id') and self.attachment_id is not None: 1449 _dict['attachment_id'] = self.attachment_id 1450 if hasattr(self, 'rule_id') and self.rule_id is not None: 1451 _dict['rule_id'] = self.rule_id 1452 if hasattr(self, 'account_id') and self.account_id is not None: 1453 _dict['account_id'] = self.account_id 1454 if hasattr(self, 'included_scope') and self.included_scope is not None: 1455 _dict['included_scope'] = self.included_scope.to_dict() 1456 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 1457 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 1458 return _dict 1459 1460 def _to_dict(self): 1461 """Return a json dictionary representing this model.""" 1462 return self.to_dict() 1463 1464 def __str__(self) -> str: 1465 """Return a `str` version of this RuleAttachment object.""" 1466 return json.dumps(self.to_dict(), indent=2) 1467 1468 def __eq__(self, other: 'RuleAttachment') -> bool: 1469 """Return `true` when self and other are equal, false otherwise.""" 1470 if not isinstance(other, self.__class__): 1471 return False 1472 return self.__dict__ == other.__dict__ 1473 1474 def __ne__(self, other: 'RuleAttachment') -> bool: 1475 """Return `true` when self and other are not equal, false otherwise.""" 1476 return not self == other 1477 1478class RuleAttachmentList(): 1479 """ 1480 A list of attachments. 1481 1482 :attr int offset: The requested offset for the returned items. 1483 :attr int limit: The requested limit for the returned items. 1484 :attr int total_count: The total number of available items. 1485 :attr Link first: The first page of available items. 1486 :attr Link last: The last page of available items. 1487 :attr List[RuleAttachment] attachments: 1488 """ 1489 1490 def __init__(self, 1491 offset: int, 1492 limit: int, 1493 total_count: int, 1494 first: 'Link', 1495 last: 'Link', 1496 attachments: List['RuleAttachment']) -> None: 1497 """ 1498 Initialize a RuleAttachmentList object. 1499 1500 :param int offset: The requested offset for the returned items. 1501 :param int limit: The requested limit for the returned items. 1502 :param int total_count: The total number of available items. 1503 :param Link first: The first page of available items. 1504 :param Link last: The last page of available items. 1505 :param List[RuleAttachment] attachments: 1506 """ 1507 self.offset = offset 1508 self.limit = limit 1509 self.total_count = total_count 1510 self.first = first 1511 self.last = last 1512 self.attachments = attachments 1513 1514 @classmethod 1515 def from_dict(cls, _dict: Dict) -> 'RuleAttachmentList': 1516 """Initialize a RuleAttachmentList object from a json dictionary.""" 1517 args = {} 1518 if 'offset' in _dict: 1519 args['offset'] = _dict.get('offset') 1520 else: 1521 raise ValueError('Required property \'offset\' not present in RuleAttachmentList JSON') 1522 if 'limit' in _dict: 1523 args['limit'] = _dict.get('limit') 1524 else: 1525 raise ValueError('Required property \'limit\' not present in RuleAttachmentList JSON') 1526 if 'total_count' in _dict: 1527 args['total_count'] = _dict.get('total_count') 1528 else: 1529 raise ValueError('Required property \'total_count\' not present in RuleAttachmentList JSON') 1530 if 'first' in _dict: 1531 args['first'] = Link.from_dict(_dict.get('first')) 1532 else: 1533 raise ValueError('Required property \'first\' not present in RuleAttachmentList JSON') 1534 if 'last' in _dict: 1535 args['last'] = Link.from_dict(_dict.get('last')) 1536 else: 1537 raise ValueError('Required property \'last\' not present in RuleAttachmentList JSON') 1538 if 'attachments' in _dict: 1539 args['attachments'] = [RuleAttachment.from_dict(x) for x in _dict.get('attachments')] 1540 else: 1541 raise ValueError('Required property \'attachments\' not present in RuleAttachmentList JSON') 1542 return cls(**args) 1543 1544 @classmethod 1545 def _from_dict(cls, _dict): 1546 """Initialize a RuleAttachmentList object from a json dictionary.""" 1547 return cls.from_dict(_dict) 1548 1549 def to_dict(self) -> Dict: 1550 """Return a json dictionary representing this model.""" 1551 _dict = {} 1552 if hasattr(self, 'offset') and self.offset is not None: 1553 _dict['offset'] = self.offset 1554 if hasattr(self, 'limit') and self.limit is not None: 1555 _dict['limit'] = self.limit 1556 if hasattr(self, 'total_count') and self.total_count is not None: 1557 _dict['total_count'] = self.total_count 1558 if hasattr(self, 'first') and self.first is not None: 1559 _dict['first'] = self.first.to_dict() 1560 if hasattr(self, 'last') and self.last is not None: 1561 _dict['last'] = self.last.to_dict() 1562 if hasattr(self, 'attachments') and self.attachments is not None: 1563 _dict['attachments'] = [x.to_dict() for x in self.attachments] 1564 return _dict 1565 1566 def _to_dict(self): 1567 """Return a json dictionary representing this model.""" 1568 return self.to_dict() 1569 1570 def __str__(self) -> str: 1571 """Return a `str` version of this RuleAttachmentList object.""" 1572 return json.dumps(self.to_dict(), indent=2) 1573 1574 def __eq__(self, other: 'RuleAttachmentList') -> bool: 1575 """Return `true` when self and other are equal, false otherwise.""" 1576 if not isinstance(other, self.__class__): 1577 return False 1578 return self.__dict__ == other.__dict__ 1579 1580 def __ne__(self, other: 'RuleAttachmentList') -> bool: 1581 """Return `true` when self and other are not equal, false otherwise.""" 1582 return not self == other 1583 1584class RuleAttachmentRequest(): 1585 """ 1586 The scopes to attach to a rule. 1587 1588 :attr str account_id: Your IBM Cloud account ID. 1589 :attr RuleScope included_scope: The extent at which the rule can be attached 1590 across your accounts. 1591 :attr List[RuleScope] excluded_scopes: (optional) The extent at which the rule 1592 can be excluded from the included scope. 1593 """ 1594 1595 def __init__(self, 1596 account_id: str, 1597 included_scope: 'RuleScope', 1598 *, 1599 excluded_scopes: List['RuleScope'] = None) -> None: 1600 """ 1601 Initialize a RuleAttachmentRequest object. 1602 1603 :param str account_id: Your IBM Cloud account ID. 1604 :param RuleScope included_scope: The extent at which the rule can be 1605 attached across your accounts. 1606 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 1607 rule can be excluded from the included scope. 1608 """ 1609 self.account_id = account_id 1610 self.included_scope = included_scope 1611 self.excluded_scopes = excluded_scopes 1612 1613 @classmethod 1614 def from_dict(cls, _dict: Dict) -> 'RuleAttachmentRequest': 1615 """Initialize a RuleAttachmentRequest object from a json dictionary.""" 1616 args = {} 1617 if 'account_id' in _dict: 1618 args['account_id'] = _dict.get('account_id') 1619 else: 1620 raise ValueError('Required property \'account_id\' not present in RuleAttachmentRequest JSON') 1621 if 'included_scope' in _dict: 1622 args['included_scope'] = RuleScope.from_dict(_dict.get('included_scope')) 1623 else: 1624 raise ValueError('Required property \'included_scope\' not present in RuleAttachmentRequest JSON') 1625 if 'excluded_scopes' in _dict: 1626 args['excluded_scopes'] = [RuleScope.from_dict(x) for x in _dict.get('excluded_scopes')] 1627 return cls(**args) 1628 1629 @classmethod 1630 def _from_dict(cls, _dict): 1631 """Initialize a RuleAttachmentRequest object from a json dictionary.""" 1632 return cls.from_dict(_dict) 1633 1634 def to_dict(self) -> Dict: 1635 """Return a json dictionary representing this model.""" 1636 _dict = {} 1637 if hasattr(self, 'account_id') and self.account_id is not None: 1638 _dict['account_id'] = self.account_id 1639 if hasattr(self, 'included_scope') and self.included_scope is not None: 1640 _dict['included_scope'] = self.included_scope.to_dict() 1641 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 1642 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 1643 return _dict 1644 1645 def _to_dict(self): 1646 """Return a json dictionary representing this model.""" 1647 return self.to_dict() 1648 1649 def __str__(self) -> str: 1650 """Return a `str` version of this RuleAttachmentRequest object.""" 1651 return json.dumps(self.to_dict(), indent=2) 1652 1653 def __eq__(self, other: 'RuleAttachmentRequest') -> bool: 1654 """Return `true` when self and other are equal, false otherwise.""" 1655 if not isinstance(other, self.__class__): 1656 return False 1657 return self.__dict__ == other.__dict__ 1658 1659 def __ne__(self, other: 'RuleAttachmentRequest') -> bool: 1660 """Return `true` when self and other are not equal, false otherwise.""" 1661 return not self == other 1662 1663class RuleCondition(): 1664 """ 1665 RuleCondition. 1666 1667 """ 1668 1669 def __init__(self) -> None: 1670 """ 1671 Initialize a RuleCondition object. 1672 1673 """ 1674 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 1675 ", ".join(['RuleConditionSingleProperty', 'RuleConditionOrLvl2', 'RuleConditionAndLvl2'])) 1676 raise Exception(msg) 1677 1678class RuleList(): 1679 """ 1680 A list of rules. 1681 1682 :attr int offset: The requested offset for the returned items. 1683 :attr int limit: The requested limit for the returned items. 1684 :attr int total_count: The total number of available items. 1685 :attr Link first: The first page of available items. 1686 :attr Link last: The last page of available items. 1687 :attr List[Rule] rules: An array of rules. 1688 """ 1689 1690 def __init__(self, 1691 offset: int, 1692 limit: int, 1693 total_count: int, 1694 first: 'Link', 1695 last: 'Link', 1696 rules: List['Rule']) -> None: 1697 """ 1698 Initialize a RuleList object. 1699 1700 :param int offset: The requested offset for the returned items. 1701 :param int limit: The requested limit for the returned items. 1702 :param int total_count: The total number of available items. 1703 :param Link first: The first page of available items. 1704 :param Link last: The last page of available items. 1705 :param List[Rule] rules: An array of rules. 1706 """ 1707 self.offset = offset 1708 self.limit = limit 1709 self.total_count = total_count 1710 self.first = first 1711 self.last = last 1712 self.rules = rules 1713 1714 @classmethod 1715 def from_dict(cls, _dict: Dict) -> 'RuleList': 1716 """Initialize a RuleList object from a json dictionary.""" 1717 args = {} 1718 if 'offset' in _dict: 1719 args['offset'] = _dict.get('offset') 1720 else: 1721 raise ValueError('Required property \'offset\' not present in RuleList JSON') 1722 if 'limit' in _dict: 1723 args['limit'] = _dict.get('limit') 1724 else: 1725 raise ValueError('Required property \'limit\' not present in RuleList JSON') 1726 if 'total_count' in _dict: 1727 args['total_count'] = _dict.get('total_count') 1728 else: 1729 raise ValueError('Required property \'total_count\' not present in RuleList JSON') 1730 if 'first' in _dict: 1731 args['first'] = Link.from_dict(_dict.get('first')) 1732 else: 1733 raise ValueError('Required property \'first\' not present in RuleList JSON') 1734 if 'last' in _dict: 1735 args['last'] = Link.from_dict(_dict.get('last')) 1736 else: 1737 raise ValueError('Required property \'last\' not present in RuleList JSON') 1738 if 'rules' in _dict: 1739 args['rules'] = [Rule.from_dict(x) for x in _dict.get('rules')] 1740 else: 1741 raise ValueError('Required property \'rules\' not present in RuleList JSON') 1742 return cls(**args) 1743 1744 @classmethod 1745 def _from_dict(cls, _dict): 1746 """Initialize a RuleList object from a json dictionary.""" 1747 return cls.from_dict(_dict) 1748 1749 def to_dict(self) -> Dict: 1750 """Return a json dictionary representing this model.""" 1751 _dict = {} 1752 if hasattr(self, 'offset') and self.offset is not None: 1753 _dict['offset'] = self.offset 1754 if hasattr(self, 'limit') and self.limit is not None: 1755 _dict['limit'] = self.limit 1756 if hasattr(self, 'total_count') and self.total_count is not None: 1757 _dict['total_count'] = self.total_count 1758 if hasattr(self, 'first') and self.first is not None: 1759 _dict['first'] = self.first.to_dict() 1760 if hasattr(self, 'last') and self.last is not None: 1761 _dict['last'] = self.last.to_dict() 1762 if hasattr(self, 'rules') and self.rules is not None: 1763 _dict['rules'] = [x.to_dict() for x in self.rules] 1764 return _dict 1765 1766 def _to_dict(self): 1767 """Return a json dictionary representing this model.""" 1768 return self.to_dict() 1769 1770 def __str__(self) -> str: 1771 """Return a `str` version of this RuleList object.""" 1772 return json.dumps(self.to_dict(), indent=2) 1773 1774 def __eq__(self, other: 'RuleList') -> bool: 1775 """Return `true` when self and other are equal, false otherwise.""" 1776 if not isinstance(other, self.__class__): 1777 return False 1778 return self.__dict__ == other.__dict__ 1779 1780 def __ne__(self, other: 'RuleList') -> bool: 1781 """Return `true` when self and other are not equal, false otherwise.""" 1782 return not self == other 1783 1784class RuleRequest(): 1785 """ 1786 Properties that you can associate with a rule. 1787 1788 :attr str account_id: (optional) Your IBM Cloud account ID. 1789 :attr str name: A human-readable alias to assign to your rule. 1790 :attr str description: An extended description of your rule. 1791 :attr str rule_type: (optional) The type of rule. Rules that you create are 1792 `user_defined`. 1793 :attr TargetResource target: The properties that describe the resource that you 1794 want to target 1795 with the rule or template. 1796 :attr RuleRequiredConfig required_config: 1797 :attr List[EnforcementAction] enforcement_actions: The actions that the service 1798 must run on your behalf when a request to create or modify the target resource 1799 does not comply with your conditions. 1800 :attr List[str] labels: (optional) Labels that you can use to group and search 1801 for similar rules, such as those that help you to meet a specific organization 1802 guideline. 1803 """ 1804 1805 def __init__(self, 1806 name: str, 1807 description: str, 1808 target: 'TargetResource', 1809 required_config: 'RuleRequiredConfig', 1810 enforcement_actions: List['EnforcementAction'], 1811 *, 1812 account_id: str = None, 1813 rule_type: str = None, 1814 labels: List[str] = None) -> None: 1815 """ 1816 Initialize a RuleRequest object. 1817 1818 :param str name: A human-readable alias to assign to your rule. 1819 :param str description: An extended description of your rule. 1820 :param TargetResource target: The properties that describe the resource 1821 that you want to target 1822 with the rule or template. 1823 :param RuleRequiredConfig required_config: 1824 :param List[EnforcementAction] enforcement_actions: The actions that the 1825 service must run on your behalf when a request to create or modify the 1826 target resource does not comply with your conditions. 1827 :param str account_id: (optional) Your IBM Cloud account ID. 1828 :param str rule_type: (optional) The type of rule. Rules that you create 1829 are `user_defined`. 1830 :param List[str] labels: (optional) Labels that you can use to group and 1831 search for similar rules, such as those that help you to meet a specific 1832 organization guideline. 1833 """ 1834 self.account_id = account_id 1835 self.name = name 1836 self.description = description 1837 self.rule_type = rule_type 1838 self.target = target 1839 self.required_config = required_config 1840 self.enforcement_actions = enforcement_actions 1841 self.labels = labels 1842 1843 @classmethod 1844 def from_dict(cls, _dict: Dict) -> 'RuleRequest': 1845 """Initialize a RuleRequest object from a json dictionary.""" 1846 args = {} 1847 if 'account_id' in _dict: 1848 args['account_id'] = _dict.get('account_id') 1849 if 'name' in _dict: 1850 args['name'] = _dict.get('name') 1851 else: 1852 raise ValueError('Required property \'name\' not present in RuleRequest JSON') 1853 if 'description' in _dict: 1854 args['description'] = _dict.get('description') 1855 else: 1856 raise ValueError('Required property \'description\' not present in RuleRequest JSON') 1857 if 'rule_type' in _dict: 1858 args['rule_type'] = _dict.get('rule_type') 1859 if 'target' in _dict: 1860 args['target'] = TargetResource.from_dict(_dict.get('target')) 1861 else: 1862 raise ValueError('Required property \'target\' not present in RuleRequest JSON') 1863 if 'required_config' in _dict: 1864 args['required_config'] = _dict.get('required_config') 1865 else: 1866 raise ValueError('Required property \'required_config\' not present in RuleRequest JSON') 1867 if 'enforcement_actions' in _dict: 1868 args['enforcement_actions'] = [EnforcementAction.from_dict(x) for x in _dict.get('enforcement_actions')] 1869 else: 1870 raise ValueError('Required property \'enforcement_actions\' not present in RuleRequest JSON') 1871 if 'labels' in _dict: 1872 args['labels'] = _dict.get('labels') 1873 return cls(**args) 1874 1875 @classmethod 1876 def _from_dict(cls, _dict): 1877 """Initialize a RuleRequest object from a json dictionary.""" 1878 return cls.from_dict(_dict) 1879 1880 def to_dict(self) -> Dict: 1881 """Return a json dictionary representing this model.""" 1882 _dict = {} 1883 if hasattr(self, 'account_id') and self.account_id is not None: 1884 _dict['account_id'] = self.account_id 1885 if hasattr(self, 'name') and self.name is not None: 1886 _dict['name'] = self.name 1887 if hasattr(self, 'description') and self.description is not None: 1888 _dict['description'] = self.description 1889 if hasattr(self, 'rule_type') and self.rule_type is not None: 1890 _dict['rule_type'] = self.rule_type 1891 if hasattr(self, 'target') and self.target is not None: 1892 _dict['target'] = self.target.to_dict() 1893 if hasattr(self, 'required_config') and self.required_config is not None: 1894 if isinstance(self.required_config, dict): 1895 _dict['required_config'] = self.required_config 1896 else: 1897 _dict['required_config'] = self.required_config.to_dict() 1898 if hasattr(self, 'enforcement_actions') and self.enforcement_actions is not None: 1899 _dict['enforcement_actions'] = [x.to_dict() for x in self.enforcement_actions] 1900 if hasattr(self, 'labels') and self.labels is not None: 1901 _dict['labels'] = self.labels 1902 return _dict 1903 1904 def _to_dict(self): 1905 """Return a json dictionary representing this model.""" 1906 return self.to_dict() 1907 1908 def __str__(self) -> str: 1909 """Return a `str` version of this RuleRequest object.""" 1910 return json.dumps(self.to_dict(), indent=2) 1911 1912 def __eq__(self, other: 'RuleRequest') -> bool: 1913 """Return `true` when self and other are equal, false otherwise.""" 1914 if not isinstance(other, self.__class__): 1915 return False 1916 return self.__dict__ == other.__dict__ 1917 1918 def __ne__(self, other: 'RuleRequest') -> bool: 1919 """Return `true` when self and other are not equal, false otherwise.""" 1920 return not self == other 1921 1922 class RuleTypeEnum(str, Enum): 1923 """ 1924 The type of rule. Rules that you create are `user_defined`. 1925 """ 1926 USER_DEFINED = 'user_defined' 1927 1928 1929class RuleRequiredConfig(): 1930 """ 1931 RuleRequiredConfig. 1932 1933 """ 1934 1935 def __init__(self) -> None: 1936 """ 1937 Initialize a RuleRequiredConfig object. 1938 1939 """ 1940 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 1941 ", ".join(['RuleRequiredConfigSingleProperty', 'RuleRequiredConfigMultipleProperties'])) 1942 raise Exception(msg) 1943 1944class RuleResponseError(): 1945 """ 1946 RuleResponseError. 1947 1948 :attr str code: Specifies the problem that caused the error. 1949 :attr str message: Describes the problem. 1950 """ 1951 1952 def __init__(self, 1953 code: str, 1954 message: str) -> None: 1955 """ 1956 Initialize a RuleResponseError object. 1957 1958 :param str code: Specifies the problem that caused the error. 1959 :param str message: Describes the problem. 1960 """ 1961 self.code = code 1962 self.message = message 1963 1964 @classmethod 1965 def from_dict(cls, _dict: Dict) -> 'RuleResponseError': 1966 """Initialize a RuleResponseError object from a json dictionary.""" 1967 args = {} 1968 if 'code' in _dict: 1969 args['code'] = _dict.get('code') 1970 else: 1971 raise ValueError('Required property \'code\' not present in RuleResponseError JSON') 1972 if 'message' in _dict: 1973 args['message'] = _dict.get('message') 1974 else: 1975 raise ValueError('Required property \'message\' not present in RuleResponseError JSON') 1976 return cls(**args) 1977 1978 @classmethod 1979 def _from_dict(cls, _dict): 1980 """Initialize a RuleResponseError object from a json dictionary.""" 1981 return cls.from_dict(_dict) 1982 1983 def to_dict(self) -> Dict: 1984 """Return a json dictionary representing this model.""" 1985 _dict = {} 1986 if hasattr(self, 'code') and self.code is not None: 1987 _dict['code'] = self.code 1988 if hasattr(self, 'message') and self.message is not None: 1989 _dict['message'] = self.message 1990 return _dict 1991 1992 def _to_dict(self): 1993 """Return a json dictionary representing this model.""" 1994 return self.to_dict() 1995 1996 def __str__(self) -> str: 1997 """Return a `str` version of this RuleResponseError object.""" 1998 return json.dumps(self.to_dict(), indent=2) 1999 2000 def __eq__(self, other: 'RuleResponseError') -> bool: 2001 """Return `true` when self and other are equal, false otherwise.""" 2002 if not isinstance(other, self.__class__): 2003 return False 2004 return self.__dict__ == other.__dict__ 2005 2006 def __ne__(self, other: 'RuleResponseError') -> bool: 2007 """Return `true` when self and other are not equal, false otherwise.""" 2008 return not self == other 2009 2010class RuleScope(): 2011 """ 2012 The extent at which the rule can be attached across your accounts. 2013 2014 :attr str note: (optional) A short description or alias to assign to the scope. 2015 :attr str scope_id: The ID of the scope, such as an enterprise, account, or 2016 account group, that you want to evaluate. 2017 :attr str scope_type: The type of scope that you want to evaluate. 2018 """ 2019 2020 def __init__(self, 2021 scope_id: str, 2022 scope_type: str, 2023 *, 2024 note: str = None) -> None: 2025 """ 2026 Initialize a RuleScope object. 2027 2028 :param str scope_id: The ID of the scope, such as an enterprise, account, 2029 or account group, that you want to evaluate. 2030 :param str scope_type: The type of scope that you want to evaluate. 2031 :param str note: (optional) A short description or alias to assign to the 2032 scope. 2033 """ 2034 self.note = note 2035 self.scope_id = scope_id 2036 self.scope_type = scope_type 2037 2038 @classmethod 2039 def from_dict(cls, _dict: Dict) -> 'RuleScope': 2040 """Initialize a RuleScope object from a json dictionary.""" 2041 args = {} 2042 if 'note' in _dict: 2043 args['note'] = _dict.get('note') 2044 if 'scope_id' in _dict: 2045 args['scope_id'] = _dict.get('scope_id') 2046 else: 2047 raise ValueError('Required property \'scope_id\' not present in RuleScope JSON') 2048 if 'scope_type' in _dict: 2049 args['scope_type'] = _dict.get('scope_type') 2050 else: 2051 raise ValueError('Required property \'scope_type\' not present in RuleScope JSON') 2052 return cls(**args) 2053 2054 @classmethod 2055 def _from_dict(cls, _dict): 2056 """Initialize a RuleScope object from a json dictionary.""" 2057 return cls.from_dict(_dict) 2058 2059 def to_dict(self) -> Dict: 2060 """Return a json dictionary representing this model.""" 2061 _dict = {} 2062 if hasattr(self, 'note') and self.note is not None: 2063 _dict['note'] = self.note 2064 if hasattr(self, 'scope_id') and self.scope_id is not None: 2065 _dict['scope_id'] = self.scope_id 2066 if hasattr(self, 'scope_type') and self.scope_type is not None: 2067 _dict['scope_type'] = self.scope_type 2068 return _dict 2069 2070 def _to_dict(self): 2071 """Return a json dictionary representing this model.""" 2072 return self.to_dict() 2073 2074 def __str__(self) -> str: 2075 """Return a `str` version of this RuleScope object.""" 2076 return json.dumps(self.to_dict(), indent=2) 2077 2078 def __eq__(self, other: 'RuleScope') -> bool: 2079 """Return `true` when self and other are equal, false otherwise.""" 2080 if not isinstance(other, self.__class__): 2081 return False 2082 return self.__dict__ == other.__dict__ 2083 2084 def __ne__(self, other: 'RuleScope') -> bool: 2085 """Return `true` when self and other are not equal, false otherwise.""" 2086 return not self == other 2087 2088 class ScopeTypeEnum(str, Enum): 2089 """ 2090 The type of scope that you want to evaluate. 2091 """ 2092 ENTERPRISE = 'enterprise' 2093 ENTERPRISE_ACCOUNT_GROUP = 'enterprise.account_group' 2094 ENTERPRISE_ACCOUNT = 'enterprise.account' 2095 ACCOUNT = 'account' 2096 ACCOUNT_RESOURCE_GROUP = 'account.resource_group' 2097 2098 2099class RuleSingleProperty(): 2100 """ 2101 The requirement that must be met to determine the resource's level of compliance in 2102 accordance with the rule. 2103 To apply a single property check, define a configuration property and the desired 2104 value that you want to check against. 2105 2106 :attr str description: (optional) 2107 :attr str property: A resource configuration variable that describes the 2108 property that you want to apply to the target resource. 2109 Available options depend on the target service and resource. 2110 :attr str operator: The way in which the `property` field is compared to its 2111 value. 2112 To learn more, see the 2113 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2114 :attr str value: (optional) The way in which you want your property to be 2115 applied. 2116 Value options differ depending on the rule that you configure. If you use a 2117 boolean operator, you do not need to input a value. 2118 """ 2119 2120 def __init__(self, 2121 property: str, 2122 operator: str, 2123 *, 2124 description: str = None, 2125 value: str = None) -> None: 2126 """ 2127 Initialize a RuleSingleProperty object. 2128 2129 :param str property: A resource configuration variable that describes the 2130 property that you want to apply to the target resource. 2131 Available options depend on the target service and resource. 2132 :param str operator: The way in which the `property` field is compared to 2133 its value. 2134 To learn more, see the 2135 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2136 :param str description: (optional) 2137 :param str value: (optional) The way in which you want your property to be 2138 applied. 2139 Value options differ depending on the rule that you configure. If you use a 2140 boolean operator, you do not need to input a value. 2141 """ 2142 self.description = description 2143 self.property = property 2144 self.operator = operator 2145 self.value = value 2146 2147 @classmethod 2148 def from_dict(cls, _dict: Dict) -> 'RuleSingleProperty': 2149 """Initialize a RuleSingleProperty object from a json dictionary.""" 2150 args = {} 2151 if 'description' in _dict: 2152 args['description'] = _dict.get('description') 2153 if 'property' in _dict: 2154 args['property'] = _dict.get('property') 2155 else: 2156 raise ValueError('Required property \'property\' not present in RuleSingleProperty JSON') 2157 if 'operator' in _dict: 2158 args['operator'] = _dict.get('operator') 2159 else: 2160 raise ValueError('Required property \'operator\' not present in RuleSingleProperty JSON') 2161 if 'value' in _dict: 2162 args['value'] = _dict.get('value') 2163 return cls(**args) 2164 2165 @classmethod 2166 def _from_dict(cls, _dict): 2167 """Initialize a RuleSingleProperty object from a json dictionary.""" 2168 return cls.from_dict(_dict) 2169 2170 def to_dict(self) -> Dict: 2171 """Return a json dictionary representing this model.""" 2172 _dict = {} 2173 if hasattr(self, 'description') and self.description is not None: 2174 _dict['description'] = self.description 2175 if hasattr(self, 'property') and self.property is not None: 2176 _dict['property'] = self.property 2177 if hasattr(self, 'operator') and self.operator is not None: 2178 _dict['operator'] = self.operator 2179 if hasattr(self, 'value') and self.value is not None: 2180 _dict['value'] = self.value 2181 return _dict 2182 2183 def _to_dict(self): 2184 """Return a json dictionary representing this model.""" 2185 return self.to_dict() 2186 2187 def __str__(self) -> str: 2188 """Return a `str` version of this RuleSingleProperty object.""" 2189 return json.dumps(self.to_dict(), indent=2) 2190 2191 def __eq__(self, other: 'RuleSingleProperty') -> bool: 2192 """Return `true` when self and other are equal, false otherwise.""" 2193 if not isinstance(other, self.__class__): 2194 return False 2195 return self.__dict__ == other.__dict__ 2196 2197 def __ne__(self, other: 'RuleSingleProperty') -> bool: 2198 """Return `true` when self and other are not equal, false otherwise.""" 2199 return not self == other 2200 2201 class OperatorEnum(str, Enum): 2202 """ 2203 The way in which the `property` field is compared to its value. 2204 To learn more, see the 2205 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2206 """ 2207 IS_TRUE = 'is_true' 2208 IS_FALSE = 'is_false' 2209 IS_EMPTY = 'is_empty' 2210 IS_NOT_EMPTY = 'is_not_empty' 2211 STRING_EQUALS = 'string_equals' 2212 STRING_NOT_EQUALS = 'string_not_equals' 2213 STRING_MATCH = 'string_match' 2214 STRING_NOT_MATCH = 'string_not_match' 2215 NUM_EQUALS = 'num_equals' 2216 NUM_NOT_EQUALS = 'num_not_equals' 2217 NUM_LESS_THAN = 'num_less_than' 2218 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2219 NUM_GREATER_THAN = 'num_greater_than' 2220 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2221 IPS_IN_RANGE = 'ips_in_range' 2222 STRINGS_IN_LIST = 'strings_in_list' 2223 2224 2225class TargetResource(): 2226 """ 2227 The properties that describe the resource that you want to target with the rule or 2228 template. 2229 2230 :attr str service_name: The programmatic name of the IBM Cloud service that you 2231 want to target with the rule or template. 2232 :attr str resource_kind: The type of resource that you want to target. 2233 :attr List[TargetResourceAdditionalTargetAttributesItem] 2234 additional_target_attributes: (optional) An extra qualifier for the resource 2235 kind. When you include additional attributes, only the resources that match the 2236 definition are included in the rule or template. 2237 """ 2238 2239 def __init__(self, 2240 service_name: str, 2241 resource_kind: str, 2242 *, 2243 additional_target_attributes: List['TargetResourceAdditionalTargetAttributesItem'] = None) -> None: 2244 """ 2245 Initialize a TargetResource object. 2246 2247 :param str service_name: The programmatic name of the IBM Cloud service 2248 that you want to target with the rule or template. 2249 :param str resource_kind: The type of resource that you want to target. 2250 :param List[TargetResourceAdditionalTargetAttributesItem] 2251 additional_target_attributes: (optional) An extra qualifier for the 2252 resource kind. When you include additional attributes, only the resources 2253 that match the definition are included in the rule or template. 2254 """ 2255 self.service_name = service_name 2256 self.resource_kind = resource_kind 2257 self.additional_target_attributes = additional_target_attributes 2258 2259 @classmethod 2260 def from_dict(cls, _dict: Dict) -> 'TargetResource': 2261 """Initialize a TargetResource object from a json dictionary.""" 2262 args = {} 2263 if 'service_name' in _dict: 2264 args['service_name'] = _dict.get('service_name') 2265 else: 2266 raise ValueError('Required property \'service_name\' not present in TargetResource JSON') 2267 if 'resource_kind' in _dict: 2268 args['resource_kind'] = _dict.get('resource_kind') 2269 else: 2270 raise ValueError('Required property \'resource_kind\' not present in TargetResource JSON') 2271 if 'additional_target_attributes' in _dict: 2272 args['additional_target_attributes'] = [TargetResourceAdditionalTargetAttributesItem.from_dict(x) for x in _dict.get('additional_target_attributes')] 2273 return cls(**args) 2274 2275 @classmethod 2276 def _from_dict(cls, _dict): 2277 """Initialize a TargetResource object from a json dictionary.""" 2278 return cls.from_dict(_dict) 2279 2280 def to_dict(self) -> Dict: 2281 """Return a json dictionary representing this model.""" 2282 _dict = {} 2283 if hasattr(self, 'service_name') and self.service_name is not None: 2284 _dict['service_name'] = self.service_name 2285 if hasattr(self, 'resource_kind') and self.resource_kind is not None: 2286 _dict['resource_kind'] = self.resource_kind 2287 if hasattr(self, 'additional_target_attributes') and self.additional_target_attributes is not None: 2288 _dict['additional_target_attributes'] = [x.to_dict() for x in self.additional_target_attributes] 2289 return _dict 2290 2291 def _to_dict(self): 2292 """Return a json dictionary representing this model.""" 2293 return self.to_dict() 2294 2295 def __str__(self) -> str: 2296 """Return a `str` version of this TargetResource object.""" 2297 return json.dumps(self.to_dict(), indent=2) 2298 2299 def __eq__(self, other: 'TargetResource') -> bool: 2300 """Return `true` when self and other are equal, false otherwise.""" 2301 if not isinstance(other, self.__class__): 2302 return False 2303 return self.__dict__ == other.__dict__ 2304 2305 def __ne__(self, other: 'TargetResource') -> bool: 2306 """Return `true` when self and other are not equal, false otherwise.""" 2307 return not self == other 2308 2309class TargetResourceAdditionalTargetAttributesItem(): 2310 """ 2311 The attributes that are associated with a rule or template target. 2312 2313 :attr str name: The name of the additional attribute that you want to use to 2314 further qualify the target. 2315 Options differ depending on the service or resource that you are targeting with 2316 a rule or template. For more information, refer to the service documentation. 2317 :attr str value: The value that you want to apply to `name` field. 2318 Options differ depending on the rule or template that you configure. For more 2319 information, refer to the service documentation. 2320 :attr str operator: The way in which the `name` field is compared to its value. 2321 There are three types of operators: string, numeric, and boolean. 2322 """ 2323 2324 def __init__(self, 2325 name: str, 2326 value: str, 2327 operator: str) -> None: 2328 """ 2329 Initialize a TargetResourceAdditionalTargetAttributesItem object. 2330 2331 :param str name: The name of the additional attribute that you want to use 2332 to further qualify the target. 2333 Options differ depending on the service or resource that you are targeting 2334 with a rule or template. For more information, refer to the service 2335 documentation. 2336 :param str value: The value that you want to apply to `name` field. 2337 Options differ depending on the rule or template that you configure. For 2338 more information, refer to the service documentation. 2339 :param str operator: The way in which the `name` field is compared to its 2340 value. 2341 There are three types of operators: string, numeric, and boolean. 2342 """ 2343 self.name = name 2344 self.value = value 2345 self.operator = operator 2346 2347 @classmethod 2348 def from_dict(cls, _dict: Dict) -> 'TargetResourceAdditionalTargetAttributesItem': 2349 """Initialize a TargetResourceAdditionalTargetAttributesItem object from a json dictionary.""" 2350 args = {} 2351 if 'name' in _dict: 2352 args['name'] = _dict.get('name') 2353 else: 2354 raise ValueError('Required property \'name\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2355 if 'value' in _dict: 2356 args['value'] = _dict.get('value') 2357 else: 2358 raise ValueError('Required property \'value\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2359 if 'operator' in _dict: 2360 args['operator'] = _dict.get('operator') 2361 else: 2362 raise ValueError('Required property \'operator\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2363 return cls(**args) 2364 2365 @classmethod 2366 def _from_dict(cls, _dict): 2367 """Initialize a TargetResourceAdditionalTargetAttributesItem object from a json dictionary.""" 2368 return cls.from_dict(_dict) 2369 2370 def to_dict(self) -> Dict: 2371 """Return a json dictionary representing this model.""" 2372 _dict = {} 2373 if hasattr(self, 'name') and self.name is not None: 2374 _dict['name'] = self.name 2375 if hasattr(self, 'value') and self.value is not None: 2376 _dict['value'] = self.value 2377 if hasattr(self, 'operator') and self.operator is not None: 2378 _dict['operator'] = self.operator 2379 return _dict 2380 2381 def _to_dict(self): 2382 """Return a json dictionary representing this model.""" 2383 return self.to_dict() 2384 2385 def __str__(self) -> str: 2386 """Return a `str` version of this TargetResourceAdditionalTargetAttributesItem object.""" 2387 return json.dumps(self.to_dict(), indent=2) 2388 2389 def __eq__(self, other: 'TargetResourceAdditionalTargetAttributesItem') -> bool: 2390 """Return `true` when self and other are equal, false otherwise.""" 2391 if not isinstance(other, self.__class__): 2392 return False 2393 return self.__dict__ == other.__dict__ 2394 2395 def __ne__(self, other: 'TargetResourceAdditionalTargetAttributesItem') -> bool: 2396 """Return `true` when self and other are not equal, false otherwise.""" 2397 return not self == other 2398 2399 class OperatorEnum(str, Enum): 2400 """ 2401 The way in which the `name` field is compared to its value. 2402 There are three types of operators: string, numeric, and boolean. 2403 """ 2404 STRING_EQUALS = 'string_equals' 2405 STRING_NOT_EQUALS = 'string_not_equals' 2406 STRING_MATCH = 'string_match' 2407 STRING_NOT_MATCH = 'string_not_match' 2408 STRINGS_IN_LIST = 'strings_in_list' 2409 IPS_IN_RANGE = 'ips_in_range' 2410 NUM_EQUALS = 'num_equals' 2411 NUM_NOT_EQUALS = 'num_not_equals' 2412 NUM_LESS_THAN = 'num_less_than' 2413 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2414 NUM_GREATER_THAN = 'num_greater_than' 2415 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2416 IS_EMPTY = 'is_empty' 2417 IS_NOT_EMPTY = 'is_not_empty' 2418 IS_TRUE = 'is_true' 2419 IS_FALSE = 'is_false' 2420 2421 2422class TemplateAttachment(): 2423 """ 2424 The scopes to attach to a template. 2425 2426 :attr str attachment_id: The UUID that uniquely identifies the attachment. 2427 :attr str template_id: The UUID that uniquely identifies the template. 2428 :attr str account_id: Your IBM Cloud account ID. 2429 :attr TemplateScope included_scope: The extent at which the template can be 2430 attached across your accounts. 2431 :attr List[TemplateScope] excluded_scopes: (optional) 2432 """ 2433 2434 def __init__(self, 2435 attachment_id: str, 2436 template_id: str, 2437 account_id: str, 2438 included_scope: 'TemplateScope', 2439 *, 2440 excluded_scopes: List['TemplateScope'] = None) -> None: 2441 """ 2442 Initialize a TemplateAttachment object. 2443 2444 :param str attachment_id: The UUID that uniquely identifies the attachment. 2445 :param str template_id: The UUID that uniquely identifies the template. 2446 :param str account_id: Your IBM Cloud account ID. 2447 :param TemplateScope included_scope: The extent at which the template can 2448 be attached across your accounts. 2449 :param List[TemplateScope] excluded_scopes: (optional) 2450 """ 2451 self.attachment_id = attachment_id 2452 self.template_id = template_id 2453 self.account_id = account_id 2454 self.included_scope = included_scope 2455 self.excluded_scopes = excluded_scopes 2456 2457 @classmethod 2458 def from_dict(cls, _dict: Dict) -> 'TemplateAttachment': 2459 """Initialize a TemplateAttachment object from a json dictionary.""" 2460 args = {} 2461 if 'attachment_id' in _dict: 2462 args['attachment_id'] = _dict.get('attachment_id') 2463 else: 2464 raise ValueError('Required property \'attachment_id\' not present in TemplateAttachment JSON') 2465 if 'template_id' in _dict: 2466 args['template_id'] = _dict.get('template_id') 2467 else: 2468 raise ValueError('Required property \'template_id\' not present in TemplateAttachment JSON') 2469 if 'account_id' in _dict: 2470 args['account_id'] = _dict.get('account_id') 2471 else: 2472 raise ValueError('Required property \'account_id\' not present in TemplateAttachment JSON') 2473 if 'included_scope' in _dict: 2474 args['included_scope'] = TemplateScope.from_dict(_dict.get('included_scope')) 2475 else: 2476 raise ValueError('Required property \'included_scope\' not present in TemplateAttachment JSON') 2477 if 'excluded_scopes' in _dict: 2478 args['excluded_scopes'] = [TemplateScope.from_dict(x) for x in _dict.get('excluded_scopes')] 2479 return cls(**args) 2480 2481 @classmethod 2482 def _from_dict(cls, _dict): 2483 """Initialize a TemplateAttachment object from a json dictionary.""" 2484 return cls.from_dict(_dict) 2485 2486 def to_dict(self) -> Dict: 2487 """Return a json dictionary representing this model.""" 2488 _dict = {} 2489 if hasattr(self, 'attachment_id') and self.attachment_id is not None: 2490 _dict['attachment_id'] = self.attachment_id 2491 if hasattr(self, 'template_id') and self.template_id is not None: 2492 _dict['template_id'] = self.template_id 2493 if hasattr(self, 'account_id') and self.account_id is not None: 2494 _dict['account_id'] = self.account_id 2495 if hasattr(self, 'included_scope') and self.included_scope is not None: 2496 _dict['included_scope'] = self.included_scope.to_dict() 2497 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 2498 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 2499 return _dict 2500 2501 def _to_dict(self): 2502 """Return a json dictionary representing this model.""" 2503 return self.to_dict() 2504 2505 def __str__(self) -> str: 2506 """Return a `str` version of this TemplateAttachment object.""" 2507 return json.dumps(self.to_dict(), indent=2) 2508 2509 def __eq__(self, other: 'TemplateAttachment') -> bool: 2510 """Return `true` when self and other are equal, false otherwise.""" 2511 if not isinstance(other, self.__class__): 2512 return False 2513 return self.__dict__ == other.__dict__ 2514 2515 def __ne__(self, other: 'TemplateAttachment') -> bool: 2516 """Return `true` when self and other are not equal, false otherwise.""" 2517 return not self == other 2518 2519class TemplateScope(): 2520 """ 2521 The extent at which the template can be attached across your accounts. 2522 2523 :attr str note: (optional) A short description or alias to assign to the scope. 2524 :attr str scope_id: The ID of the scope, such as an enterprise, account, or 2525 account group, where you want to apply the customized defaults that are 2526 associated with a template. 2527 :attr str scope_type: The type of scope. 2528 """ 2529 2530 def __init__(self, 2531 scope_id: str, 2532 scope_type: str, 2533 *, 2534 note: str = None) -> None: 2535 """ 2536 Initialize a TemplateScope object. 2537 2538 :param str scope_id: The ID of the scope, such as an enterprise, account, 2539 or account group, where you want to apply the customized defaults that are 2540 associated with a template. 2541 :param str scope_type: The type of scope. 2542 :param str note: (optional) A short description or alias to assign to the 2543 scope. 2544 """ 2545 self.note = note 2546 self.scope_id = scope_id 2547 self.scope_type = scope_type 2548 2549 @classmethod 2550 def from_dict(cls, _dict: Dict) -> 'TemplateScope': 2551 """Initialize a TemplateScope object from a json dictionary.""" 2552 args = {} 2553 if 'note' in _dict: 2554 args['note'] = _dict.get('note') 2555 if 'scope_id' in _dict: 2556 args['scope_id'] = _dict.get('scope_id') 2557 else: 2558 raise ValueError('Required property \'scope_id\' not present in TemplateScope JSON') 2559 if 'scope_type' in _dict: 2560 args['scope_type'] = _dict.get('scope_type') 2561 else: 2562 raise ValueError('Required property \'scope_type\' not present in TemplateScope JSON') 2563 return cls(**args) 2564 2565 @classmethod 2566 def _from_dict(cls, _dict): 2567 """Initialize a TemplateScope object from a json dictionary.""" 2568 return cls.from_dict(_dict) 2569 2570 def to_dict(self) -> Dict: 2571 """Return a json dictionary representing this model.""" 2572 _dict = {} 2573 if hasattr(self, 'note') and self.note is not None: 2574 _dict['note'] = self.note 2575 if hasattr(self, 'scope_id') and self.scope_id is not None: 2576 _dict['scope_id'] = self.scope_id 2577 if hasattr(self, 'scope_type') and self.scope_type is not None: 2578 _dict['scope_type'] = self.scope_type 2579 return _dict 2580 2581 def _to_dict(self): 2582 """Return a json dictionary representing this model.""" 2583 return self.to_dict() 2584 2585 def __str__(self) -> str: 2586 """Return a `str` version of this TemplateScope object.""" 2587 return json.dumps(self.to_dict(), indent=2) 2588 2589 def __eq__(self, other: 'TemplateScope') -> bool: 2590 """Return `true` when self and other are equal, false otherwise.""" 2591 if not isinstance(other, self.__class__): 2592 return False 2593 return self.__dict__ == other.__dict__ 2594 2595 def __ne__(self, other: 'TemplateScope') -> bool: 2596 """Return `true` when self and other are not equal, false otherwise.""" 2597 return not self == other 2598 2599 class ScopeTypeEnum(str, Enum): 2600 """ 2601 The type of scope. 2602 """ 2603 ENTERPRISE = 'enterprise' 2604 ENTERPRISE_ACCOUNT_GROUP = 'enterprise.account_group' 2605 ENTERPRISE_ACCOUNT = 'enterprise.account' 2606 ACCOUNT = 'account' 2607 ACCOUNT_RESOURCE_GROUP = 'account.resource_group' 2608 2609 2610class RuleConditionAndLvl2(RuleCondition): 2611 """ 2612 A condition with the `and` logical operator. 2613 2614 :attr str description: (optional) 2615 :attr List[RuleSingleProperty] and_: 2616 """ 2617 2618 def __init__(self, 2619 and_: List['RuleSingleProperty'], 2620 *, 2621 description: str = None) -> None: 2622 """ 2623 Initialize a RuleConditionAndLvl2 object. 2624 2625 :param List[RuleSingleProperty] and_: 2626 :param str description: (optional) 2627 """ 2628 # pylint: disable=super-init-not-called 2629 self.description = description 2630 self.and_ = and_ 2631 2632 @classmethod 2633 def from_dict(cls, _dict: Dict) -> 'RuleConditionAndLvl2': 2634 """Initialize a RuleConditionAndLvl2 object from a json dictionary.""" 2635 args = {} 2636 if 'description' in _dict: 2637 args['description'] = _dict.get('description') 2638 if 'and' in _dict: 2639 args['and_'] = [RuleSingleProperty.from_dict(x) for x in _dict.get('and')] 2640 else: 2641 raise ValueError('Required property \'and\' not present in RuleConditionAndLvl2 JSON') 2642 return cls(**args) 2643 2644 @classmethod 2645 def _from_dict(cls, _dict): 2646 """Initialize a RuleConditionAndLvl2 object from a json dictionary.""" 2647 return cls.from_dict(_dict) 2648 2649 def to_dict(self) -> Dict: 2650 """Return a json dictionary representing this model.""" 2651 _dict = {} 2652 if hasattr(self, 'description') and self.description is not None: 2653 _dict['description'] = self.description 2654 if hasattr(self, 'and_') and self.and_ is not None: 2655 _dict['and'] = [x.to_dict() for x in self.and_] 2656 return _dict 2657 2658 def _to_dict(self): 2659 """Return a json dictionary representing this model.""" 2660 return self.to_dict() 2661 2662 def __str__(self) -> str: 2663 """Return a `str` version of this RuleConditionAndLvl2 object.""" 2664 return json.dumps(self.to_dict(), indent=2) 2665 2666 def __eq__(self, other: 'RuleConditionAndLvl2') -> bool: 2667 """Return `true` when self and other are equal, false otherwise.""" 2668 if not isinstance(other, self.__class__): 2669 return False 2670 return self.__dict__ == other.__dict__ 2671 2672 def __ne__(self, other: 'RuleConditionAndLvl2') -> bool: 2673 """Return `true` when self and other are not equal, false otherwise.""" 2674 return not self == other 2675 2676class RuleConditionOrLvl2(RuleCondition): 2677 """ 2678 A condition with the `or` logical operator. 2679 2680 :attr str description: (optional) 2681 :attr List[RuleSingleProperty] or_: 2682 """ 2683 2684 def __init__(self, 2685 or_: List['RuleSingleProperty'], 2686 *, 2687 description: str = None) -> None: 2688 """ 2689 Initialize a RuleConditionOrLvl2 object. 2690 2691 :param List[RuleSingleProperty] or_: 2692 :param str description: (optional) 2693 """ 2694 # pylint: disable=super-init-not-called 2695 self.description = description 2696 self.or_ = or_ 2697 2698 @classmethod 2699 def from_dict(cls, _dict: Dict) -> 'RuleConditionOrLvl2': 2700 """Initialize a RuleConditionOrLvl2 object from a json dictionary.""" 2701 args = {} 2702 if 'description' in _dict: 2703 args['description'] = _dict.get('description') 2704 if 'or' in _dict: 2705 args['or_'] = [RuleSingleProperty.from_dict(x) for x in _dict.get('or')] 2706 else: 2707 raise ValueError('Required property \'or\' not present in RuleConditionOrLvl2 JSON') 2708 return cls(**args) 2709 2710 @classmethod 2711 def _from_dict(cls, _dict): 2712 """Initialize a RuleConditionOrLvl2 object from a json dictionary.""" 2713 return cls.from_dict(_dict) 2714 2715 def to_dict(self) -> Dict: 2716 """Return a json dictionary representing this model.""" 2717 _dict = {} 2718 if hasattr(self, 'description') and self.description is not None: 2719 _dict['description'] = self.description 2720 if hasattr(self, 'or_') and self.or_ is not None: 2721 _dict['or'] = [x.to_dict() for x in self.or_] 2722 return _dict 2723 2724 def _to_dict(self): 2725 """Return a json dictionary representing this model.""" 2726 return self.to_dict() 2727 2728 def __str__(self) -> str: 2729 """Return a `str` version of this RuleConditionOrLvl2 object.""" 2730 return json.dumps(self.to_dict(), indent=2) 2731 2732 def __eq__(self, other: 'RuleConditionOrLvl2') -> bool: 2733 """Return `true` when self and other are equal, false otherwise.""" 2734 if not isinstance(other, self.__class__): 2735 return False 2736 return self.__dict__ == other.__dict__ 2737 2738 def __ne__(self, other: 'RuleConditionOrLvl2') -> bool: 2739 """Return `true` when self and other are not equal, false otherwise.""" 2740 return not self == other 2741 2742class RuleConditionSingleProperty(RuleCondition): 2743 """ 2744 The requirement that must be met to determine the resource's level of compliance in 2745 accordance with the rule. 2746 To apply a single property check, define a configuration property and the desired 2747 value that you want to check against. 2748 2749 :attr str description: (optional) 2750 :attr str property: A resource configuration variable that describes the 2751 property that you want to apply to the target resource. 2752 Available options depend on the target service and resource. 2753 :attr str operator: The way in which the `property` field is compared to its 2754 value. 2755 To learn more, see the 2756 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2757 :attr str value: (optional) The way in which you want your property to be 2758 applied. 2759 Value options differ depending on the rule that you configure. If you use a 2760 boolean operator, you do not need to input a value. 2761 """ 2762 2763 def __init__(self, 2764 property: str, 2765 operator: str, 2766 *, 2767 description: str = None, 2768 value: str = None) -> None: 2769 """ 2770 Initialize a RuleConditionSingleProperty object. 2771 2772 :param str property: A resource configuration variable that describes the 2773 property that you want to apply to the target resource. 2774 Available options depend on the target service and resource. 2775 :param str operator: The way in which the `property` field is compared to 2776 its value. 2777 To learn more, see the 2778 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2779 :param str description: (optional) 2780 :param str value: (optional) The way in which you want your property to be 2781 applied. 2782 Value options differ depending on the rule that you configure. If you use a 2783 boolean operator, you do not need to input a value. 2784 """ 2785 # pylint: disable=super-init-not-called 2786 self.description = description 2787 self.property = property 2788 self.operator = operator 2789 self.value = value 2790 2791 @classmethod 2792 def from_dict(cls, _dict: Dict) -> 'RuleConditionSingleProperty': 2793 """Initialize a RuleConditionSingleProperty object from a json dictionary.""" 2794 args = {} 2795 if 'description' in _dict: 2796 args['description'] = _dict.get('description') 2797 if 'property' in _dict: 2798 args['property'] = _dict.get('property') 2799 else: 2800 raise ValueError('Required property \'property\' not present in RuleConditionSingleProperty JSON') 2801 if 'operator' in _dict: 2802 args['operator'] = _dict.get('operator') 2803 else: 2804 raise ValueError('Required property \'operator\' not present in RuleConditionSingleProperty JSON') 2805 if 'value' in _dict: 2806 args['value'] = _dict.get('value') 2807 return cls(**args) 2808 2809 @classmethod 2810 def _from_dict(cls, _dict): 2811 """Initialize a RuleConditionSingleProperty object from a json dictionary.""" 2812 return cls.from_dict(_dict) 2813 2814 def to_dict(self) -> Dict: 2815 """Return a json dictionary representing this model.""" 2816 _dict = {} 2817 if hasattr(self, 'description') and self.description is not None: 2818 _dict['description'] = self.description 2819 if hasattr(self, 'property') and self.property is not None: 2820 _dict['property'] = self.property 2821 if hasattr(self, 'operator') and self.operator is not None: 2822 _dict['operator'] = self.operator 2823 if hasattr(self, 'value') and self.value is not None: 2824 _dict['value'] = self.value 2825 return _dict 2826 2827 def _to_dict(self): 2828 """Return a json dictionary representing this model.""" 2829 return self.to_dict() 2830 2831 def __str__(self) -> str: 2832 """Return a `str` version of this RuleConditionSingleProperty object.""" 2833 return json.dumps(self.to_dict(), indent=2) 2834 2835 def __eq__(self, other: 'RuleConditionSingleProperty') -> bool: 2836 """Return `true` when self and other are equal, false otherwise.""" 2837 if not isinstance(other, self.__class__): 2838 return False 2839 return self.__dict__ == other.__dict__ 2840 2841 def __ne__(self, other: 'RuleConditionSingleProperty') -> bool: 2842 """Return `true` when self and other are not equal, false otherwise.""" 2843 return not self == other 2844 2845 class OperatorEnum(str, Enum): 2846 """ 2847 The way in which the `property` field is compared to its value. 2848 To learn more, see the 2849 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2850 """ 2851 IS_TRUE = 'is_true' 2852 IS_FALSE = 'is_false' 2853 IS_EMPTY = 'is_empty' 2854 IS_NOT_EMPTY = 'is_not_empty' 2855 STRING_EQUALS = 'string_equals' 2856 STRING_NOT_EQUALS = 'string_not_equals' 2857 STRING_MATCH = 'string_match' 2858 STRING_NOT_MATCH = 'string_not_match' 2859 NUM_EQUALS = 'num_equals' 2860 NUM_NOT_EQUALS = 'num_not_equals' 2861 NUM_LESS_THAN = 'num_less_than' 2862 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2863 NUM_GREATER_THAN = 'num_greater_than' 2864 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2865 IPS_IN_RANGE = 'ips_in_range' 2866 STRINGS_IN_LIST = 'strings_in_list' 2867 2868 2869class RuleRequiredConfigMultipleProperties(RuleRequiredConfig): 2870 """ 2871 The requirements that must be met to determine the resource's level of compliance in 2872 accordance with the rule. 2873 Use logical operators (`and`/`or`) to define multiple property checks and conditions. 2874 To define requirements for a rule, list one or more property check objects in the 2875 `and` array. To add conditions to a property check, use `or`. 2876 2877 """ 2878 2879 def __init__(self) -> None: 2880 """ 2881 Initialize a RuleRequiredConfigMultipleProperties object. 2882 2883 """ 2884 # pylint: disable=super-init-not-called 2885 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 2886 ", ".join(['RuleRequiredConfigMultiplePropertiesConditionOr', 'RuleRequiredConfigMultiplePropertiesConditionAnd'])) 2887 raise Exception(msg) 2888 2889class RuleRequiredConfigSingleProperty(RuleRequiredConfig): 2890 """ 2891 The requirement that must be met to determine the resource's level of compliance in 2892 accordance with the rule. 2893 To apply a single property check, define a configuration property and the desired 2894 value that you want to check against. 2895 2896 :attr str description: (optional) 2897 :attr str property: A resource configuration variable that describes the 2898 property that you want to apply to the target resource. 2899 Available options depend on the target service and resource. 2900 :attr str operator: The way in which the `property` field is compared to its 2901 value. 2902 To learn more, see the 2903 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2904 :attr str value: (optional) The way in which you want your property to be 2905 applied. 2906 Value options differ depending on the rule that you configure. If you use a 2907 boolean operator, you do not need to input a value. 2908 """ 2909 2910 def __init__(self, 2911 property: str, 2912 operator: str, 2913 *, 2914 description: str = None, 2915 value: str = None) -> None: 2916 """ 2917 Initialize a RuleRequiredConfigSingleProperty object. 2918 2919 :param str property: A resource configuration variable that describes the 2920 property that you want to apply to the target resource. 2921 Available options depend on the target service and resource. 2922 :param str operator: The way in which the `property` field is compared to 2923 its value. 2924 To learn more, see the 2925 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2926 :param str description: (optional) 2927 :param str value: (optional) The way in which you want your property to be 2928 applied. 2929 Value options differ depending on the rule that you configure. If you use a 2930 boolean operator, you do not need to input a value. 2931 """ 2932 # pylint: disable=super-init-not-called 2933 self.description = description 2934 self.property = property 2935 self.operator = operator 2936 self.value = value 2937 2938 @classmethod 2939 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigSingleProperty': 2940 """Initialize a RuleRequiredConfigSingleProperty object from a json dictionary.""" 2941 args = {} 2942 if 'description' in _dict: 2943 args['description'] = _dict.get('description') 2944 if 'property' in _dict: 2945 args['property'] = _dict.get('property') 2946 else: 2947 raise ValueError('Required property \'property\' not present in RuleRequiredConfigSingleProperty JSON') 2948 if 'operator' in _dict: 2949 args['operator'] = _dict.get('operator') 2950 else: 2951 raise ValueError('Required property \'operator\' not present in RuleRequiredConfigSingleProperty JSON') 2952 if 'value' in _dict: 2953 args['value'] = _dict.get('value') 2954 return cls(**args) 2955 2956 @classmethod 2957 def _from_dict(cls, _dict): 2958 """Initialize a RuleRequiredConfigSingleProperty object from a json dictionary.""" 2959 return cls.from_dict(_dict) 2960 2961 def to_dict(self) -> Dict: 2962 """Return a json dictionary representing this model.""" 2963 _dict = {} 2964 if hasattr(self, 'description') and self.description is not None: 2965 _dict['description'] = self.description 2966 if hasattr(self, 'property') and self.property is not None: 2967 _dict['property'] = self.property 2968 if hasattr(self, 'operator') and self.operator is not None: 2969 _dict['operator'] = self.operator 2970 if hasattr(self, 'value') and self.value is not None: 2971 _dict['value'] = self.value 2972 return _dict 2973 2974 def _to_dict(self): 2975 """Return a json dictionary representing this model.""" 2976 return self.to_dict() 2977 2978 def __str__(self) -> str: 2979 """Return a `str` version of this RuleRequiredConfigSingleProperty object.""" 2980 return json.dumps(self.to_dict(), indent=2) 2981 2982 def __eq__(self, other: 'RuleRequiredConfigSingleProperty') -> bool: 2983 """Return `true` when self and other are equal, false otherwise.""" 2984 if not isinstance(other, self.__class__): 2985 return False 2986 return self.__dict__ == other.__dict__ 2987 2988 def __ne__(self, other: 'RuleRequiredConfigSingleProperty') -> bool: 2989 """Return `true` when self and other are not equal, false otherwise.""" 2990 return not self == other 2991 2992 class OperatorEnum(str, Enum): 2993 """ 2994 The way in which the `property` field is compared to its value. 2995 To learn more, see the 2996 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2997 """ 2998 IS_TRUE = 'is_true' 2999 IS_FALSE = 'is_false' 3000 IS_EMPTY = 'is_empty' 3001 IS_NOT_EMPTY = 'is_not_empty' 3002 STRING_EQUALS = 'string_equals' 3003 STRING_NOT_EQUALS = 'string_not_equals' 3004 STRING_MATCH = 'string_match' 3005 STRING_NOT_MATCH = 'string_not_match' 3006 NUM_EQUALS = 'num_equals' 3007 NUM_NOT_EQUALS = 'num_not_equals' 3008 NUM_LESS_THAN = 'num_less_than' 3009 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 3010 NUM_GREATER_THAN = 'num_greater_than' 3011 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 3012 IPS_IN_RANGE = 'ips_in_range' 3013 STRINGS_IN_LIST = 'strings_in_list' 3014 3015 3016class RuleRequiredConfigMultiplePropertiesConditionAnd(RuleRequiredConfigMultipleProperties): 3017 """ 3018 A condition with the `and` logical operator. 3019 3020 :attr str description: (optional) 3021 :attr List[RuleCondition] and_: 3022 """ 3023 3024 def __init__(self, 3025 and_: List['RuleCondition'], 3026 *, 3027 description: str = None) -> None: 3028 """ 3029 Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object. 3030 3031 :param List[RuleCondition] and_: 3032 :param str description: (optional) 3033 """ 3034 # pylint: disable=super-init-not-called 3035 self.description = description 3036 self.and_ = and_ 3037 3038 @classmethod 3039 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigMultiplePropertiesConditionAnd': 3040 """Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object from a json dictionary.""" 3041 args = {} 3042 if 'description' in _dict: 3043 args['description'] = _dict.get('description') 3044 if 'and' in _dict: 3045 args['and_'] = _dict.get('and') 3046 else: 3047 raise ValueError('Required property \'and\' not present in RuleRequiredConfigMultiplePropertiesConditionAnd JSON') 3048 return cls(**args) 3049 3050 @classmethod 3051 def _from_dict(cls, _dict): 3052 """Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object from a json dictionary.""" 3053 return cls.from_dict(_dict) 3054 3055 def to_dict(self) -> Dict: 3056 """Return a json dictionary representing this model.""" 3057 _dict = {} 3058 if hasattr(self, 'description') and self.description is not None: 3059 _dict['description'] = self.description 3060 if hasattr(self, 'and_') and self.and_ is not None: 3061 and_list = [] 3062 for x in self.and_: 3063 if isinstance(x, dict): 3064 and_list.append(x) 3065 else: 3066 and_list.append(x.to_dict()) 3067 _dict['and'] = and_list 3068 return _dict 3069 3070 def _to_dict(self): 3071 """Return a json dictionary representing this model.""" 3072 return self.to_dict() 3073 3074 def __str__(self) -> str: 3075 """Return a `str` version of this RuleRequiredConfigMultiplePropertiesConditionAnd object.""" 3076 return json.dumps(self.to_dict(), indent=2) 3077 3078 def __eq__(self, other: 'RuleRequiredConfigMultiplePropertiesConditionAnd') -> bool: 3079 """Return `true` when self and other are equal, false otherwise.""" 3080 if not isinstance(other, self.__class__): 3081 return False 3082 return self.__dict__ == other.__dict__ 3083 3084 def __ne__(self, other: 'RuleRequiredConfigMultiplePropertiesConditionAnd') -> bool: 3085 """Return `true` when self and other are not equal, false otherwise.""" 3086 return not self == other 3087 3088class RuleRequiredConfigMultiplePropertiesConditionOr(RuleRequiredConfigMultipleProperties): 3089 """ 3090 A condition with the `or` logical operator. 3091 3092 :attr str description: (optional) 3093 :attr List[RuleCondition] or_: 3094 """ 3095 3096 def __init__(self, 3097 or_: List['RuleCondition'], 3098 *, 3099 description: str = None) -> None: 3100 """ 3101 Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object. 3102 3103 :param List[RuleCondition] or_: 3104 :param str description: (optional) 3105 """ 3106 # pylint: disable=super-init-not-called 3107 self.description = description 3108 self.or_ = or_ 3109 3110 @classmethod 3111 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigMultiplePropertiesConditionOr': 3112 """Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object from a json dictionary.""" 3113 args = {} 3114 if 'description' in _dict: 3115 args['description'] = _dict.get('description') 3116 if 'or' in _dict: 3117 args['or_'] = _dict.get('or') 3118 else: 3119 raise ValueError('Required property \'or\' not present in RuleRequiredConfigMultiplePropertiesConditionOr JSON') 3120 return cls(**args) 3121 3122 @classmethod 3123 def _from_dict(cls, _dict): 3124 """Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object from a json dictionary.""" 3125 return cls.from_dict(_dict) 3126 3127 def to_dict(self) -> Dict: 3128 """Return a json dictionary representing this model.""" 3129 _dict = {} 3130 if hasattr(self, 'description') and self.description is not None: 3131 _dict['description'] = self.description 3132 if hasattr(self, 'or_') and self.or_ is not None: 3133 or_list = [] 3134 for x in self.or_: 3135 if isinstance(x, dict): 3136 or_list.append(x) 3137 else: 3138 or_list.append(x.to_dict()) 3139 _dict['or'] = or_list 3140 return _dict 3141 3142 def _to_dict(self): 3143 """Return a json dictionary representing this model.""" 3144 return self.to_dict() 3145 3146 def __str__(self) -> str: 3147 """Return a `str` version of this RuleRequiredConfigMultiplePropertiesConditionOr object.""" 3148 return json.dumps(self.to_dict(), indent=2) 3149 3150 def __eq__(self, other: 'RuleRequiredConfigMultiplePropertiesConditionOr') -> bool: 3151 """Return `true` when self and other are equal, false otherwise.""" 3152 if not isinstance(other, self.__class__): 3153 return False 3154 return self.__dict__ == other.__dict__ 3155 3156 def __ne__(self, other: 'RuleRequiredConfigMultiplePropertiesConditionOr') -> bool: 3157 """Return `true` when self and other are not equal, false otherwise.""" 3158 return not self == other
40class ConfigurationGovernanceV1(BaseService): 41 """The Configuration Governance V1 service.""" 42 43 DEFAULT_SERVICE_URL = 'https://us.compliance.cloud.ibm.com' 44 DEFAULT_SERVICE_NAME = 'configuration_governance' 45 46 @classmethod 47 def new_instance(cls, 48 service_name: str = DEFAULT_SERVICE_NAME, 49 ) -> 'ConfigurationGovernanceV1': 50 """ 51 Return a new client for the Configuration Governance service using the 52 specified parameters and external configuration. 53 """ 54 authenticator = get_authenticator_from_environment(service_name) 55 service = cls( 56 authenticator 57 ) 58 service.configure_service(service_name) 59 return service 60 61 def __init__(self, 62 authenticator: Authenticator = None, 63 ) -> None: 64 """ 65 Construct a new client for the Configuration Governance service. 66 67 :param Authenticator authenticator: The authenticator specifies the authentication mechanism. 68 Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md 69 about initializing the authenticator of your choice. 70 """ 71 BaseService.__init__(self, 72 service_url=self.DEFAULT_SERVICE_URL, 73 authenticator=authenticator) 74 75 76 ######################### 77 # Rules 78 ######################### 79 80 81 def create_rules(self, 82 rules: List['CreateRuleRequest'], 83 *, 84 transaction_id: str = None, 85 **kwargs 86 ) -> DetailedResponse: 87 """ 88 Create rules. 89 90 Creates one or more rules that you can use to govern the way that IBM Cloud 91 resources can be provisioned and configured. 92 A successful `POST /config/rules` request defines a rule based on the target, 93 conditions, and enforcement actions that you specify. The response returns the ID 94 value for your rule, along with other metadata. 95 To learn more about rules, check out the 96 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule). 97 98 :param List[CreateRuleRequest] rules: A list of rules to be created. 99 :param str transaction_id: (optional) The unique identifier that is used to 100 trace an entire request. If you omit this field, the service generates and 101 sends a transaction ID as a response header of the request. In the case of 102 an error, the transaction ID is set in the `trace` field of the response 103 body. 104 **Note:** To help with debugging logs, it is strongly recommended that you 105 generate and supply a `Transaction-Id` with each request. 106 :param dict headers: A `dict` containing the request headers 107 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 108 :rtype: DetailedResponse with `dict` result representing a `CreateRulesResponse` object 109 """ 110 111 if rules is None: 112 raise ValueError('rules must be provided') 113 rules = [convert_model(x) for x in rules] 114 headers = { 115 'Transaction-Id': transaction_id 116 } 117 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 118 service_version='V1', 119 operation_id='create_rules') 120 headers.update(sdk_headers) 121 122 data = { 123 'rules': rules 124 } 125 data = {k: v for (k, v) in data.items() if v is not None} 126 data = json.dumps(data) 127 headers['content-type'] = 'application/json' 128 129 if 'headers' in kwargs: 130 headers.update(kwargs.get('headers')) 131 headers['Accept'] = 'application/json' 132 133 url = '/config/v1/rules' 134 request = self.prepare_request(method='POST', 135 url=url, 136 headers=headers, 137 data=data) 138 139 response = self.send(request) 140 return response 141 142 143 def list_rules(self, 144 account_id: str, 145 *, 146 transaction_id: str = None, 147 attached: bool = None, 148 labels: str = None, 149 scopes: str = None, 150 limit: int = None, 151 offset: int = None, 152 **kwargs 153 ) -> DetailedResponse: 154 """ 155 List rules. 156 157 Retrieves a list of the rules that are available in your account. 158 159 :param str account_id: Your IBM Cloud account ID. 160 :param str transaction_id: (optional) The unique identifier that is used to 161 trace an entire request. If you omit this field, the service generates and 162 sends a transaction ID as a response header of the request. In the case of 163 an error, the transaction ID is set in the `trace` field of the response 164 body. 165 **Note:** To help with debugging logs, it is strongly recommended that you 166 generate and supply a `Transaction-Id` with each request. 167 :param bool attached: (optional) Retrieves a list of rules that have scope 168 attachments. 169 :param str labels: (optional) Retrieves a list of rules that match the 170 labels that you specify. 171 :param str scopes: (optional) Retrieves a list of rules that match the 172 scope ID that you specify. 173 :param int limit: (optional) The number of resources to retrieve. By 174 default, list operations return the first 100 items. To retrieve a 175 different set of items, use `limit` with `offset` to page through your 176 available resources. 177 **Usage:** If you have 20 rules, and you want to retrieve only the first 5 178 rules, use `../rules?account_id={account_id}&limit=5`. 179 :param int offset: (optional) The number of resources to skip. By 180 specifying `offset`, you retrieve a subset of resources that starts with 181 the `offset` value. Use `offset` with `limit` to page through your 182 available resources. 183 **Usage:** If you have 100 rules, and you want to retrieve rules 26 through 184 50, use `../rules?account_id={account_id}&offset=25&limit=5`. 185 :param dict headers: A `dict` containing the request headers 186 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 187 :rtype: DetailedResponse with `dict` result representing a `RuleList` object 188 """ 189 190 if account_id is None: 191 raise ValueError('account_id must be provided') 192 headers = { 193 'Transaction-Id': transaction_id 194 } 195 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 196 service_version='V1', 197 operation_id='list_rules') 198 headers.update(sdk_headers) 199 200 params = { 201 'account_id': account_id, 202 'attached': attached, 203 'labels': labels, 204 'scopes': scopes, 205 'limit': limit, 206 'offset': offset 207 } 208 209 if 'headers' in kwargs: 210 headers.update(kwargs.get('headers')) 211 headers['Accept'] = 'application/json' 212 213 url = '/config/v1/rules' 214 request = self.prepare_request(method='GET', 215 url=url, 216 headers=headers, 217 params=params) 218 219 response = self.send(request) 220 return response 221 222 223 def get_rule(self, 224 rule_id: str, 225 *, 226 transaction_id: str = None, 227 **kwargs 228 ) -> DetailedResponse: 229 """ 230 Get a rule. 231 232 Retrieves an existing rule and its details. 233 234 :param str rule_id: The UUID that uniquely identifies the rule. 235 :param str transaction_id: (optional) The unique identifier that is used to 236 trace an entire request. If you omit this field, the service generates and 237 sends a transaction ID as a response header of the request. In the case of 238 an error, the transaction ID is set in the `trace` field of the response 239 body. 240 **Note:** To help with debugging logs, it is strongly recommended that you 241 generate and supply a `Transaction-Id` with each request. 242 :param dict headers: A `dict` containing the request headers 243 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 244 :rtype: DetailedResponse with `dict` result representing a `Rule` object 245 """ 246 247 if rule_id is None: 248 raise ValueError('rule_id must be provided') 249 headers = { 250 'Transaction-Id': transaction_id 251 } 252 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 253 service_version='V1', 254 operation_id='get_rule') 255 headers.update(sdk_headers) 256 257 if 'headers' in kwargs: 258 headers.update(kwargs.get('headers')) 259 headers['Accept'] = 'application/json' 260 261 path_param_keys = ['rule_id'] 262 path_param_values = self.encode_path_vars(rule_id) 263 path_param_dict = dict(zip(path_param_keys, path_param_values)) 264 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 265 request = self.prepare_request(method='GET', 266 url=url, 267 headers=headers) 268 269 response = self.send(request) 270 return response 271 272 273 def update_rule(self, 274 rule_id: str, 275 if_match: str, 276 name: str, 277 description: str, 278 target: 'TargetResource', 279 required_config: 'RuleRequiredConfig', 280 enforcement_actions: List['EnforcementAction'], 281 *, 282 account_id: str = None, 283 rule_type: str = None, 284 labels: List[str] = None, 285 transaction_id: str = None, 286 **kwargs 287 ) -> DetailedResponse: 288 """ 289 Update a rule. 290 291 Updates an existing rule based on the properties that you specify. 292 293 :param str rule_id: The UUID that uniquely identifies the rule. 294 :param str if_match: Compares a supplied `Etag` value with the version that 295 is stored for the requested resource. If the values match, the server 296 allows the request method to continue. 297 To find the `Etag` value, run a GET request on the resource that you want 298 to modify, and check the response headers. 299 :param str name: A human-readable alias to assign to your rule. 300 :param str description: An extended description of your rule. 301 :param TargetResource target: The properties that describe the resource 302 that you want to target 303 with the rule or template. 304 :param RuleRequiredConfig required_config: 305 :param List[EnforcementAction] enforcement_actions: The actions that the 306 service must run on your behalf when a request to create or modify the 307 target resource does not comply with your conditions. 308 :param str account_id: (optional) Your IBM Cloud account ID. 309 :param str rule_type: (optional) The type of rule. Rules that you create 310 are `user_defined`. 311 :param List[str] labels: (optional) Labels that you can use to group and 312 search for similar rules, such as those that help you to meet a specific 313 organization guideline. 314 :param str transaction_id: (optional) The unique identifier that is used to 315 trace an entire request. If you omit this field, the service generates and 316 sends a transaction ID as a response header of the request. In the case of 317 an error, the transaction ID is set in the `trace` field of the response 318 body. 319 **Note:** To help with debugging logs, it is strongly recommended that you 320 generate and supply a `Transaction-Id` with each request. 321 :param dict headers: A `dict` containing the request headers 322 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 323 :rtype: DetailedResponse with `dict` result representing a `Rule` object 324 """ 325 326 if rule_id is None: 327 raise ValueError('rule_id must be provided') 328 if if_match is None: 329 raise ValueError('if_match must be provided') 330 if name is None: 331 raise ValueError('name must be provided') 332 if description is None: 333 raise ValueError('description must be provided') 334 if target is None: 335 raise ValueError('target must be provided') 336 if required_config is None: 337 raise ValueError('required_config must be provided') 338 if enforcement_actions is None: 339 raise ValueError('enforcement_actions must be provided') 340 target = convert_model(target) 341 required_config = convert_model(required_config) 342 enforcement_actions = [convert_model(x) for x in enforcement_actions] 343 headers = { 344 'If-Match': if_match, 345 'Transaction-Id': transaction_id 346 } 347 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 348 service_version='V1', 349 operation_id='update_rule') 350 headers.update(sdk_headers) 351 352 data = { 353 'name': name, 354 'description': description, 355 'target': target, 356 'required_config': required_config, 357 'enforcement_actions': enforcement_actions, 358 'account_id': account_id, 359 'rule_type': rule_type, 360 'labels': labels 361 } 362 data = {k: v for (k, v) in data.items() if v is not None} 363 data = json.dumps(data) 364 headers['content-type'] = 'application/json' 365 366 if 'headers' in kwargs: 367 headers.update(kwargs.get('headers')) 368 headers['Accept'] = 'application/json' 369 370 path_param_keys = ['rule_id'] 371 path_param_values = self.encode_path_vars(rule_id) 372 path_param_dict = dict(zip(path_param_keys, path_param_values)) 373 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 374 request = self.prepare_request(method='PUT', 375 url=url, 376 headers=headers, 377 data=data) 378 379 response = self.send(request) 380 return response 381 382 383 def delete_rule(self, 384 rule_id: str, 385 *, 386 transaction_id: str = None, 387 **kwargs 388 ) -> DetailedResponse: 389 """ 390 Delete a rule. 391 392 Deletes an existing rule. 393 394 :param str rule_id: The UUID that uniquely identifies the rule. 395 :param str transaction_id: (optional) The unique identifier that is used to 396 trace an entire request. If you omit this field, the service generates and 397 sends a transaction ID as a response header of the request. In the case of 398 an error, the transaction ID is set in the `trace` field of the response 399 body. 400 **Note:** To help with debugging logs, it is strongly recommended that you 401 generate and supply a `Transaction-Id` with each request. 402 :param dict headers: A `dict` containing the request headers 403 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 404 :rtype: DetailedResponse 405 """ 406 407 if rule_id is None: 408 raise ValueError('rule_id must be provided') 409 headers = { 410 'Transaction-Id': transaction_id 411 } 412 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 413 service_version='V1', 414 operation_id='delete_rule') 415 headers.update(sdk_headers) 416 417 if 'headers' in kwargs: 418 headers.update(kwargs.get('headers')) 419 420 path_param_keys = ['rule_id'] 421 path_param_values = self.encode_path_vars(rule_id) 422 path_param_dict = dict(zip(path_param_keys, path_param_values)) 423 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 424 request = self.prepare_request(method='DELETE', 425 url=url, 426 headers=headers) 427 428 response = self.send(request) 429 return response 430 431 432 def create_rule_attachments(self, 433 rule_id: str, 434 attachments: List['RuleAttachmentRequest'], 435 *, 436 transaction_id: str = None, 437 **kwargs 438 ) -> DetailedResponse: 439 """ 440 Create attachments. 441 442 Creates one or more scope attachments for an existing rule. 443 You can attach an existing rule to a scope, such as a specific IBM Cloud account, 444 to start evaluating the rule for compliance. A successful 445 `POST /config/v1/rules/{rule_id}/attachments` returns the ID value for the 446 attachment, along with other metadata. 447 448 :param str rule_id: The UUID that uniquely identifies the rule. 449 :param List[RuleAttachmentRequest] attachments: 450 :param str transaction_id: (optional) The unique identifier that is used to 451 trace an entire request. If you omit this field, the service generates and 452 sends a transaction ID as a response header of the request. In the case of 453 an error, the transaction ID is set in the `trace` field of the response 454 body. 455 **Note:** To help with debugging logs, it is strongly recommended that you 456 generate and supply a `Transaction-Id` with each request. 457 :param dict headers: A `dict` containing the request headers 458 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 459 :rtype: DetailedResponse with `dict` result representing a `CreateRuleAttachmentsResponse` object 460 """ 461 462 if rule_id is None: 463 raise ValueError('rule_id must be provided') 464 if attachments is None: 465 raise ValueError('attachments must be provided') 466 attachments = [convert_model(x) for x in attachments] 467 headers = { 468 'Transaction-Id': transaction_id 469 } 470 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 471 service_version='V1', 472 operation_id='create_rule_attachments') 473 headers.update(sdk_headers) 474 475 data = { 476 'attachments': attachments 477 } 478 data = {k: v for (k, v) in data.items() if v is not None} 479 data = json.dumps(data) 480 headers['content-type'] = 'application/json' 481 482 if 'headers' in kwargs: 483 headers.update(kwargs.get('headers')) 484 headers['Accept'] = 'application/json' 485 486 path_param_keys = ['rule_id'] 487 path_param_values = self.encode_path_vars(rule_id) 488 path_param_dict = dict(zip(path_param_keys, path_param_values)) 489 url = '/config/v1/rules/{rule_id}/attachments'.format(**path_param_dict) 490 request = self.prepare_request(method='POST', 491 url=url, 492 headers=headers, 493 data=data) 494 495 response = self.send(request) 496 return response 497 498 499 def list_rule_attachments(self, 500 rule_id: str, 501 *, 502 transaction_id: str = None, 503 limit: int = None, 504 offset: int = None, 505 **kwargs 506 ) -> DetailedResponse: 507 """ 508 List attachments. 509 510 Retrieves a list of scope attachments that are associated with the specified rule. 511 512 :param str rule_id: The UUID that uniquely identifies the rule. 513 :param str transaction_id: (optional) The unique identifier that is used to 514 trace an entire request. If you omit this field, the service generates and 515 sends a transaction ID as a response header of the request. In the case of 516 an error, the transaction ID is set in the `trace` field of the response 517 body. 518 **Note:** To help with debugging logs, it is strongly recommended that you 519 generate and supply a `Transaction-Id` with each request. 520 :param int limit: (optional) The number of resources to retrieve. By 521 default, list operations return the first 100 items. To retrieve a 522 different set of items, use `limit` with `offset` to page through your 523 available resources. 524 **Usage:** If you have 20 rules, and you want to retrieve only the first 5 525 rules, use `../rules?account_id={account_id}&limit=5`. 526 :param int offset: (optional) The number of resources to skip. By 527 specifying `offset`, you retrieve a subset of resources that starts with 528 the `offset` value. Use `offset` with `limit` to page through your 529 available resources. 530 **Usage:** If you have 100 rules, and you want to retrieve rules 26 through 531 50, use `../rules?account_id={account_id}&offset=25&limit=5`. 532 :param dict headers: A `dict` containing the request headers 533 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 534 :rtype: DetailedResponse with `dict` result representing a `RuleAttachmentList` object 535 """ 536 537 if rule_id is None: 538 raise ValueError('rule_id must be provided') 539 headers = { 540 'Transaction-Id': transaction_id 541 } 542 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 543 service_version='V1', 544 operation_id='list_rule_attachments') 545 headers.update(sdk_headers) 546 547 params = { 548 'limit': limit, 549 'offset': offset 550 } 551 552 if 'headers' in kwargs: 553 headers.update(kwargs.get('headers')) 554 headers['Accept'] = 'application/json' 555 556 path_param_keys = ['rule_id'] 557 path_param_values = self.encode_path_vars(rule_id) 558 path_param_dict = dict(zip(path_param_keys, path_param_values)) 559 url = '/config/v1/rules/{rule_id}/attachments'.format(**path_param_dict) 560 request = self.prepare_request(method='GET', 561 url=url, 562 headers=headers, 563 params=params) 564 565 response = self.send(request) 566 return response 567 568 569 def get_rule_attachment(self, 570 rule_id: str, 571 attachment_id: str, 572 *, 573 transaction_id: str = None, 574 **kwargs 575 ) -> DetailedResponse: 576 """ 577 Get an attachment. 578 579 Retrieves an existing scope attachment for a rule. 580 581 :param str rule_id: The UUID that uniquely identifies the rule. 582 :param str attachment_id: The UUID that uniquely identifies the attachment. 583 :param str transaction_id: (optional) The unique identifier that is used to 584 trace an entire request. If you omit this field, the service generates and 585 sends a transaction ID as a response header of the request. In the case of 586 an error, the transaction ID is set in the `trace` field of the response 587 body. 588 **Note:** To help with debugging logs, it is strongly recommended that you 589 generate and supply a `Transaction-Id` with each request. 590 :param dict headers: A `dict` containing the request headers 591 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 592 :rtype: DetailedResponse with `dict` result representing a `RuleAttachment` object 593 """ 594 595 if rule_id is None: 596 raise ValueError('rule_id must be provided') 597 if attachment_id is None: 598 raise ValueError('attachment_id must be provided') 599 headers = { 600 'Transaction-Id': transaction_id 601 } 602 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 603 service_version='V1', 604 operation_id='get_rule_attachment') 605 headers.update(sdk_headers) 606 607 if 'headers' in kwargs: 608 headers.update(kwargs.get('headers')) 609 headers['Accept'] = 'application/json' 610 611 path_param_keys = ['rule_id', 'attachment_id'] 612 path_param_values = self.encode_path_vars(rule_id, attachment_id) 613 path_param_dict = dict(zip(path_param_keys, path_param_values)) 614 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 615 request = self.prepare_request(method='GET', 616 url=url, 617 headers=headers) 618 619 response = self.send(request) 620 return response 621 622 623 def update_rule_attachment(self, 624 rule_id: str, 625 attachment_id: str, 626 if_match: str, 627 account_id: str, 628 included_scope: 'RuleScope', 629 *, 630 excluded_scopes: List['RuleScope'] = None, 631 transaction_id: str = None, 632 **kwargs 633 ) -> DetailedResponse: 634 """ 635 Update an attachment. 636 637 Updates an existing scope attachment based on the properties that you specify. 638 639 :param str rule_id: The UUID that uniquely identifies the rule. 640 :param str attachment_id: The UUID that uniquely identifies the attachment. 641 :param str if_match: Compares a supplied `Etag` value with the version that 642 is stored for the requested resource. If the values match, the server 643 allows the request method to continue. 644 To find the `Etag` value, run a GET request on the resource that you want 645 to modify, and check the response headers. 646 :param str account_id: Your IBM Cloud account ID. 647 :param RuleScope included_scope: The extent at which the rule can be 648 attached across your accounts. 649 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 650 rule can be excluded from the included scope. 651 :param str transaction_id: (optional) The unique identifier that is used to 652 trace an entire request. If you omit this field, the service generates and 653 sends a transaction ID as a response header of the request. In the case of 654 an error, the transaction ID is set in the `trace` field of the response 655 body. 656 **Note:** To help with debugging logs, it is strongly recommended that you 657 generate and supply a `Transaction-Id` with each request. 658 :param dict headers: A `dict` containing the request headers 659 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 660 :rtype: DetailedResponse with `dict` result representing a `TemplateAttachment` object 661 """ 662 663 if rule_id is None: 664 raise ValueError('rule_id must be provided') 665 if attachment_id is None: 666 raise ValueError('attachment_id must be provided') 667 if if_match is None: 668 raise ValueError('if_match must be provided') 669 if account_id is None: 670 raise ValueError('account_id must be provided') 671 if included_scope is None: 672 raise ValueError('included_scope must be provided') 673 included_scope = convert_model(included_scope) 674 if excluded_scopes is not None: 675 excluded_scopes = [convert_model(x) for x in excluded_scopes] 676 headers = { 677 'If-Match': if_match, 678 'Transaction-Id': transaction_id 679 } 680 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 681 service_version='V1', 682 operation_id='update_rule_attachment') 683 headers.update(sdk_headers) 684 685 data = { 686 'account_id': account_id, 687 'included_scope': included_scope, 688 'excluded_scopes': excluded_scopes 689 } 690 data = {k: v for (k, v) in data.items() if v is not None} 691 data = json.dumps(data) 692 headers['content-type'] = 'application/json' 693 694 if 'headers' in kwargs: 695 headers.update(kwargs.get('headers')) 696 headers['Accept'] = 'application/json' 697 698 path_param_keys = ['rule_id', 'attachment_id'] 699 path_param_values = self.encode_path_vars(rule_id, attachment_id) 700 path_param_dict = dict(zip(path_param_keys, path_param_values)) 701 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 702 request = self.prepare_request(method='PUT', 703 url=url, 704 headers=headers, 705 data=data) 706 707 response = self.send(request) 708 return response 709 710 711 def delete_rule_attachment(self, 712 rule_id: str, 713 attachment_id: str, 714 *, 715 transaction_id: str = None, 716 **kwargs 717 ) -> DetailedResponse: 718 """ 719 Delete an attachment. 720 721 Deletes an existing scope attachment. 722 723 :param str rule_id: The UUID that uniquely identifies the rule. 724 :param str attachment_id: The UUID that uniquely identifies the attachment. 725 :param str transaction_id: (optional) The unique identifier that is used to 726 trace an entire request. If you omit this field, the service generates and 727 sends a transaction ID as a response header of the request. In the case of 728 an error, the transaction ID is set in the `trace` field of the response 729 body. 730 **Note:** To help with debugging logs, it is strongly recommended that you 731 generate and supply a `Transaction-Id` with each request. 732 :param dict headers: A `dict` containing the request headers 733 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 734 :rtype: DetailedResponse 735 """ 736 737 if rule_id is None: 738 raise ValueError('rule_id must be provided') 739 if attachment_id is None: 740 raise ValueError('attachment_id must be provided') 741 headers = { 742 'Transaction-Id': transaction_id 743 } 744 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 745 service_version='V1', 746 operation_id='delete_rule_attachment') 747 headers.update(sdk_headers) 748 749 if 'headers' in kwargs: 750 headers.update(kwargs.get('headers')) 751 752 path_param_keys = ['rule_id', 'attachment_id'] 753 path_param_values = self.encode_path_vars(rule_id, attachment_id) 754 path_param_dict = dict(zip(path_param_keys, path_param_values)) 755 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 756 request = self.prepare_request(method='DELETE', 757 url=url, 758 headers=headers) 759 760 response = self.send(request) 761 return response
The Configuration Governance V1 service.
61 def __init__(self, 62 authenticator: Authenticator = None, 63 ) -> None: 64 """ 65 Construct a new client for the Configuration Governance service. 66 67 :param Authenticator authenticator: The authenticator specifies the authentication mechanism. 68 Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md 69 about initializing the authenticator of your choice. 70 """ 71 BaseService.__init__(self, 72 service_url=self.DEFAULT_SERVICE_URL, 73 authenticator=authenticator)
Construct a new client for the Configuration Governance service.
Parameters
- Authenticator authenticator: The authenticator specifies the authentication mechanism. Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice.
46 @classmethod 47 def new_instance(cls, 48 service_name: str = DEFAULT_SERVICE_NAME, 49 ) -> 'ConfigurationGovernanceV1': 50 """ 51 Return a new client for the Configuration Governance service using the 52 specified parameters and external configuration. 53 """ 54 authenticator = get_authenticator_from_environment(service_name) 55 service = cls( 56 authenticator 57 ) 58 service.configure_service(service_name) 59 return service
Return a new client for the Configuration Governance service using the specified parameters and external configuration.
81 def create_rules(self, 82 rules: List['CreateRuleRequest'], 83 *, 84 transaction_id: str = None, 85 **kwargs 86 ) -> DetailedResponse: 87 """ 88 Create rules. 89 90 Creates one or more rules that you can use to govern the way that IBM Cloud 91 resources can be provisioned and configured. 92 A successful `POST /config/rules` request defines a rule based on the target, 93 conditions, and enforcement actions that you specify. The response returns the ID 94 value for your rule, along with other metadata. 95 To learn more about rules, check out the 96 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule). 97 98 :param List[CreateRuleRequest] rules: A list of rules to be created. 99 :param str transaction_id: (optional) The unique identifier that is used to 100 trace an entire request. If you omit this field, the service generates and 101 sends a transaction ID as a response header of the request. In the case of 102 an error, the transaction ID is set in the `trace` field of the response 103 body. 104 **Note:** To help with debugging logs, it is strongly recommended that you 105 generate and supply a `Transaction-Id` with each request. 106 :param dict headers: A `dict` containing the request headers 107 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 108 :rtype: DetailedResponse with `dict` result representing a `CreateRulesResponse` object 109 """ 110 111 if rules is None: 112 raise ValueError('rules must be provided') 113 rules = [convert_model(x) for x in rules] 114 headers = { 115 'Transaction-Id': transaction_id 116 } 117 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 118 service_version='V1', 119 operation_id='create_rules') 120 headers.update(sdk_headers) 121 122 data = { 123 'rules': rules 124 } 125 data = {k: v for (k, v) in data.items() if v is not None} 126 data = json.dumps(data) 127 headers['content-type'] = 'application/json' 128 129 if 'headers' in kwargs: 130 headers.update(kwargs.get('headers')) 131 headers['Accept'] = 'application/json' 132 133 url = '/config/v1/rules' 134 request = self.prepare_request(method='POST', 135 url=url, 136 headers=headers, 137 data=data) 138 139 response = self.send(request) 140 return response
Create rules.
Creates one or more rules that you can use to govern the way that IBM Cloud
resources can be provisioned and configured.
A successful POST /config/rules request defines a rule based on the target,
conditions, and enforcement actions that you specify. The response returns the ID
value for your rule, along with other metadata.
To learn more about rules, check out the
docs.
Parameters
- List[CreateRuleRequest] rules: A list of rules to be created.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
143 def list_rules(self, 144 account_id: str, 145 *, 146 transaction_id: str = None, 147 attached: bool = None, 148 labels: str = None, 149 scopes: str = None, 150 limit: int = None, 151 offset: int = None, 152 **kwargs 153 ) -> DetailedResponse: 154 """ 155 List rules. 156 157 Retrieves a list of the rules that are available in your account. 158 159 :param str account_id: Your IBM Cloud account ID. 160 :param str transaction_id: (optional) The unique identifier that is used to 161 trace an entire request. If you omit this field, the service generates and 162 sends a transaction ID as a response header of the request. In the case of 163 an error, the transaction ID is set in the `trace` field of the response 164 body. 165 **Note:** To help with debugging logs, it is strongly recommended that you 166 generate and supply a `Transaction-Id` with each request. 167 :param bool attached: (optional) Retrieves a list of rules that have scope 168 attachments. 169 :param str labels: (optional) Retrieves a list of rules that match the 170 labels that you specify. 171 :param str scopes: (optional) Retrieves a list of rules that match the 172 scope ID that you specify. 173 :param int limit: (optional) The number of resources to retrieve. By 174 default, list operations return the first 100 items. To retrieve a 175 different set of items, use `limit` with `offset` to page through your 176 available resources. 177 **Usage:** If you have 20 rules, and you want to retrieve only the first 5 178 rules, use `../rules?account_id={account_id}&limit=5`. 179 :param int offset: (optional) The number of resources to skip. By 180 specifying `offset`, you retrieve a subset of resources that starts with 181 the `offset` value. Use `offset` with `limit` to page through your 182 available resources. 183 **Usage:** If you have 100 rules, and you want to retrieve rules 26 through 184 50, use `../rules?account_id={account_id}&offset=25&limit=5`. 185 :param dict headers: A `dict` containing the request headers 186 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 187 :rtype: DetailedResponse with `dict` result representing a `RuleList` object 188 """ 189 190 if account_id is None: 191 raise ValueError('account_id must be provided') 192 headers = { 193 'Transaction-Id': transaction_id 194 } 195 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 196 service_version='V1', 197 operation_id='list_rules') 198 headers.update(sdk_headers) 199 200 params = { 201 'account_id': account_id, 202 'attached': attached, 203 'labels': labels, 204 'scopes': scopes, 205 'limit': limit, 206 'offset': offset 207 } 208 209 if 'headers' in kwargs: 210 headers.update(kwargs.get('headers')) 211 headers['Accept'] = 'application/json' 212 213 url = '/config/v1/rules' 214 request = self.prepare_request(method='GET', 215 url=url, 216 headers=headers, 217 params=params) 218 219 response = self.send(request) 220 return response
List rules.
Retrieves a list of the rules that are available in your account.
Parameters
- str account_id: Your IBM Cloud account ID.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - bool attached: (optional) Retrieves a list of rules that have scope attachments.
- str labels: (optional) Retrieves a list of rules that match the labels that you specify.
- str scopes: (optional) Retrieves a list of rules that match the scope ID that you specify.
- int limit: (optional) The number of resources to retrieve. By
default, list operations return the first 100 items. To retrieve a
different set of items, use
limitwithoffsetto page through your available resources. Usage: If you have 20 rules, and you want to retrieve only the first 5 rules, use../rules?account_id={account_id}&limit=5. - int offset: (optional) The number of resources to skip. By
specifying
offset, you retrieve a subset of resources that starts with theoffsetvalue. Useoffsetwithlimitto page through your available resources. Usage: If you have 100 rules, and you want to retrieve rules 26 through 50, use../rules?account_id={account_id}&offset=25&limit=5. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
223 def get_rule(self, 224 rule_id: str, 225 *, 226 transaction_id: str = None, 227 **kwargs 228 ) -> DetailedResponse: 229 """ 230 Get a rule. 231 232 Retrieves an existing rule and its details. 233 234 :param str rule_id: The UUID that uniquely identifies the rule. 235 :param str transaction_id: (optional) The unique identifier that is used to 236 trace an entire request. If you omit this field, the service generates and 237 sends a transaction ID as a response header of the request. In the case of 238 an error, the transaction ID is set in the `trace` field of the response 239 body. 240 **Note:** To help with debugging logs, it is strongly recommended that you 241 generate and supply a `Transaction-Id` with each request. 242 :param dict headers: A `dict` containing the request headers 243 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 244 :rtype: DetailedResponse with `dict` result representing a `Rule` object 245 """ 246 247 if rule_id is None: 248 raise ValueError('rule_id must be provided') 249 headers = { 250 'Transaction-Id': transaction_id 251 } 252 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 253 service_version='V1', 254 operation_id='get_rule') 255 headers.update(sdk_headers) 256 257 if 'headers' in kwargs: 258 headers.update(kwargs.get('headers')) 259 headers['Accept'] = 'application/json' 260 261 path_param_keys = ['rule_id'] 262 path_param_values = self.encode_path_vars(rule_id) 263 path_param_dict = dict(zip(path_param_keys, path_param_values)) 264 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 265 request = self.prepare_request(method='GET', 266 url=url, 267 headers=headers) 268 269 response = self.send(request) 270 return response
Get a rule.
Retrieves an existing rule and its details.
Parameters
- str rule_id: The UUID that uniquely identifies the rule.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
273 def update_rule(self, 274 rule_id: str, 275 if_match: str, 276 name: str, 277 description: str, 278 target: 'TargetResource', 279 required_config: 'RuleRequiredConfig', 280 enforcement_actions: List['EnforcementAction'], 281 *, 282 account_id: str = None, 283 rule_type: str = None, 284 labels: List[str] = None, 285 transaction_id: str = None, 286 **kwargs 287 ) -> DetailedResponse: 288 """ 289 Update a rule. 290 291 Updates an existing rule based on the properties that you specify. 292 293 :param str rule_id: The UUID that uniquely identifies the rule. 294 :param str if_match: Compares a supplied `Etag` value with the version that 295 is stored for the requested resource. If the values match, the server 296 allows the request method to continue. 297 To find the `Etag` value, run a GET request on the resource that you want 298 to modify, and check the response headers. 299 :param str name: A human-readable alias to assign to your rule. 300 :param str description: An extended description of your rule. 301 :param TargetResource target: The properties that describe the resource 302 that you want to target 303 with the rule or template. 304 :param RuleRequiredConfig required_config: 305 :param List[EnforcementAction] enforcement_actions: The actions that the 306 service must run on your behalf when a request to create or modify the 307 target resource does not comply with your conditions. 308 :param str account_id: (optional) Your IBM Cloud account ID. 309 :param str rule_type: (optional) The type of rule. Rules that you create 310 are `user_defined`. 311 :param List[str] labels: (optional) Labels that you can use to group and 312 search for similar rules, such as those that help you to meet a specific 313 organization guideline. 314 :param str transaction_id: (optional) The unique identifier that is used to 315 trace an entire request. If you omit this field, the service generates and 316 sends a transaction ID as a response header of the request. In the case of 317 an error, the transaction ID is set in the `trace` field of the response 318 body. 319 **Note:** To help with debugging logs, it is strongly recommended that you 320 generate and supply a `Transaction-Id` with each request. 321 :param dict headers: A `dict` containing the request headers 322 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 323 :rtype: DetailedResponse with `dict` result representing a `Rule` object 324 """ 325 326 if rule_id is None: 327 raise ValueError('rule_id must be provided') 328 if if_match is None: 329 raise ValueError('if_match must be provided') 330 if name is None: 331 raise ValueError('name must be provided') 332 if description is None: 333 raise ValueError('description must be provided') 334 if target is None: 335 raise ValueError('target must be provided') 336 if required_config is None: 337 raise ValueError('required_config must be provided') 338 if enforcement_actions is None: 339 raise ValueError('enforcement_actions must be provided') 340 target = convert_model(target) 341 required_config = convert_model(required_config) 342 enforcement_actions = [convert_model(x) for x in enforcement_actions] 343 headers = { 344 'If-Match': if_match, 345 'Transaction-Id': transaction_id 346 } 347 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 348 service_version='V1', 349 operation_id='update_rule') 350 headers.update(sdk_headers) 351 352 data = { 353 'name': name, 354 'description': description, 355 'target': target, 356 'required_config': required_config, 357 'enforcement_actions': enforcement_actions, 358 'account_id': account_id, 359 'rule_type': rule_type, 360 'labels': labels 361 } 362 data = {k: v for (k, v) in data.items() if v is not None} 363 data = json.dumps(data) 364 headers['content-type'] = 'application/json' 365 366 if 'headers' in kwargs: 367 headers.update(kwargs.get('headers')) 368 headers['Accept'] = 'application/json' 369 370 path_param_keys = ['rule_id'] 371 path_param_values = self.encode_path_vars(rule_id) 372 path_param_dict = dict(zip(path_param_keys, path_param_values)) 373 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 374 request = self.prepare_request(method='PUT', 375 url=url, 376 headers=headers, 377 data=data) 378 379 response = self.send(request) 380 return response
Update a rule.
Updates an existing rule based on the properties that you specify.
Parameters
- str rule_id: The UUID that uniquely identifies the rule.
- str if_match: Compares a supplied
Etagvalue with the version that is stored for the requested resource. If the values match, the server allows the request method to continue. To find theEtagvalue, run a GET request on the resource that you want to modify, and check the response headers. - str name: A human-readable alias to assign to your rule.
- str description: An extended description of your rule.
- TargetResource target: The properties that describe the resource that you want to target with the rule or template.
- RuleRequiredConfig required_config:
- List[EnforcementAction] enforcement_actions: The actions that the service must run on your behalf when a request to create or modify the target resource does not comply with your conditions.
- str account_id: (optional) Your IBM Cloud account ID.
- str rule_type: (optional) The type of rule. Rules that you create
are
user_defined. - List[str] labels: (optional) Labels that you can use to group and search for similar rules, such as those that help you to meet a specific organization guideline.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
383 def delete_rule(self, 384 rule_id: str, 385 *, 386 transaction_id: str = None, 387 **kwargs 388 ) -> DetailedResponse: 389 """ 390 Delete a rule. 391 392 Deletes an existing rule. 393 394 :param str rule_id: The UUID that uniquely identifies the rule. 395 :param str transaction_id: (optional) The unique identifier that is used to 396 trace an entire request. If you omit this field, the service generates and 397 sends a transaction ID as a response header of the request. In the case of 398 an error, the transaction ID is set in the `trace` field of the response 399 body. 400 **Note:** To help with debugging logs, it is strongly recommended that you 401 generate and supply a `Transaction-Id` with each request. 402 :param dict headers: A `dict` containing the request headers 403 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 404 :rtype: DetailedResponse 405 """ 406 407 if rule_id is None: 408 raise ValueError('rule_id must be provided') 409 headers = { 410 'Transaction-Id': transaction_id 411 } 412 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 413 service_version='V1', 414 operation_id='delete_rule') 415 headers.update(sdk_headers) 416 417 if 'headers' in kwargs: 418 headers.update(kwargs.get('headers')) 419 420 path_param_keys = ['rule_id'] 421 path_param_values = self.encode_path_vars(rule_id) 422 path_param_dict = dict(zip(path_param_keys, path_param_values)) 423 url = '/config/v1/rules/{rule_id}'.format(**path_param_dict) 424 request = self.prepare_request(method='DELETE', 425 url=url, 426 headers=headers) 427 428 response = self.send(request) 429 return response
Delete a rule.
Deletes an existing rule.
Parameters
- str rule_id: The UUID that uniquely identifies the rule.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
432 def create_rule_attachments(self, 433 rule_id: str, 434 attachments: List['RuleAttachmentRequest'], 435 *, 436 transaction_id: str = None, 437 **kwargs 438 ) -> DetailedResponse: 439 """ 440 Create attachments. 441 442 Creates one or more scope attachments for an existing rule. 443 You can attach an existing rule to a scope, such as a specific IBM Cloud account, 444 to start evaluating the rule for compliance. A successful 445 `POST /config/v1/rules/{rule_id}/attachments` returns the ID value for the 446 attachment, along with other metadata. 447 448 :param str rule_id: The UUID that uniquely identifies the rule. 449 :param List[RuleAttachmentRequest] attachments: 450 :param str transaction_id: (optional) The unique identifier that is used to 451 trace an entire request. If you omit this field, the service generates and 452 sends a transaction ID as a response header of the request. In the case of 453 an error, the transaction ID is set in the `trace` field of the response 454 body. 455 **Note:** To help with debugging logs, it is strongly recommended that you 456 generate and supply a `Transaction-Id` with each request. 457 :param dict headers: A `dict` containing the request headers 458 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 459 :rtype: DetailedResponse with `dict` result representing a `CreateRuleAttachmentsResponse` object 460 """ 461 462 if rule_id is None: 463 raise ValueError('rule_id must be provided') 464 if attachments is None: 465 raise ValueError('attachments must be provided') 466 attachments = [convert_model(x) for x in attachments] 467 headers = { 468 'Transaction-Id': transaction_id 469 } 470 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 471 service_version='V1', 472 operation_id='create_rule_attachments') 473 headers.update(sdk_headers) 474 475 data = { 476 'attachments': attachments 477 } 478 data = {k: v for (k, v) in data.items() if v is not None} 479 data = json.dumps(data) 480 headers['content-type'] = 'application/json' 481 482 if 'headers' in kwargs: 483 headers.update(kwargs.get('headers')) 484 headers['Accept'] = 'application/json' 485 486 path_param_keys = ['rule_id'] 487 path_param_values = self.encode_path_vars(rule_id) 488 path_param_dict = dict(zip(path_param_keys, path_param_values)) 489 url = '/config/v1/rules/{rule_id}/attachments'.format(**path_param_dict) 490 request = self.prepare_request(method='POST', 491 url=url, 492 headers=headers, 493 data=data) 494 495 response = self.send(request) 496 return response
Create attachments.
Creates one or more scope attachments for an existing rule.
You can attach an existing rule to a scope, such as a specific IBM Cloud account,
to start evaluating the rule for compliance. A successful
POST /config/v1/rules/{rule_id}/attachments returns the ID value for the
attachment, along with other metadata.
Parameters
- str rule_id: The UUID that uniquely identifies the rule.
- List[RuleAttachmentRequest] attachments:
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
499 def list_rule_attachments(self, 500 rule_id: str, 501 *, 502 transaction_id: str = None, 503 limit: int = None, 504 offset: int = None, 505 **kwargs 506 ) -> DetailedResponse: 507 """ 508 List attachments. 509 510 Retrieves a list of scope attachments that are associated with the specified rule. 511 512 :param str rule_id: The UUID that uniquely identifies the rule. 513 :param str transaction_id: (optional) The unique identifier that is used to 514 trace an entire request. If you omit this field, the service generates and 515 sends a transaction ID as a response header of the request. In the case of 516 an error, the transaction ID is set in the `trace` field of the response 517 body. 518 **Note:** To help with debugging logs, it is strongly recommended that you 519 generate and supply a `Transaction-Id` with each request. 520 :param int limit: (optional) The number of resources to retrieve. By 521 default, list operations return the first 100 items. To retrieve a 522 different set of items, use `limit` with `offset` to page through your 523 available resources. 524 **Usage:** If you have 20 rules, and you want to retrieve only the first 5 525 rules, use `../rules?account_id={account_id}&limit=5`. 526 :param int offset: (optional) The number of resources to skip. By 527 specifying `offset`, you retrieve a subset of resources that starts with 528 the `offset` value. Use `offset` with `limit` to page through your 529 available resources. 530 **Usage:** If you have 100 rules, and you want to retrieve rules 26 through 531 50, use `../rules?account_id={account_id}&offset=25&limit=5`. 532 :param dict headers: A `dict` containing the request headers 533 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 534 :rtype: DetailedResponse with `dict` result representing a `RuleAttachmentList` object 535 """ 536 537 if rule_id is None: 538 raise ValueError('rule_id must be provided') 539 headers = { 540 'Transaction-Id': transaction_id 541 } 542 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 543 service_version='V1', 544 operation_id='list_rule_attachments') 545 headers.update(sdk_headers) 546 547 params = { 548 'limit': limit, 549 'offset': offset 550 } 551 552 if 'headers' in kwargs: 553 headers.update(kwargs.get('headers')) 554 headers['Accept'] = 'application/json' 555 556 path_param_keys = ['rule_id'] 557 path_param_values = self.encode_path_vars(rule_id) 558 path_param_dict = dict(zip(path_param_keys, path_param_values)) 559 url = '/config/v1/rules/{rule_id}/attachments'.format(**path_param_dict) 560 request = self.prepare_request(method='GET', 561 url=url, 562 headers=headers, 563 params=params) 564 565 response = self.send(request) 566 return response
List attachments.
Retrieves a list of scope attachments that are associated with the specified rule.
Parameters
- str rule_id: The UUID that uniquely identifies the rule.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - int limit: (optional) The number of resources to retrieve. By
default, list operations return the first 100 items. To retrieve a
different set of items, use
limitwithoffsetto page through your available resources. Usage: If you have 20 rules, and you want to retrieve only the first 5 rules, use../rules?account_id={account_id}&limit=5. - int offset: (optional) The number of resources to skip. By
specifying
offset, you retrieve a subset of resources that starts with theoffsetvalue. Useoffsetwithlimitto page through your available resources. Usage: If you have 100 rules, and you want to retrieve rules 26 through 50, use../rules?account_id={account_id}&offset=25&limit=5. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
569 def get_rule_attachment(self, 570 rule_id: str, 571 attachment_id: str, 572 *, 573 transaction_id: str = None, 574 **kwargs 575 ) -> DetailedResponse: 576 """ 577 Get an attachment. 578 579 Retrieves an existing scope attachment for a rule. 580 581 :param str rule_id: The UUID that uniquely identifies the rule. 582 :param str attachment_id: The UUID that uniquely identifies the attachment. 583 :param str transaction_id: (optional) The unique identifier that is used to 584 trace an entire request. If you omit this field, the service generates and 585 sends a transaction ID as a response header of the request. In the case of 586 an error, the transaction ID is set in the `trace` field of the response 587 body. 588 **Note:** To help with debugging logs, it is strongly recommended that you 589 generate and supply a `Transaction-Id` with each request. 590 :param dict headers: A `dict` containing the request headers 591 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 592 :rtype: DetailedResponse with `dict` result representing a `RuleAttachment` object 593 """ 594 595 if rule_id is None: 596 raise ValueError('rule_id must be provided') 597 if attachment_id is None: 598 raise ValueError('attachment_id must be provided') 599 headers = { 600 'Transaction-Id': transaction_id 601 } 602 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 603 service_version='V1', 604 operation_id='get_rule_attachment') 605 headers.update(sdk_headers) 606 607 if 'headers' in kwargs: 608 headers.update(kwargs.get('headers')) 609 headers['Accept'] = 'application/json' 610 611 path_param_keys = ['rule_id', 'attachment_id'] 612 path_param_values = self.encode_path_vars(rule_id, attachment_id) 613 path_param_dict = dict(zip(path_param_keys, path_param_values)) 614 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 615 request = self.prepare_request(method='GET', 616 url=url, 617 headers=headers) 618 619 response = self.send(request) 620 return response
Get an attachment.
Retrieves an existing scope attachment for a rule.
Parameters
- str rule_id: The UUID that uniquely identifies the rule.
- str attachment_id: The UUID that uniquely identifies the attachment.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
623 def update_rule_attachment(self, 624 rule_id: str, 625 attachment_id: str, 626 if_match: str, 627 account_id: str, 628 included_scope: 'RuleScope', 629 *, 630 excluded_scopes: List['RuleScope'] = None, 631 transaction_id: str = None, 632 **kwargs 633 ) -> DetailedResponse: 634 """ 635 Update an attachment. 636 637 Updates an existing scope attachment based on the properties that you specify. 638 639 :param str rule_id: The UUID that uniquely identifies the rule. 640 :param str attachment_id: The UUID that uniquely identifies the attachment. 641 :param str if_match: Compares a supplied `Etag` value with the version that 642 is stored for the requested resource. If the values match, the server 643 allows the request method to continue. 644 To find the `Etag` value, run a GET request on the resource that you want 645 to modify, and check the response headers. 646 :param str account_id: Your IBM Cloud account ID. 647 :param RuleScope included_scope: The extent at which the rule can be 648 attached across your accounts. 649 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 650 rule can be excluded from the included scope. 651 :param str transaction_id: (optional) The unique identifier that is used to 652 trace an entire request. If you omit this field, the service generates and 653 sends a transaction ID as a response header of the request. In the case of 654 an error, the transaction ID is set in the `trace` field of the response 655 body. 656 **Note:** To help with debugging logs, it is strongly recommended that you 657 generate and supply a `Transaction-Id` with each request. 658 :param dict headers: A `dict` containing the request headers 659 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 660 :rtype: DetailedResponse with `dict` result representing a `TemplateAttachment` object 661 """ 662 663 if rule_id is None: 664 raise ValueError('rule_id must be provided') 665 if attachment_id is None: 666 raise ValueError('attachment_id must be provided') 667 if if_match is None: 668 raise ValueError('if_match must be provided') 669 if account_id is None: 670 raise ValueError('account_id must be provided') 671 if included_scope is None: 672 raise ValueError('included_scope must be provided') 673 included_scope = convert_model(included_scope) 674 if excluded_scopes is not None: 675 excluded_scopes = [convert_model(x) for x in excluded_scopes] 676 headers = { 677 'If-Match': if_match, 678 'Transaction-Id': transaction_id 679 } 680 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 681 service_version='V1', 682 operation_id='update_rule_attachment') 683 headers.update(sdk_headers) 684 685 data = { 686 'account_id': account_id, 687 'included_scope': included_scope, 688 'excluded_scopes': excluded_scopes 689 } 690 data = {k: v for (k, v) in data.items() if v is not None} 691 data = json.dumps(data) 692 headers['content-type'] = 'application/json' 693 694 if 'headers' in kwargs: 695 headers.update(kwargs.get('headers')) 696 headers['Accept'] = 'application/json' 697 698 path_param_keys = ['rule_id', 'attachment_id'] 699 path_param_values = self.encode_path_vars(rule_id, attachment_id) 700 path_param_dict = dict(zip(path_param_keys, path_param_values)) 701 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 702 request = self.prepare_request(method='PUT', 703 url=url, 704 headers=headers, 705 data=data) 706 707 response = self.send(request) 708 return response
Update an attachment.
Updates an existing scope attachment based on the properties that you specify.
Parameters
- str rule_id: The UUID that uniquely identifies the rule.
- str attachment_id: The UUID that uniquely identifies the attachment.
- str if_match: Compares a supplied
Etagvalue with the version that is stored for the requested resource. If the values match, the server allows the request method to continue. To find theEtagvalue, run a GET request on the resource that you want to modify, and check the response headers. - str account_id: Your IBM Cloud account ID.
- RuleScope included_scope: The extent at which the rule can be attached across your accounts.
- List[RuleScope] excluded_scopes: (optional) The extent at which the rule can be excluded from the included scope.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
711 def delete_rule_attachment(self, 712 rule_id: str, 713 attachment_id: str, 714 *, 715 transaction_id: str = None, 716 **kwargs 717 ) -> DetailedResponse: 718 """ 719 Delete an attachment. 720 721 Deletes an existing scope attachment. 722 723 :param str rule_id: The UUID that uniquely identifies the rule. 724 :param str attachment_id: The UUID that uniquely identifies the attachment. 725 :param str transaction_id: (optional) The unique identifier that is used to 726 trace an entire request. If you omit this field, the service generates and 727 sends a transaction ID as a response header of the request. In the case of 728 an error, the transaction ID is set in the `trace` field of the response 729 body. 730 **Note:** To help with debugging logs, it is strongly recommended that you 731 generate and supply a `Transaction-Id` with each request. 732 :param dict headers: A `dict` containing the request headers 733 :return: A `DetailedResponse` containing the result, headers and HTTP status code. 734 :rtype: DetailedResponse 735 """ 736 737 if rule_id is None: 738 raise ValueError('rule_id must be provided') 739 if attachment_id is None: 740 raise ValueError('attachment_id must be provided') 741 headers = { 742 'Transaction-Id': transaction_id 743 } 744 sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, 745 service_version='V1', 746 operation_id='delete_rule_attachment') 747 headers.update(sdk_headers) 748 749 if 'headers' in kwargs: 750 headers.update(kwargs.get('headers')) 751 752 path_param_keys = ['rule_id', 'attachment_id'] 753 path_param_values = self.encode_path_vars(rule_id, attachment_id) 754 path_param_dict = dict(zip(path_param_keys, path_param_values)) 755 url = '/config/v1/rules/{rule_id}/attachments/{attachment_id}'.format(**path_param_dict) 756 request = self.prepare_request(method='DELETE', 757 url=url, 758 headers=headers) 759 760 response = self.send(request) 761 return response
Delete an attachment.
Deletes an existing scope attachment.
Parameters
- str rule_id: The UUID that uniquely identifies the rule.
- str attachment_id: The UUID that uniquely identifies the attachment.
- str transaction_id: (optional) The unique identifier that is used to
trace an entire request. If you omit this field, the service generates and
sends a transaction ID as a response header of the request. In the case of
an error, the transaction ID is set in the
tracefield of the response body. Note: To help with debugging logs, it is strongly recommended that you generate and supply aTransaction-Idwith each request. - dict headers: A
dictcontaining the request headers
Returns
A
DetailedResponsecontaining the result, headers and HTTP status code.
Inherited Members
- ibm_cloud_sdk_core.base_service.BaseService
- SDK_NAME
- ERROR_MSG_DISABLE_SSL
- enable_retries
- disable_retries
- configure_service
- set_http_config
- set_disable_ssl_verification
- set_service_url
- get_http_client
- set_http_client
- get_authenticator
- set_default_headers
- send
- set_enable_gzip_compression
- get_enable_gzip_compression
- prepare_request
- encode_path_vars
769class CreateRuleAttachmentsResponse(): 770 """ 771 CreateRuleAttachmentsResponse. 772 773 :attr List[RuleAttachment] attachments: 774 """ 775 776 def __init__(self, 777 attachments: List['RuleAttachment']) -> None: 778 """ 779 Initialize a CreateRuleAttachmentsResponse object. 780 781 :param List[RuleAttachment] attachments: 782 """ 783 self.attachments = attachments 784 785 @classmethod 786 def from_dict(cls, _dict: Dict) -> 'CreateRuleAttachmentsResponse': 787 """Initialize a CreateRuleAttachmentsResponse object from a json dictionary.""" 788 args = {} 789 if 'attachments' in _dict: 790 args['attachments'] = [RuleAttachment.from_dict(x) for x in _dict.get('attachments')] 791 else: 792 raise ValueError('Required property \'attachments\' not present in CreateRuleAttachmentsResponse JSON') 793 return cls(**args) 794 795 @classmethod 796 def _from_dict(cls, _dict): 797 """Initialize a CreateRuleAttachmentsResponse object from a json dictionary.""" 798 return cls.from_dict(_dict) 799 800 def to_dict(self) -> Dict: 801 """Return a json dictionary representing this model.""" 802 _dict = {} 803 if hasattr(self, 'attachments') and self.attachments is not None: 804 _dict['attachments'] = [x.to_dict() for x in self.attachments] 805 return _dict 806 807 def _to_dict(self): 808 """Return a json dictionary representing this model.""" 809 return self.to_dict() 810 811 def __str__(self) -> str: 812 """Return a `str` version of this CreateRuleAttachmentsResponse object.""" 813 return json.dumps(self.to_dict(), indent=2) 814 815 def __eq__(self, other: 'CreateRuleAttachmentsResponse') -> bool: 816 """Return `true` when self and other are equal, false otherwise.""" 817 if not isinstance(other, self.__class__): 818 return False 819 return self.__dict__ == other.__dict__ 820 821 def __ne__(self, other: 'CreateRuleAttachmentsResponse') -> bool: 822 """Return `true` when self and other are not equal, false otherwise.""" 823 return not self == other
CreateRuleAttachmentsResponse.
:attr List[RuleAttachment] attachments:
776 def __init__(self, 777 attachments: List['RuleAttachment']) -> None: 778 """ 779 Initialize a CreateRuleAttachmentsResponse object. 780 781 :param List[RuleAttachment] attachments: 782 """ 783 self.attachments = attachments
Initialize a CreateRuleAttachmentsResponse object.
Parameters
- List[RuleAttachment] attachments:
785 @classmethod 786 def from_dict(cls, _dict: Dict) -> 'CreateRuleAttachmentsResponse': 787 """Initialize a CreateRuleAttachmentsResponse object from a json dictionary.""" 788 args = {} 789 if 'attachments' in _dict: 790 args['attachments'] = [RuleAttachment.from_dict(x) for x in _dict.get('attachments')] 791 else: 792 raise ValueError('Required property \'attachments\' not present in CreateRuleAttachmentsResponse JSON') 793 return cls(**args)
Initialize a CreateRuleAttachmentsResponse object from a json dictionary.
800 def to_dict(self) -> Dict: 801 """Return a json dictionary representing this model.""" 802 _dict = {} 803 if hasattr(self, 'attachments') and self.attachments is not None: 804 _dict['attachments'] = [x.to_dict() for x in self.attachments] 805 return _dict
Return a json dictionary representing this model.
825class CreateRuleRequest(): 826 """ 827 A rule to be created. 828 829 :attr str request_id: (optional) A field that you can use in bulk operations to 830 store a custom identifier for an individual request. If you omit this field, the 831 service generates and sends a `request_id` string for each new rule. The 832 generated string corresponds with the numerical order of the rules request 833 array. For example, `"request_id": "1"`, `"request_id": "2"`. 834 **Note:** To help with debugging logs, it is strongly recommended that you 835 generate and supply a `request_id` with each request. 836 :attr RuleRequest rule: Properties that you can associate with a rule. 837 """ 838 839 def __init__(self, 840 rule: 'RuleRequest', 841 *, 842 request_id: str = None) -> None: 843 """ 844 Initialize a CreateRuleRequest object. 845 846 :param RuleRequest rule: Properties that you can associate with a rule. 847 :param str request_id: (optional) A field that you can use in bulk 848 operations to store a custom identifier for an individual request. If you 849 omit this field, the service generates and sends a `request_id` string for 850 each new rule. The generated string corresponds with the numerical order of 851 the rules request array. For example, `"request_id": "1"`, `"request_id": 852 "2"`. 853 **Note:** To help with debugging logs, it is strongly recommended that you 854 generate and supply a `request_id` with each request. 855 """ 856 self.request_id = request_id 857 self.rule = rule 858 859 @classmethod 860 def from_dict(cls, _dict: Dict) -> 'CreateRuleRequest': 861 """Initialize a CreateRuleRequest object from a json dictionary.""" 862 args = {} 863 if 'request_id' in _dict: 864 args['request_id'] = _dict.get('request_id') 865 if 'rule' in _dict: 866 args['rule'] = RuleRequest.from_dict(_dict.get('rule')) 867 else: 868 raise ValueError('Required property \'rule\' not present in CreateRuleRequest JSON') 869 return cls(**args) 870 871 @classmethod 872 def _from_dict(cls, _dict): 873 """Initialize a CreateRuleRequest object from a json dictionary.""" 874 return cls.from_dict(_dict) 875 876 def to_dict(self) -> Dict: 877 """Return a json dictionary representing this model.""" 878 _dict = {} 879 if hasattr(self, 'request_id') and self.request_id is not None: 880 _dict['request_id'] = self.request_id 881 if hasattr(self, 'rule') and self.rule is not None: 882 _dict['rule'] = self.rule.to_dict() 883 return _dict 884 885 def _to_dict(self): 886 """Return a json dictionary representing this model.""" 887 return self.to_dict() 888 889 def __str__(self) -> str: 890 """Return a `str` version of this CreateRuleRequest object.""" 891 return json.dumps(self.to_dict(), indent=2) 892 893 def __eq__(self, other: 'CreateRuleRequest') -> bool: 894 """Return `true` when self and other are equal, false otherwise.""" 895 if not isinstance(other, self.__class__): 896 return False 897 return self.__dict__ == other.__dict__ 898 899 def __ne__(self, other: 'CreateRuleRequest') -> bool: 900 """Return `true` when self and other are not equal, false otherwise.""" 901 return not self == other
A rule to be created.
:attr str request_id: (optional) A field that you can use in bulk operations to
store a custom identifier for an individual request. If you omit this field, the
service generates and sends a request_id string for each new rule. The
generated string corresponds with the numerical order of the rules request
array. For example, "request_id": "1", "request_id": "2".
Note: To help with debugging logs, it is strongly recommended that you
generate and supply a request_id with each request.
:attr RuleRequest rule: Properties that you can associate with a rule.
839 def __init__(self, 840 rule: 'RuleRequest', 841 *, 842 request_id: str = None) -> None: 843 """ 844 Initialize a CreateRuleRequest object. 845 846 :param RuleRequest rule: Properties that you can associate with a rule. 847 :param str request_id: (optional) A field that you can use in bulk 848 operations to store a custom identifier for an individual request. If you 849 omit this field, the service generates and sends a `request_id` string for 850 each new rule. The generated string corresponds with the numerical order of 851 the rules request array. For example, `"request_id": "1"`, `"request_id": 852 "2"`. 853 **Note:** To help with debugging logs, it is strongly recommended that you 854 generate and supply a `request_id` with each request. 855 """ 856 self.request_id = request_id 857 self.rule = rule
Initialize a CreateRuleRequest object.
Parameters
- RuleRequest rule: Properties that you can associate with a rule.
- str request_id: (optional) A field that you can use in bulk
operations to store a custom identifier for an individual request. If you
omit this field, the service generates and sends a
request_idstring for each new rule. The generated string corresponds with the numerical order of the rules request array. For example,"request_id": "1","request_id": "2". Note: To help with debugging logs, it is strongly recommended that you generate and supply arequest_idwith each request.
859 @classmethod 860 def from_dict(cls, _dict: Dict) -> 'CreateRuleRequest': 861 """Initialize a CreateRuleRequest object from a json dictionary.""" 862 args = {} 863 if 'request_id' in _dict: 864 args['request_id'] = _dict.get('request_id') 865 if 'rule' in _dict: 866 args['rule'] = RuleRequest.from_dict(_dict.get('rule')) 867 else: 868 raise ValueError('Required property \'rule\' not present in CreateRuleRequest JSON') 869 return cls(**args)
Initialize a CreateRuleRequest object from a json dictionary.
876 def to_dict(self) -> Dict: 877 """Return a json dictionary representing this model.""" 878 _dict = {} 879 if hasattr(self, 'request_id') and self.request_id is not None: 880 _dict['request_id'] = self.request_id 881 if hasattr(self, 'rule') and self.rule is not None: 882 _dict['rule'] = self.rule.to_dict() 883 return _dict
Return a json dictionary representing this model.
903class CreateRuleResponse(): 904 """ 905 Response information for a rule request. 906 If the 'status_code' property indicates success, the 'request_id' and 'rule' 907 properties are returned in the response. If the 'status_code' property indicates an 908 error, the 'request_id', 'errors', and 'trace' fields are returned. 909 910 :attr str request_id: (optional) The identifier that is used to correlate an 911 individual request. 912 To assist with debugging, you can use this ID to identify and inspect only one 913 request that was made as part of a bulk operation. 914 :attr int status_code: (optional) The HTTP response status code. 915 :attr Rule rule: (optional) Information about a newly-created rule. 916 This field is present for successful requests. 917 :attr List[RuleResponseError] errors: (optional) The error contents of the 918 multi-status response. 919 This field is present for unsuccessful requests. 920 :attr str trace: (optional) The UUID that uniquely identifies the request. 921 This field is present for unsuccessful requests. 922 """ 923 924 def __init__(self, 925 *, 926 request_id: str = None, 927 status_code: int = None, 928 rule: 'Rule' = None, 929 errors: List['RuleResponseError'] = None, 930 trace: str = None) -> None: 931 """ 932 Initialize a CreateRuleResponse object. 933 934 :param str request_id: (optional) The identifier that is used to correlate 935 an individual request. 936 To assist with debugging, you can use this ID to identify and inspect only 937 one request that was made as part of a bulk operation. 938 :param int status_code: (optional) The HTTP response status code. 939 :param Rule rule: (optional) Information about a newly-created rule. 940 This field is present for successful requests. 941 :param List[RuleResponseError] errors: (optional) The error contents of the 942 multi-status response. 943 This field is present for unsuccessful requests. 944 :param str trace: (optional) The UUID that uniquely identifies the request. 945 This field is present for unsuccessful requests. 946 """ 947 self.request_id = request_id 948 self.status_code = status_code 949 self.rule = rule 950 self.errors = errors 951 self.trace = trace 952 953 @classmethod 954 def from_dict(cls, _dict: Dict) -> 'CreateRuleResponse': 955 """Initialize a CreateRuleResponse object from a json dictionary.""" 956 args = {} 957 if 'request_id' in _dict: 958 args['request_id'] = _dict.get('request_id') 959 if 'status_code' in _dict: 960 args['status_code'] = _dict.get('status_code') 961 if 'rule' in _dict: 962 args['rule'] = Rule.from_dict(_dict.get('rule')) 963 if 'errors' in _dict: 964 args['errors'] = [RuleResponseError.from_dict(x) for x in _dict.get('errors')] 965 if 'trace' in _dict: 966 args['trace'] = _dict.get('trace') 967 return cls(**args) 968 969 @classmethod 970 def _from_dict(cls, _dict): 971 """Initialize a CreateRuleResponse object from a json dictionary.""" 972 return cls.from_dict(_dict) 973 974 def to_dict(self) -> Dict: 975 """Return a json dictionary representing this model.""" 976 _dict = {} 977 if hasattr(self, 'request_id') and self.request_id is not None: 978 _dict['request_id'] = self.request_id 979 if hasattr(self, 'status_code') and self.status_code is not None: 980 _dict['status_code'] = self.status_code 981 if hasattr(self, 'rule') and self.rule is not None: 982 _dict['rule'] = self.rule.to_dict() 983 if hasattr(self, 'errors') and self.errors is not None: 984 _dict['errors'] = [x.to_dict() for x in self.errors] 985 if hasattr(self, 'trace') and self.trace is not None: 986 _dict['trace'] = self.trace 987 return _dict 988 989 def _to_dict(self): 990 """Return a json dictionary representing this model.""" 991 return self.to_dict() 992 993 def __str__(self) -> str: 994 """Return a `str` version of this CreateRuleResponse object.""" 995 return json.dumps(self.to_dict(), indent=2) 996 997 def __eq__(self, other: 'CreateRuleResponse') -> bool: 998 """Return `true` when self and other are equal, false otherwise.""" 999 if not isinstance(other, self.__class__): 1000 return False 1001 return self.__dict__ == other.__dict__ 1002 1003 def __ne__(self, other: 'CreateRuleResponse') -> bool: 1004 """Return `true` when self and other are not equal, false otherwise.""" 1005 return not self == other
Response information for a rule request. If the 'status_code' property indicates success, the 'request_id' and 'rule' properties are returned in the response. If the 'status_code' property indicates an error, the 'request_id', 'errors', and 'trace' fields are returned.
:attr str request_id: (optional) The identifier that is used to correlate an individual request. To assist with debugging, you can use this ID to identify and inspect only one request that was made as part of a bulk operation. :attr int status_code: (optional) The HTTP response status code. :attr Rule rule: (optional) Information about a newly-created rule. This field is present for successful requests. :attr List[RuleResponseError] errors: (optional) The error contents of the multi-status response. This field is present for unsuccessful requests. :attr str trace: (optional) The UUID that uniquely identifies the request. This field is present for unsuccessful requests.
924 def __init__(self, 925 *, 926 request_id: str = None, 927 status_code: int = None, 928 rule: 'Rule' = None, 929 errors: List['RuleResponseError'] = None, 930 trace: str = None) -> None: 931 """ 932 Initialize a CreateRuleResponse object. 933 934 :param str request_id: (optional) The identifier that is used to correlate 935 an individual request. 936 To assist with debugging, you can use this ID to identify and inspect only 937 one request that was made as part of a bulk operation. 938 :param int status_code: (optional) The HTTP response status code. 939 :param Rule rule: (optional) Information about a newly-created rule. 940 This field is present for successful requests. 941 :param List[RuleResponseError] errors: (optional) The error contents of the 942 multi-status response. 943 This field is present for unsuccessful requests. 944 :param str trace: (optional) The UUID that uniquely identifies the request. 945 This field is present for unsuccessful requests. 946 """ 947 self.request_id = request_id 948 self.status_code = status_code 949 self.rule = rule 950 self.errors = errors 951 self.trace = trace
Initialize a CreateRuleResponse object.
Parameters
- str request_id: (optional) The identifier that is used to correlate an individual request. To assist with debugging, you can use this ID to identify and inspect only one request that was made as part of a bulk operation.
- int status_code: (optional) The HTTP response status code.
- Rule rule: (optional) Information about a newly-created rule. This field is present for successful requests.
- List[RuleResponseError] errors: (optional) The error contents of the multi-status response. This field is present for unsuccessful requests.
- str trace: (optional) The UUID that uniquely identifies the request. This field is present for unsuccessful requests.
953 @classmethod 954 def from_dict(cls, _dict: Dict) -> 'CreateRuleResponse': 955 """Initialize a CreateRuleResponse object from a json dictionary.""" 956 args = {} 957 if 'request_id' in _dict: 958 args['request_id'] = _dict.get('request_id') 959 if 'status_code' in _dict: 960 args['status_code'] = _dict.get('status_code') 961 if 'rule' in _dict: 962 args['rule'] = Rule.from_dict(_dict.get('rule')) 963 if 'errors' in _dict: 964 args['errors'] = [RuleResponseError.from_dict(x) for x in _dict.get('errors')] 965 if 'trace' in _dict: 966 args['trace'] = _dict.get('trace') 967 return cls(**args)
Initialize a CreateRuleResponse object from a json dictionary.
974 def to_dict(self) -> Dict: 975 """Return a json dictionary representing this model.""" 976 _dict = {} 977 if hasattr(self, 'request_id') and self.request_id is not None: 978 _dict['request_id'] = self.request_id 979 if hasattr(self, 'status_code') and self.status_code is not None: 980 _dict['status_code'] = self.status_code 981 if hasattr(self, 'rule') and self.rule is not None: 982 _dict['rule'] = self.rule.to_dict() 983 if hasattr(self, 'errors') and self.errors is not None: 984 _dict['errors'] = [x.to_dict() for x in self.errors] 985 if hasattr(self, 'trace') and self.trace is not None: 986 _dict['trace'] = self.trace 987 return _dict
Return a json dictionary representing this model.
1007class CreateRulesResponse(): 1008 """ 1009 The response associated with a request to create one or more rules. 1010 1011 :attr List[CreateRuleResponse] rules: An array of rule responses. 1012 """ 1013 1014 def __init__(self, 1015 rules: List['CreateRuleResponse']) -> None: 1016 """ 1017 Initialize a CreateRulesResponse object. 1018 1019 :param List[CreateRuleResponse] rules: An array of rule responses. 1020 """ 1021 self.rules = rules 1022 1023 @classmethod 1024 def from_dict(cls, _dict: Dict) -> 'CreateRulesResponse': 1025 """Initialize a CreateRulesResponse object from a json dictionary.""" 1026 args = {} 1027 if 'rules' in _dict: 1028 args['rules'] = [CreateRuleResponse.from_dict(x) for x in _dict.get('rules')] 1029 else: 1030 raise ValueError('Required property \'rules\' not present in CreateRulesResponse JSON') 1031 return cls(**args) 1032 1033 @classmethod 1034 def _from_dict(cls, _dict): 1035 """Initialize a CreateRulesResponse object from a json dictionary.""" 1036 return cls.from_dict(_dict) 1037 1038 def to_dict(self) -> Dict: 1039 """Return a json dictionary representing this model.""" 1040 _dict = {} 1041 if hasattr(self, 'rules') and self.rules is not None: 1042 _dict['rules'] = [x.to_dict() for x in self.rules] 1043 return _dict 1044 1045 def _to_dict(self): 1046 """Return a json dictionary representing this model.""" 1047 return self.to_dict() 1048 1049 def __str__(self) -> str: 1050 """Return a `str` version of this CreateRulesResponse object.""" 1051 return json.dumps(self.to_dict(), indent=2) 1052 1053 def __eq__(self, other: 'CreateRulesResponse') -> bool: 1054 """Return `true` when self and other are equal, false otherwise.""" 1055 if not isinstance(other, self.__class__): 1056 return False 1057 return self.__dict__ == other.__dict__ 1058 1059 def __ne__(self, other: 'CreateRulesResponse') -> bool: 1060 """Return `true` when self and other are not equal, false otherwise.""" 1061 return not self == other
The response associated with a request to create one or more rules.
:attr List[CreateRuleResponse] rules: An array of rule responses.
1014 def __init__(self, 1015 rules: List['CreateRuleResponse']) -> None: 1016 """ 1017 Initialize a CreateRulesResponse object. 1018 1019 :param List[CreateRuleResponse] rules: An array of rule responses. 1020 """ 1021 self.rules = rules
Initialize a CreateRulesResponse object.
Parameters
- List[CreateRuleResponse] rules: An array of rule responses.
1023 @classmethod 1024 def from_dict(cls, _dict: Dict) -> 'CreateRulesResponse': 1025 """Initialize a CreateRulesResponse object from a json dictionary.""" 1026 args = {} 1027 if 'rules' in _dict: 1028 args['rules'] = [CreateRuleResponse.from_dict(x) for x in _dict.get('rules')] 1029 else: 1030 raise ValueError('Required property \'rules\' not present in CreateRulesResponse JSON') 1031 return cls(**args)
Initialize a CreateRulesResponse object from a json dictionary.
1038 def to_dict(self) -> Dict: 1039 """Return a json dictionary representing this model.""" 1040 _dict = {} 1041 if hasattr(self, 'rules') and self.rules is not None: 1042 _dict['rules'] = [x.to_dict() for x in self.rules] 1043 return _dict
Return a json dictionary representing this model.
1063class EnforcementAction(): 1064 """ 1065 EnforcementAction. 1066 1067 :attr str action: To block a request from completing, use `disallow`. To log the 1068 request to Activity Tracker with LogDNA, use `audit_log`. 1069 """ 1070 1071 def __init__(self, 1072 action: str) -> None: 1073 """ 1074 Initialize a EnforcementAction object. 1075 1076 :param str action: To block a request from completing, use `disallow`. To 1077 log the request to Activity Tracker with LogDNA, use `audit_log`. 1078 """ 1079 self.action = action 1080 1081 @classmethod 1082 def from_dict(cls, _dict: Dict) -> 'EnforcementAction': 1083 """Initialize a EnforcementAction object from a json dictionary.""" 1084 args = {} 1085 if 'action' in _dict: 1086 args['action'] = _dict.get('action') 1087 else: 1088 raise ValueError('Required property \'action\' not present in EnforcementAction JSON') 1089 return cls(**args) 1090 1091 @classmethod 1092 def _from_dict(cls, _dict): 1093 """Initialize a EnforcementAction object from a json dictionary.""" 1094 return cls.from_dict(_dict) 1095 1096 def to_dict(self) -> Dict: 1097 """Return a json dictionary representing this model.""" 1098 _dict = {} 1099 if hasattr(self, 'action') and self.action is not None: 1100 _dict['action'] = self.action 1101 return _dict 1102 1103 def _to_dict(self): 1104 """Return a json dictionary representing this model.""" 1105 return self.to_dict() 1106 1107 def __str__(self) -> str: 1108 """Return a `str` version of this EnforcementAction object.""" 1109 return json.dumps(self.to_dict(), indent=2) 1110 1111 def __eq__(self, other: 'EnforcementAction') -> bool: 1112 """Return `true` when self and other are equal, false otherwise.""" 1113 if not isinstance(other, self.__class__): 1114 return False 1115 return self.__dict__ == other.__dict__ 1116 1117 def __ne__(self, other: 'EnforcementAction') -> bool: 1118 """Return `true` when self and other are not equal, false otherwise.""" 1119 return not self == other 1120 1121 class ActionEnum(str, Enum): 1122 """ 1123 To block a request from completing, use `disallow`. To log the request to Activity 1124 Tracker with LogDNA, use `audit_log`. 1125 """ 1126 AUDIT_LOG = 'audit_log' 1127 DISALLOW = 'disallow'
EnforcementAction.
:attr str action: To block a request from completing, use disallow. To log the
request to Activity Tracker with LogDNA, use audit_log.
1071 def __init__(self, 1072 action: str) -> None: 1073 """ 1074 Initialize a EnforcementAction object. 1075 1076 :param str action: To block a request from completing, use `disallow`. To 1077 log the request to Activity Tracker with LogDNA, use `audit_log`. 1078 """ 1079 self.action = action
Initialize a EnforcementAction object.
Parameters
- str action: To block a request from completing, use
disallow. To log the request to Activity Tracker with LogDNA, useaudit_log.
1081 @classmethod 1082 def from_dict(cls, _dict: Dict) -> 'EnforcementAction': 1083 """Initialize a EnforcementAction object from a json dictionary.""" 1084 args = {} 1085 if 'action' in _dict: 1086 args['action'] = _dict.get('action') 1087 else: 1088 raise ValueError('Required property \'action\' not present in EnforcementAction JSON') 1089 return cls(**args)
Initialize a EnforcementAction object from a json dictionary.
1121 class ActionEnum(str, Enum): 1122 """ 1123 To block a request from completing, use `disallow`. To log the request to Activity 1124 Tracker with LogDNA, use `audit_log`. 1125 """ 1126 AUDIT_LOG = 'audit_log' 1127 DISALLOW = 'disallow'
To block a request from completing, use disallow. To log the request to Activity
Tracker with LogDNA, use audit_log.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
1130class Link(): 1131 """ 1132 A link that is used to paginate through available resources. 1133 1134 :attr str href: The URL for the first, previous, next, or last page of 1135 resources. 1136 """ 1137 1138 def __init__(self, 1139 href: str) -> None: 1140 """ 1141 Initialize a Link object. 1142 1143 :param str href: The URL for the first, previous, next, or last page of 1144 resources. 1145 """ 1146 self.href = href 1147 1148 @classmethod 1149 def from_dict(cls, _dict: Dict) -> 'Link': 1150 """Initialize a Link object from a json dictionary.""" 1151 args = {} 1152 if 'href' in _dict: 1153 args['href'] = _dict.get('href') 1154 else: 1155 raise ValueError('Required property \'href\' not present in Link JSON') 1156 return cls(**args) 1157 1158 @classmethod 1159 def _from_dict(cls, _dict): 1160 """Initialize a Link object from a json dictionary.""" 1161 return cls.from_dict(_dict) 1162 1163 def to_dict(self) -> Dict: 1164 """Return a json dictionary representing this model.""" 1165 _dict = {} 1166 if hasattr(self, 'href') and self.href is not None: 1167 _dict['href'] = self.href 1168 return _dict 1169 1170 def _to_dict(self): 1171 """Return a json dictionary representing this model.""" 1172 return self.to_dict() 1173 1174 def __str__(self) -> str: 1175 """Return a `str` version of this Link object.""" 1176 return json.dumps(self.to_dict(), indent=2) 1177 1178 def __eq__(self, other: 'Link') -> bool: 1179 """Return `true` when self and other are equal, false otherwise.""" 1180 if not isinstance(other, self.__class__): 1181 return False 1182 return self.__dict__ == other.__dict__ 1183 1184 def __ne__(self, other: 'Link') -> bool: 1185 """Return `true` when self and other are not equal, false otherwise.""" 1186 return not self == other
A link that is used to paginate through available resources.
:attr str href: The URL for the first, previous, next, or last page of resources.
1138 def __init__(self, 1139 href: str) -> None: 1140 """ 1141 Initialize a Link object. 1142 1143 :param str href: The URL for the first, previous, next, or last page of 1144 resources. 1145 """ 1146 self.href = href
Initialize a Link object.
Parameters
- str href: The URL for the first, previous, next, or last page of resources.
1148 @classmethod 1149 def from_dict(cls, _dict: Dict) -> 'Link': 1150 """Initialize a Link object from a json dictionary.""" 1151 args = {} 1152 if 'href' in _dict: 1153 args['href'] = _dict.get('href') 1154 else: 1155 raise ValueError('Required property \'href\' not present in Link JSON') 1156 return cls(**args)
Initialize a Link object from a json dictionary.
1188class Rule(): 1189 """ 1190 Properties associated with a rule, including both user-defined and server-populated 1191 properties. 1192 1193 :attr str account_id: (optional) Your IBM Cloud account ID. 1194 :attr str name: A human-readable alias to assign to your rule. 1195 :attr str description: An extended description of your rule. 1196 :attr str rule_type: (optional) The type of rule. Rules that you create are 1197 `user_defined`. 1198 :attr TargetResource target: The properties that describe the resource that you 1199 want to target 1200 with the rule or template. 1201 :attr RuleRequiredConfig required_config: 1202 :attr List[EnforcementAction] enforcement_actions: The actions that the service 1203 must run on your behalf when a request to create or modify the target resource 1204 does not comply with your conditions. 1205 :attr List[str] labels: (optional) Labels that you can use to group and search 1206 for similar rules, such as those that help you to meet a specific organization 1207 guideline. 1208 :attr str rule_id: (optional) The UUID that uniquely identifies the rule. 1209 :attr datetime creation_date: (optional) The date the resource was created. 1210 :attr str created_by: (optional) The unique identifier for the user or 1211 application that created the resource. 1212 :attr datetime modification_date: (optional) The date the resource was last 1213 modified. 1214 :attr str modified_by: (optional) The unique identifier for the user or 1215 application that last modified the resource. 1216 :attr int number_of_attachments: (optional) The number of scope attachments that 1217 are associated with the rule. 1218 """ 1219 1220 def __init__(self, 1221 name: str, 1222 description: str, 1223 target: 'TargetResource', 1224 required_config: 'RuleRequiredConfig', 1225 enforcement_actions: List['EnforcementAction'], 1226 *, 1227 account_id: str = None, 1228 rule_type: str = None, 1229 labels: List[str] = None, 1230 rule_id: str = None, 1231 creation_date: datetime = None, 1232 created_by: str = None, 1233 modification_date: datetime = None, 1234 modified_by: str = None, 1235 number_of_attachments: int = None) -> None: 1236 """ 1237 Initialize a Rule object. 1238 1239 :param str name: A human-readable alias to assign to your rule. 1240 :param str description: An extended description of your rule. 1241 :param TargetResource target: The properties that describe the resource 1242 that you want to target 1243 with the rule or template. 1244 :param RuleRequiredConfig required_config: 1245 :param List[EnforcementAction] enforcement_actions: The actions that the 1246 service must run on your behalf when a request to create or modify the 1247 target resource does not comply with your conditions. 1248 :param str account_id: (optional) Your IBM Cloud account ID. 1249 :param str rule_type: (optional) The type of rule. Rules that you create 1250 are `user_defined`. 1251 :param List[str] labels: (optional) Labels that you can use to group and 1252 search for similar rules, such as those that help you to meet a specific 1253 organization guideline. 1254 """ 1255 self.account_id = account_id 1256 self.name = name 1257 self.description = description 1258 self.rule_type = rule_type 1259 self.target = target 1260 self.required_config = required_config 1261 self.enforcement_actions = enforcement_actions 1262 self.labels = labels 1263 self.rule_id = rule_id 1264 self.creation_date = creation_date 1265 self.created_by = created_by 1266 self.modification_date = modification_date 1267 self.modified_by = modified_by 1268 self.number_of_attachments = number_of_attachments 1269 1270 @classmethod 1271 def from_dict(cls, _dict: Dict) -> 'Rule': 1272 """Initialize a Rule object from a json dictionary.""" 1273 args = {} 1274 if 'account_id' in _dict: 1275 args['account_id'] = _dict.get('account_id') 1276 if 'name' in _dict: 1277 args['name'] = _dict.get('name') 1278 else: 1279 raise ValueError('Required property \'name\' not present in Rule JSON') 1280 if 'description' in _dict: 1281 args['description'] = _dict.get('description') 1282 else: 1283 raise ValueError('Required property \'description\' not present in Rule JSON') 1284 if 'rule_type' in _dict: 1285 args['rule_type'] = _dict.get('rule_type') 1286 if 'target' in _dict: 1287 args['target'] = TargetResource.from_dict(_dict.get('target')) 1288 else: 1289 raise ValueError('Required property \'target\' not present in Rule JSON') 1290 if 'required_config' in _dict: 1291 args['required_config'] = _dict.get('required_config') 1292 else: 1293 raise ValueError('Required property \'required_config\' not present in Rule JSON') 1294 if 'enforcement_actions' in _dict: 1295 args['enforcement_actions'] = [EnforcementAction.from_dict(x) for x in _dict.get('enforcement_actions')] 1296 else: 1297 raise ValueError('Required property \'enforcement_actions\' not present in Rule JSON') 1298 if 'labels' in _dict: 1299 args['labels'] = _dict.get('labels') 1300 if 'rule_id' in _dict: 1301 args['rule_id'] = _dict.get('rule_id') 1302 if 'creation_date' in _dict: 1303 args['creation_date'] = string_to_datetime(_dict.get('creation_date')) 1304 if 'created_by' in _dict: 1305 args['created_by'] = _dict.get('created_by') 1306 if 'modification_date' in _dict: 1307 args['modification_date'] = string_to_datetime(_dict.get('modification_date')) 1308 if 'modified_by' in _dict: 1309 args['modified_by'] = _dict.get('modified_by') 1310 if 'number_of_attachments' in _dict: 1311 args['number_of_attachments'] = _dict.get('number_of_attachments') 1312 return cls(**args) 1313 1314 @classmethod 1315 def _from_dict(cls, _dict): 1316 """Initialize a Rule object from a json dictionary.""" 1317 return cls.from_dict(_dict) 1318 1319 def to_dict(self) -> Dict: 1320 """Return a json dictionary representing this model.""" 1321 _dict = {} 1322 if hasattr(self, 'account_id') and self.account_id is not None: 1323 _dict['account_id'] = self.account_id 1324 if hasattr(self, 'name') and self.name is not None: 1325 _dict['name'] = self.name 1326 if hasattr(self, 'description') and self.description is not None: 1327 _dict['description'] = self.description 1328 if hasattr(self, 'rule_type') and self.rule_type is not None: 1329 _dict['rule_type'] = self.rule_type 1330 if hasattr(self, 'target') and self.target is not None: 1331 _dict['target'] = self.target.to_dict() 1332 if hasattr(self, 'required_config') and self.required_config is not None: 1333 if isinstance(self.required_config, dict): 1334 _dict['required_config'] = self.required_config 1335 else: 1336 _dict['required_config'] = self.required_config.to_dict() 1337 if hasattr(self, 'enforcement_actions') and self.enforcement_actions is not None: 1338 _dict['enforcement_actions'] = [x.to_dict() for x in self.enforcement_actions] 1339 if hasattr(self, 'labels') and self.labels is not None: 1340 _dict['labels'] = self.labels 1341 if hasattr(self, 'rule_id') and getattr(self, 'rule_id') is not None: 1342 _dict['rule_id'] = getattr(self, 'rule_id') 1343 if hasattr(self, 'creation_date') and getattr(self, 'creation_date') is not None: 1344 _dict['creation_date'] = datetime_to_string(getattr(self, 'creation_date')) 1345 if hasattr(self, 'created_by') and getattr(self, 'created_by') is not None: 1346 _dict['created_by'] = getattr(self, 'created_by') 1347 if hasattr(self, 'modification_date') and getattr(self, 'modification_date') is not None: 1348 _dict['modification_date'] = datetime_to_string(getattr(self, 'modification_date')) 1349 if hasattr(self, 'modified_by') and getattr(self, 'modified_by') is not None: 1350 _dict['modified_by'] = getattr(self, 'modified_by') 1351 if hasattr(self, 'number_of_attachments') and getattr(self, 'number_of_attachments') is not None: 1352 _dict['number_of_attachments'] = getattr(self, 'number_of_attachments') 1353 return _dict 1354 1355 def _to_dict(self): 1356 """Return a json dictionary representing this model.""" 1357 return self.to_dict() 1358 1359 def __str__(self) -> str: 1360 """Return a `str` version of this Rule object.""" 1361 return json.dumps(self.to_dict(), indent=2) 1362 1363 def __eq__(self, other: 'Rule') -> bool: 1364 """Return `true` when self and other are equal, false otherwise.""" 1365 if not isinstance(other, self.__class__): 1366 return False 1367 return self.__dict__ == other.__dict__ 1368 1369 def __ne__(self, other: 'Rule') -> bool: 1370 """Return `true` when self and other are not equal, false otherwise.""" 1371 return not self == other 1372 1373 class RuleTypeEnum(str, Enum): 1374 """ 1375 The type of rule. Rules that you create are `user_defined`. 1376 """ 1377 USER_DEFINED = 'user_defined'
Properties associated with a rule, including both user-defined and server-populated properties.
:attr str account_id: (optional) Your IBM Cloud account ID.
:attr str name: A human-readable alias to assign to your rule.
:attr str description: An extended description of your rule.
:attr str rule_type: (optional) The type of rule. Rules that you create are
user_defined.
:attr TargetResource target: The properties that describe the resource that you
want to target
with the rule or template.
:attr RuleRequiredConfig required_config:
:attr List[EnforcementAction] enforcement_actions: The actions that the service
must run on your behalf when a request to create or modify the target resource
does not comply with your conditions.
:attr List[str] labels: (optional) Labels that you can use to group and search
for similar rules, such as those that help you to meet a specific organization
guideline.
:attr str rule_id: (optional) The UUID that uniquely identifies the rule.
:attr datetime creation_date: (optional) The date the resource was created.
:attr str created_by: (optional) The unique identifier for the user or
application that created the resource.
:attr datetime modification_date: (optional) The date the resource was last
modified.
:attr str modified_by: (optional) The unique identifier for the user or
application that last modified the resource.
:attr int number_of_attachments: (optional) The number of scope attachments that
are associated with the rule.
1220 def __init__(self, 1221 name: str, 1222 description: str, 1223 target: 'TargetResource', 1224 required_config: 'RuleRequiredConfig', 1225 enforcement_actions: List['EnforcementAction'], 1226 *, 1227 account_id: str = None, 1228 rule_type: str = None, 1229 labels: List[str] = None, 1230 rule_id: str = None, 1231 creation_date: datetime = None, 1232 created_by: str = None, 1233 modification_date: datetime = None, 1234 modified_by: str = None, 1235 number_of_attachments: int = None) -> None: 1236 """ 1237 Initialize a Rule object. 1238 1239 :param str name: A human-readable alias to assign to your rule. 1240 :param str description: An extended description of your rule. 1241 :param TargetResource target: The properties that describe the resource 1242 that you want to target 1243 with the rule or template. 1244 :param RuleRequiredConfig required_config: 1245 :param List[EnforcementAction] enforcement_actions: The actions that the 1246 service must run on your behalf when a request to create or modify the 1247 target resource does not comply with your conditions. 1248 :param str account_id: (optional) Your IBM Cloud account ID. 1249 :param str rule_type: (optional) The type of rule. Rules that you create 1250 are `user_defined`. 1251 :param List[str] labels: (optional) Labels that you can use to group and 1252 search for similar rules, such as those that help you to meet a specific 1253 organization guideline. 1254 """ 1255 self.account_id = account_id 1256 self.name = name 1257 self.description = description 1258 self.rule_type = rule_type 1259 self.target = target 1260 self.required_config = required_config 1261 self.enforcement_actions = enforcement_actions 1262 self.labels = labels 1263 self.rule_id = rule_id 1264 self.creation_date = creation_date 1265 self.created_by = created_by 1266 self.modification_date = modification_date 1267 self.modified_by = modified_by 1268 self.number_of_attachments = number_of_attachments
Initialize a Rule object.
Parameters
- str name: A human-readable alias to assign to your rule.
- str description: An extended description of your rule.
- TargetResource target: The properties that describe the resource that you want to target with the rule or template.
- RuleRequiredConfig required_config:
- List[EnforcementAction] enforcement_actions: The actions that the service must run on your behalf when a request to create or modify the target resource does not comply with your conditions.
- str account_id: (optional) Your IBM Cloud account ID.
- str rule_type: (optional) The type of rule. Rules that you create
are
user_defined. - List[str] labels: (optional) Labels that you can use to group and search for similar rules, such as those that help you to meet a specific organization guideline.
1270 @classmethod 1271 def from_dict(cls, _dict: Dict) -> 'Rule': 1272 """Initialize a Rule object from a json dictionary.""" 1273 args = {} 1274 if 'account_id' in _dict: 1275 args['account_id'] = _dict.get('account_id') 1276 if 'name' in _dict: 1277 args['name'] = _dict.get('name') 1278 else: 1279 raise ValueError('Required property \'name\' not present in Rule JSON') 1280 if 'description' in _dict: 1281 args['description'] = _dict.get('description') 1282 else: 1283 raise ValueError('Required property \'description\' not present in Rule JSON') 1284 if 'rule_type' in _dict: 1285 args['rule_type'] = _dict.get('rule_type') 1286 if 'target' in _dict: 1287 args['target'] = TargetResource.from_dict(_dict.get('target')) 1288 else: 1289 raise ValueError('Required property \'target\' not present in Rule JSON') 1290 if 'required_config' in _dict: 1291 args['required_config'] = _dict.get('required_config') 1292 else: 1293 raise ValueError('Required property \'required_config\' not present in Rule JSON') 1294 if 'enforcement_actions' in _dict: 1295 args['enforcement_actions'] = [EnforcementAction.from_dict(x) for x in _dict.get('enforcement_actions')] 1296 else: 1297 raise ValueError('Required property \'enforcement_actions\' not present in Rule JSON') 1298 if 'labels' in _dict: 1299 args['labels'] = _dict.get('labels') 1300 if 'rule_id' in _dict: 1301 args['rule_id'] = _dict.get('rule_id') 1302 if 'creation_date' in _dict: 1303 args['creation_date'] = string_to_datetime(_dict.get('creation_date')) 1304 if 'created_by' in _dict: 1305 args['created_by'] = _dict.get('created_by') 1306 if 'modification_date' in _dict: 1307 args['modification_date'] = string_to_datetime(_dict.get('modification_date')) 1308 if 'modified_by' in _dict: 1309 args['modified_by'] = _dict.get('modified_by') 1310 if 'number_of_attachments' in _dict: 1311 args['number_of_attachments'] = _dict.get('number_of_attachments') 1312 return cls(**args)
Initialize a Rule object from a json dictionary.
1319 def to_dict(self) -> Dict: 1320 """Return a json dictionary representing this model.""" 1321 _dict = {} 1322 if hasattr(self, 'account_id') and self.account_id is not None: 1323 _dict['account_id'] = self.account_id 1324 if hasattr(self, 'name') and self.name is not None: 1325 _dict['name'] = self.name 1326 if hasattr(self, 'description') and self.description is not None: 1327 _dict['description'] = self.description 1328 if hasattr(self, 'rule_type') and self.rule_type is not None: 1329 _dict['rule_type'] = self.rule_type 1330 if hasattr(self, 'target') and self.target is not None: 1331 _dict['target'] = self.target.to_dict() 1332 if hasattr(self, 'required_config') and self.required_config is not None: 1333 if isinstance(self.required_config, dict): 1334 _dict['required_config'] = self.required_config 1335 else: 1336 _dict['required_config'] = self.required_config.to_dict() 1337 if hasattr(self, 'enforcement_actions') and self.enforcement_actions is not None: 1338 _dict['enforcement_actions'] = [x.to_dict() for x in self.enforcement_actions] 1339 if hasattr(self, 'labels') and self.labels is not None: 1340 _dict['labels'] = self.labels 1341 if hasattr(self, 'rule_id') and getattr(self, 'rule_id') is not None: 1342 _dict['rule_id'] = getattr(self, 'rule_id') 1343 if hasattr(self, 'creation_date') and getattr(self, 'creation_date') is not None: 1344 _dict['creation_date'] = datetime_to_string(getattr(self, 'creation_date')) 1345 if hasattr(self, 'created_by') and getattr(self, 'created_by') is not None: 1346 _dict['created_by'] = getattr(self, 'created_by') 1347 if hasattr(self, 'modification_date') and getattr(self, 'modification_date') is not None: 1348 _dict['modification_date'] = datetime_to_string(getattr(self, 'modification_date')) 1349 if hasattr(self, 'modified_by') and getattr(self, 'modified_by') is not None: 1350 _dict['modified_by'] = getattr(self, 'modified_by') 1351 if hasattr(self, 'number_of_attachments') and getattr(self, 'number_of_attachments') is not None: 1352 _dict['number_of_attachments'] = getattr(self, 'number_of_attachments') 1353 return _dict
Return a json dictionary representing this model.
1373 class RuleTypeEnum(str, Enum): 1374 """ 1375 The type of rule. Rules that you create are `user_defined`. 1376 """ 1377 USER_DEFINED = 'user_defined'
The type of rule. Rules that you create are user_defined.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
1380class RuleAttachment(): 1381 """ 1382 The scopes to attach to a rule. 1383 1384 :attr str attachment_id: The UUID that uniquely identifies the attachment. 1385 :attr str rule_id: The UUID that uniquely identifies the rule. 1386 :attr str account_id: Your IBM Cloud account ID. 1387 :attr RuleScope included_scope: The extent at which the rule can be attached 1388 across your accounts. 1389 :attr List[RuleScope] excluded_scopes: (optional) The extent at which the rule 1390 can be excluded from the included scope. 1391 """ 1392 1393 def __init__(self, 1394 attachment_id: str, 1395 rule_id: str, 1396 account_id: str, 1397 included_scope: 'RuleScope', 1398 *, 1399 excluded_scopes: List['RuleScope'] = None) -> None: 1400 """ 1401 Initialize a RuleAttachment object. 1402 1403 :param str attachment_id: The UUID that uniquely identifies the attachment. 1404 :param str rule_id: The UUID that uniquely identifies the rule. 1405 :param str account_id: Your IBM Cloud account ID. 1406 :param RuleScope included_scope: The extent at which the rule can be 1407 attached across your accounts. 1408 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 1409 rule can be excluded from the included scope. 1410 """ 1411 self.attachment_id = attachment_id 1412 self.rule_id = rule_id 1413 self.account_id = account_id 1414 self.included_scope = included_scope 1415 self.excluded_scopes = excluded_scopes 1416 1417 @classmethod 1418 def from_dict(cls, _dict: Dict) -> 'RuleAttachment': 1419 """Initialize a RuleAttachment object from a json dictionary.""" 1420 args = {} 1421 if 'attachment_id' in _dict: 1422 args['attachment_id'] = _dict.get('attachment_id') 1423 else: 1424 raise ValueError('Required property \'attachment_id\' not present in RuleAttachment JSON') 1425 if 'rule_id' in _dict: 1426 args['rule_id'] = _dict.get('rule_id') 1427 else: 1428 raise ValueError('Required property \'rule_id\' not present in RuleAttachment JSON') 1429 if 'account_id' in _dict: 1430 args['account_id'] = _dict.get('account_id') 1431 else: 1432 raise ValueError('Required property \'account_id\' not present in RuleAttachment JSON') 1433 if 'included_scope' in _dict: 1434 args['included_scope'] = RuleScope.from_dict(_dict.get('included_scope')) 1435 else: 1436 raise ValueError('Required property \'included_scope\' not present in RuleAttachment JSON') 1437 if 'excluded_scopes' in _dict: 1438 args['excluded_scopes'] = [RuleScope.from_dict(x) for x in _dict.get('excluded_scopes')] 1439 return cls(**args) 1440 1441 @classmethod 1442 def _from_dict(cls, _dict): 1443 """Initialize a RuleAttachment object from a json dictionary.""" 1444 return cls.from_dict(_dict) 1445 1446 def to_dict(self) -> Dict: 1447 """Return a json dictionary representing this model.""" 1448 _dict = {} 1449 if hasattr(self, 'attachment_id') and self.attachment_id is not None: 1450 _dict['attachment_id'] = self.attachment_id 1451 if hasattr(self, 'rule_id') and self.rule_id is not None: 1452 _dict['rule_id'] = self.rule_id 1453 if hasattr(self, 'account_id') and self.account_id is not None: 1454 _dict['account_id'] = self.account_id 1455 if hasattr(self, 'included_scope') and self.included_scope is not None: 1456 _dict['included_scope'] = self.included_scope.to_dict() 1457 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 1458 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 1459 return _dict 1460 1461 def _to_dict(self): 1462 """Return a json dictionary representing this model.""" 1463 return self.to_dict() 1464 1465 def __str__(self) -> str: 1466 """Return a `str` version of this RuleAttachment object.""" 1467 return json.dumps(self.to_dict(), indent=2) 1468 1469 def __eq__(self, other: 'RuleAttachment') -> bool: 1470 """Return `true` when self and other are equal, false otherwise.""" 1471 if not isinstance(other, self.__class__): 1472 return False 1473 return self.__dict__ == other.__dict__ 1474 1475 def __ne__(self, other: 'RuleAttachment') -> bool: 1476 """Return `true` when self and other are not equal, false otherwise.""" 1477 return not self == other
The scopes to attach to a rule.
:attr str attachment_id: The UUID that uniquely identifies the attachment. :attr str rule_id: The UUID that uniquely identifies the rule. :attr str account_id: Your IBM Cloud account ID. :attr RuleScope included_scope: The extent at which the rule can be attached across your accounts. :attr List[RuleScope] excluded_scopes: (optional) The extent at which the rule can be excluded from the included scope.
1393 def __init__(self, 1394 attachment_id: str, 1395 rule_id: str, 1396 account_id: str, 1397 included_scope: 'RuleScope', 1398 *, 1399 excluded_scopes: List['RuleScope'] = None) -> None: 1400 """ 1401 Initialize a RuleAttachment object. 1402 1403 :param str attachment_id: The UUID that uniquely identifies the attachment. 1404 :param str rule_id: The UUID that uniquely identifies the rule. 1405 :param str account_id: Your IBM Cloud account ID. 1406 :param RuleScope included_scope: The extent at which the rule can be 1407 attached across your accounts. 1408 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 1409 rule can be excluded from the included scope. 1410 """ 1411 self.attachment_id = attachment_id 1412 self.rule_id = rule_id 1413 self.account_id = account_id 1414 self.included_scope = included_scope 1415 self.excluded_scopes = excluded_scopes
Initialize a RuleAttachment object.
Parameters
- str attachment_id: The UUID that uniquely identifies the attachment.
- str rule_id: The UUID that uniquely identifies the rule.
- str account_id: Your IBM Cloud account ID.
- RuleScope included_scope: The extent at which the rule can be attached across your accounts.
- List[RuleScope] excluded_scopes: (optional) The extent at which the rule can be excluded from the included scope.
1417 @classmethod 1418 def from_dict(cls, _dict: Dict) -> 'RuleAttachment': 1419 """Initialize a RuleAttachment object from a json dictionary.""" 1420 args = {} 1421 if 'attachment_id' in _dict: 1422 args['attachment_id'] = _dict.get('attachment_id') 1423 else: 1424 raise ValueError('Required property \'attachment_id\' not present in RuleAttachment JSON') 1425 if 'rule_id' in _dict: 1426 args['rule_id'] = _dict.get('rule_id') 1427 else: 1428 raise ValueError('Required property \'rule_id\' not present in RuleAttachment JSON') 1429 if 'account_id' in _dict: 1430 args['account_id'] = _dict.get('account_id') 1431 else: 1432 raise ValueError('Required property \'account_id\' not present in RuleAttachment JSON') 1433 if 'included_scope' in _dict: 1434 args['included_scope'] = RuleScope.from_dict(_dict.get('included_scope')) 1435 else: 1436 raise ValueError('Required property \'included_scope\' not present in RuleAttachment JSON') 1437 if 'excluded_scopes' in _dict: 1438 args['excluded_scopes'] = [RuleScope.from_dict(x) for x in _dict.get('excluded_scopes')] 1439 return cls(**args)
Initialize a RuleAttachment object from a json dictionary.
1446 def to_dict(self) -> Dict: 1447 """Return a json dictionary representing this model.""" 1448 _dict = {} 1449 if hasattr(self, 'attachment_id') and self.attachment_id is not None: 1450 _dict['attachment_id'] = self.attachment_id 1451 if hasattr(self, 'rule_id') and self.rule_id is not None: 1452 _dict['rule_id'] = self.rule_id 1453 if hasattr(self, 'account_id') and self.account_id is not None: 1454 _dict['account_id'] = self.account_id 1455 if hasattr(self, 'included_scope') and self.included_scope is not None: 1456 _dict['included_scope'] = self.included_scope.to_dict() 1457 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 1458 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 1459 return _dict
Return a json dictionary representing this model.
1479class RuleAttachmentList(): 1480 """ 1481 A list of attachments. 1482 1483 :attr int offset: The requested offset for the returned items. 1484 :attr int limit: The requested limit for the returned items. 1485 :attr int total_count: The total number of available items. 1486 :attr Link first: The first page of available items. 1487 :attr Link last: The last page of available items. 1488 :attr List[RuleAttachment] attachments: 1489 """ 1490 1491 def __init__(self, 1492 offset: int, 1493 limit: int, 1494 total_count: int, 1495 first: 'Link', 1496 last: 'Link', 1497 attachments: List['RuleAttachment']) -> None: 1498 """ 1499 Initialize a RuleAttachmentList object. 1500 1501 :param int offset: The requested offset for the returned items. 1502 :param int limit: The requested limit for the returned items. 1503 :param int total_count: The total number of available items. 1504 :param Link first: The first page of available items. 1505 :param Link last: The last page of available items. 1506 :param List[RuleAttachment] attachments: 1507 """ 1508 self.offset = offset 1509 self.limit = limit 1510 self.total_count = total_count 1511 self.first = first 1512 self.last = last 1513 self.attachments = attachments 1514 1515 @classmethod 1516 def from_dict(cls, _dict: Dict) -> 'RuleAttachmentList': 1517 """Initialize a RuleAttachmentList object from a json dictionary.""" 1518 args = {} 1519 if 'offset' in _dict: 1520 args['offset'] = _dict.get('offset') 1521 else: 1522 raise ValueError('Required property \'offset\' not present in RuleAttachmentList JSON') 1523 if 'limit' in _dict: 1524 args['limit'] = _dict.get('limit') 1525 else: 1526 raise ValueError('Required property \'limit\' not present in RuleAttachmentList JSON') 1527 if 'total_count' in _dict: 1528 args['total_count'] = _dict.get('total_count') 1529 else: 1530 raise ValueError('Required property \'total_count\' not present in RuleAttachmentList JSON') 1531 if 'first' in _dict: 1532 args['first'] = Link.from_dict(_dict.get('first')) 1533 else: 1534 raise ValueError('Required property \'first\' not present in RuleAttachmentList JSON') 1535 if 'last' in _dict: 1536 args['last'] = Link.from_dict(_dict.get('last')) 1537 else: 1538 raise ValueError('Required property \'last\' not present in RuleAttachmentList JSON') 1539 if 'attachments' in _dict: 1540 args['attachments'] = [RuleAttachment.from_dict(x) for x in _dict.get('attachments')] 1541 else: 1542 raise ValueError('Required property \'attachments\' not present in RuleAttachmentList JSON') 1543 return cls(**args) 1544 1545 @classmethod 1546 def _from_dict(cls, _dict): 1547 """Initialize a RuleAttachmentList object from a json dictionary.""" 1548 return cls.from_dict(_dict) 1549 1550 def to_dict(self) -> Dict: 1551 """Return a json dictionary representing this model.""" 1552 _dict = {} 1553 if hasattr(self, 'offset') and self.offset is not None: 1554 _dict['offset'] = self.offset 1555 if hasattr(self, 'limit') and self.limit is not None: 1556 _dict['limit'] = self.limit 1557 if hasattr(self, 'total_count') and self.total_count is not None: 1558 _dict['total_count'] = self.total_count 1559 if hasattr(self, 'first') and self.first is not None: 1560 _dict['first'] = self.first.to_dict() 1561 if hasattr(self, 'last') and self.last is not None: 1562 _dict['last'] = self.last.to_dict() 1563 if hasattr(self, 'attachments') and self.attachments is not None: 1564 _dict['attachments'] = [x.to_dict() for x in self.attachments] 1565 return _dict 1566 1567 def _to_dict(self): 1568 """Return a json dictionary representing this model.""" 1569 return self.to_dict() 1570 1571 def __str__(self) -> str: 1572 """Return a `str` version of this RuleAttachmentList object.""" 1573 return json.dumps(self.to_dict(), indent=2) 1574 1575 def __eq__(self, other: 'RuleAttachmentList') -> bool: 1576 """Return `true` when self and other are equal, false otherwise.""" 1577 if not isinstance(other, self.__class__): 1578 return False 1579 return self.__dict__ == other.__dict__ 1580 1581 def __ne__(self, other: 'RuleAttachmentList') -> bool: 1582 """Return `true` when self and other are not equal, false otherwise.""" 1583 return not self == other
A list of attachments.
:attr int offset: The requested offset for the returned items. :attr int limit: The requested limit for the returned items. :attr int total_count: The total number of available items. :attr Link first: The first page of available items. :attr Link last: The last page of available items. :attr List[RuleAttachment] attachments:
1491 def __init__(self, 1492 offset: int, 1493 limit: int, 1494 total_count: int, 1495 first: 'Link', 1496 last: 'Link', 1497 attachments: List['RuleAttachment']) -> None: 1498 """ 1499 Initialize a RuleAttachmentList object. 1500 1501 :param int offset: The requested offset for the returned items. 1502 :param int limit: The requested limit for the returned items. 1503 :param int total_count: The total number of available items. 1504 :param Link first: The first page of available items. 1505 :param Link last: The last page of available items. 1506 :param List[RuleAttachment] attachments: 1507 """ 1508 self.offset = offset 1509 self.limit = limit 1510 self.total_count = total_count 1511 self.first = first 1512 self.last = last 1513 self.attachments = attachments
Initialize a RuleAttachmentList object.
Parameters
- int offset: The requested offset for the returned items.
- int limit: The requested limit for the returned items.
- int total_count: The total number of available items.
- Link first: The first page of available items.
- Link last: The last page of available items.
- List[RuleAttachment] attachments:
1515 @classmethod 1516 def from_dict(cls, _dict: Dict) -> 'RuleAttachmentList': 1517 """Initialize a RuleAttachmentList object from a json dictionary.""" 1518 args = {} 1519 if 'offset' in _dict: 1520 args['offset'] = _dict.get('offset') 1521 else: 1522 raise ValueError('Required property \'offset\' not present in RuleAttachmentList JSON') 1523 if 'limit' in _dict: 1524 args['limit'] = _dict.get('limit') 1525 else: 1526 raise ValueError('Required property \'limit\' not present in RuleAttachmentList JSON') 1527 if 'total_count' in _dict: 1528 args['total_count'] = _dict.get('total_count') 1529 else: 1530 raise ValueError('Required property \'total_count\' not present in RuleAttachmentList JSON') 1531 if 'first' in _dict: 1532 args['first'] = Link.from_dict(_dict.get('first')) 1533 else: 1534 raise ValueError('Required property \'first\' not present in RuleAttachmentList JSON') 1535 if 'last' in _dict: 1536 args['last'] = Link.from_dict(_dict.get('last')) 1537 else: 1538 raise ValueError('Required property \'last\' not present in RuleAttachmentList JSON') 1539 if 'attachments' in _dict: 1540 args['attachments'] = [RuleAttachment.from_dict(x) for x in _dict.get('attachments')] 1541 else: 1542 raise ValueError('Required property \'attachments\' not present in RuleAttachmentList JSON') 1543 return cls(**args)
Initialize a RuleAttachmentList object from a json dictionary.
1550 def to_dict(self) -> Dict: 1551 """Return a json dictionary representing this model.""" 1552 _dict = {} 1553 if hasattr(self, 'offset') and self.offset is not None: 1554 _dict['offset'] = self.offset 1555 if hasattr(self, 'limit') and self.limit is not None: 1556 _dict['limit'] = self.limit 1557 if hasattr(self, 'total_count') and self.total_count is not None: 1558 _dict['total_count'] = self.total_count 1559 if hasattr(self, 'first') and self.first is not None: 1560 _dict['first'] = self.first.to_dict() 1561 if hasattr(self, 'last') and self.last is not None: 1562 _dict['last'] = self.last.to_dict() 1563 if hasattr(self, 'attachments') and self.attachments is not None: 1564 _dict['attachments'] = [x.to_dict() for x in self.attachments] 1565 return _dict
Return a json dictionary representing this model.
1585class RuleAttachmentRequest(): 1586 """ 1587 The scopes to attach to a rule. 1588 1589 :attr str account_id: Your IBM Cloud account ID. 1590 :attr RuleScope included_scope: The extent at which the rule can be attached 1591 across your accounts. 1592 :attr List[RuleScope] excluded_scopes: (optional) The extent at which the rule 1593 can be excluded from the included scope. 1594 """ 1595 1596 def __init__(self, 1597 account_id: str, 1598 included_scope: 'RuleScope', 1599 *, 1600 excluded_scopes: List['RuleScope'] = None) -> None: 1601 """ 1602 Initialize a RuleAttachmentRequest object. 1603 1604 :param str account_id: Your IBM Cloud account ID. 1605 :param RuleScope included_scope: The extent at which the rule can be 1606 attached across your accounts. 1607 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 1608 rule can be excluded from the included scope. 1609 """ 1610 self.account_id = account_id 1611 self.included_scope = included_scope 1612 self.excluded_scopes = excluded_scopes 1613 1614 @classmethod 1615 def from_dict(cls, _dict: Dict) -> 'RuleAttachmentRequest': 1616 """Initialize a RuleAttachmentRequest object from a json dictionary.""" 1617 args = {} 1618 if 'account_id' in _dict: 1619 args['account_id'] = _dict.get('account_id') 1620 else: 1621 raise ValueError('Required property \'account_id\' not present in RuleAttachmentRequest JSON') 1622 if 'included_scope' in _dict: 1623 args['included_scope'] = RuleScope.from_dict(_dict.get('included_scope')) 1624 else: 1625 raise ValueError('Required property \'included_scope\' not present in RuleAttachmentRequest JSON') 1626 if 'excluded_scopes' in _dict: 1627 args['excluded_scopes'] = [RuleScope.from_dict(x) for x in _dict.get('excluded_scopes')] 1628 return cls(**args) 1629 1630 @classmethod 1631 def _from_dict(cls, _dict): 1632 """Initialize a RuleAttachmentRequest object from a json dictionary.""" 1633 return cls.from_dict(_dict) 1634 1635 def to_dict(self) -> Dict: 1636 """Return a json dictionary representing this model.""" 1637 _dict = {} 1638 if hasattr(self, 'account_id') and self.account_id is not None: 1639 _dict['account_id'] = self.account_id 1640 if hasattr(self, 'included_scope') and self.included_scope is not None: 1641 _dict['included_scope'] = self.included_scope.to_dict() 1642 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 1643 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 1644 return _dict 1645 1646 def _to_dict(self): 1647 """Return a json dictionary representing this model.""" 1648 return self.to_dict() 1649 1650 def __str__(self) -> str: 1651 """Return a `str` version of this RuleAttachmentRequest object.""" 1652 return json.dumps(self.to_dict(), indent=2) 1653 1654 def __eq__(self, other: 'RuleAttachmentRequest') -> bool: 1655 """Return `true` when self and other are equal, false otherwise.""" 1656 if not isinstance(other, self.__class__): 1657 return False 1658 return self.__dict__ == other.__dict__ 1659 1660 def __ne__(self, other: 'RuleAttachmentRequest') -> bool: 1661 """Return `true` when self and other are not equal, false otherwise.""" 1662 return not self == other
The scopes to attach to a rule.
:attr str account_id: Your IBM Cloud account ID. :attr RuleScope included_scope: The extent at which the rule can be attached across your accounts. :attr List[RuleScope] excluded_scopes: (optional) The extent at which the rule can be excluded from the included scope.
1596 def __init__(self, 1597 account_id: str, 1598 included_scope: 'RuleScope', 1599 *, 1600 excluded_scopes: List['RuleScope'] = None) -> None: 1601 """ 1602 Initialize a RuleAttachmentRequest object. 1603 1604 :param str account_id: Your IBM Cloud account ID. 1605 :param RuleScope included_scope: The extent at which the rule can be 1606 attached across your accounts. 1607 :param List[RuleScope] excluded_scopes: (optional) The extent at which the 1608 rule can be excluded from the included scope. 1609 """ 1610 self.account_id = account_id 1611 self.included_scope = included_scope 1612 self.excluded_scopes = excluded_scopes
Initialize a RuleAttachmentRequest object.
Parameters
- str account_id: Your IBM Cloud account ID.
- RuleScope included_scope: The extent at which the rule can be attached across your accounts.
- List[RuleScope] excluded_scopes: (optional) The extent at which the rule can be excluded from the included scope.
1614 @classmethod 1615 def from_dict(cls, _dict: Dict) -> 'RuleAttachmentRequest': 1616 """Initialize a RuleAttachmentRequest object from a json dictionary.""" 1617 args = {} 1618 if 'account_id' in _dict: 1619 args['account_id'] = _dict.get('account_id') 1620 else: 1621 raise ValueError('Required property \'account_id\' not present in RuleAttachmentRequest JSON') 1622 if 'included_scope' in _dict: 1623 args['included_scope'] = RuleScope.from_dict(_dict.get('included_scope')) 1624 else: 1625 raise ValueError('Required property \'included_scope\' not present in RuleAttachmentRequest JSON') 1626 if 'excluded_scopes' in _dict: 1627 args['excluded_scopes'] = [RuleScope.from_dict(x) for x in _dict.get('excluded_scopes')] 1628 return cls(**args)
Initialize a RuleAttachmentRequest object from a json dictionary.
1635 def to_dict(self) -> Dict: 1636 """Return a json dictionary representing this model.""" 1637 _dict = {} 1638 if hasattr(self, 'account_id') and self.account_id is not None: 1639 _dict['account_id'] = self.account_id 1640 if hasattr(self, 'included_scope') and self.included_scope is not None: 1641 _dict['included_scope'] = self.included_scope.to_dict() 1642 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 1643 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 1644 return _dict
Return a json dictionary representing this model.
1664class RuleCondition(): 1665 """ 1666 RuleCondition. 1667 1668 """ 1669 1670 def __init__(self) -> None: 1671 """ 1672 Initialize a RuleCondition object. 1673 1674 """ 1675 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 1676 ", ".join(['RuleConditionSingleProperty', 'RuleConditionOrLvl2', 'RuleConditionAndLvl2'])) 1677 raise Exception(msg)
RuleCondition.
1670 def __init__(self) -> None: 1671 """ 1672 Initialize a RuleCondition object. 1673 1674 """ 1675 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 1676 ", ".join(['RuleConditionSingleProperty', 'RuleConditionOrLvl2', 'RuleConditionAndLvl2'])) 1677 raise Exception(msg)
Initialize a RuleCondition object.
1679class RuleList(): 1680 """ 1681 A list of rules. 1682 1683 :attr int offset: The requested offset for the returned items. 1684 :attr int limit: The requested limit for the returned items. 1685 :attr int total_count: The total number of available items. 1686 :attr Link first: The first page of available items. 1687 :attr Link last: The last page of available items. 1688 :attr List[Rule] rules: An array of rules. 1689 """ 1690 1691 def __init__(self, 1692 offset: int, 1693 limit: int, 1694 total_count: int, 1695 first: 'Link', 1696 last: 'Link', 1697 rules: List['Rule']) -> None: 1698 """ 1699 Initialize a RuleList object. 1700 1701 :param int offset: The requested offset for the returned items. 1702 :param int limit: The requested limit for the returned items. 1703 :param int total_count: The total number of available items. 1704 :param Link first: The first page of available items. 1705 :param Link last: The last page of available items. 1706 :param List[Rule] rules: An array of rules. 1707 """ 1708 self.offset = offset 1709 self.limit = limit 1710 self.total_count = total_count 1711 self.first = first 1712 self.last = last 1713 self.rules = rules 1714 1715 @classmethod 1716 def from_dict(cls, _dict: Dict) -> 'RuleList': 1717 """Initialize a RuleList object from a json dictionary.""" 1718 args = {} 1719 if 'offset' in _dict: 1720 args['offset'] = _dict.get('offset') 1721 else: 1722 raise ValueError('Required property \'offset\' not present in RuleList JSON') 1723 if 'limit' in _dict: 1724 args['limit'] = _dict.get('limit') 1725 else: 1726 raise ValueError('Required property \'limit\' not present in RuleList JSON') 1727 if 'total_count' in _dict: 1728 args['total_count'] = _dict.get('total_count') 1729 else: 1730 raise ValueError('Required property \'total_count\' not present in RuleList JSON') 1731 if 'first' in _dict: 1732 args['first'] = Link.from_dict(_dict.get('first')) 1733 else: 1734 raise ValueError('Required property \'first\' not present in RuleList JSON') 1735 if 'last' in _dict: 1736 args['last'] = Link.from_dict(_dict.get('last')) 1737 else: 1738 raise ValueError('Required property \'last\' not present in RuleList JSON') 1739 if 'rules' in _dict: 1740 args['rules'] = [Rule.from_dict(x) for x in _dict.get('rules')] 1741 else: 1742 raise ValueError('Required property \'rules\' not present in RuleList JSON') 1743 return cls(**args) 1744 1745 @classmethod 1746 def _from_dict(cls, _dict): 1747 """Initialize a RuleList object from a json dictionary.""" 1748 return cls.from_dict(_dict) 1749 1750 def to_dict(self) -> Dict: 1751 """Return a json dictionary representing this model.""" 1752 _dict = {} 1753 if hasattr(self, 'offset') and self.offset is not None: 1754 _dict['offset'] = self.offset 1755 if hasattr(self, 'limit') and self.limit is not None: 1756 _dict['limit'] = self.limit 1757 if hasattr(self, 'total_count') and self.total_count is not None: 1758 _dict['total_count'] = self.total_count 1759 if hasattr(self, 'first') and self.first is not None: 1760 _dict['first'] = self.first.to_dict() 1761 if hasattr(self, 'last') and self.last is not None: 1762 _dict['last'] = self.last.to_dict() 1763 if hasattr(self, 'rules') and self.rules is not None: 1764 _dict['rules'] = [x.to_dict() for x in self.rules] 1765 return _dict 1766 1767 def _to_dict(self): 1768 """Return a json dictionary representing this model.""" 1769 return self.to_dict() 1770 1771 def __str__(self) -> str: 1772 """Return a `str` version of this RuleList object.""" 1773 return json.dumps(self.to_dict(), indent=2) 1774 1775 def __eq__(self, other: 'RuleList') -> bool: 1776 """Return `true` when self and other are equal, false otherwise.""" 1777 if not isinstance(other, self.__class__): 1778 return False 1779 return self.__dict__ == other.__dict__ 1780 1781 def __ne__(self, other: 'RuleList') -> bool: 1782 """Return `true` when self and other are not equal, false otherwise.""" 1783 return not self == other
A list of rules.
:attr int offset: The requested offset for the returned items. :attr int limit: The requested limit for the returned items. :attr int total_count: The total number of available items. :attr Link first: The first page of available items. :attr Link last: The last page of available items. :attr List[Rule] rules: An array of rules.
1691 def __init__(self, 1692 offset: int, 1693 limit: int, 1694 total_count: int, 1695 first: 'Link', 1696 last: 'Link', 1697 rules: List['Rule']) -> None: 1698 """ 1699 Initialize a RuleList object. 1700 1701 :param int offset: The requested offset for the returned items. 1702 :param int limit: The requested limit for the returned items. 1703 :param int total_count: The total number of available items. 1704 :param Link first: The first page of available items. 1705 :param Link last: The last page of available items. 1706 :param List[Rule] rules: An array of rules. 1707 """ 1708 self.offset = offset 1709 self.limit = limit 1710 self.total_count = total_count 1711 self.first = first 1712 self.last = last 1713 self.rules = rules
Initialize a RuleList object.
Parameters
- int offset: The requested offset for the returned items.
- int limit: The requested limit for the returned items.
- int total_count: The total number of available items.
- Link first: The first page of available items.
- Link last: The last page of available items.
- List[Rule] rules: An array of rules.
1715 @classmethod 1716 def from_dict(cls, _dict: Dict) -> 'RuleList': 1717 """Initialize a RuleList object from a json dictionary.""" 1718 args = {} 1719 if 'offset' in _dict: 1720 args['offset'] = _dict.get('offset') 1721 else: 1722 raise ValueError('Required property \'offset\' not present in RuleList JSON') 1723 if 'limit' in _dict: 1724 args['limit'] = _dict.get('limit') 1725 else: 1726 raise ValueError('Required property \'limit\' not present in RuleList JSON') 1727 if 'total_count' in _dict: 1728 args['total_count'] = _dict.get('total_count') 1729 else: 1730 raise ValueError('Required property \'total_count\' not present in RuleList JSON') 1731 if 'first' in _dict: 1732 args['first'] = Link.from_dict(_dict.get('first')) 1733 else: 1734 raise ValueError('Required property \'first\' not present in RuleList JSON') 1735 if 'last' in _dict: 1736 args['last'] = Link.from_dict(_dict.get('last')) 1737 else: 1738 raise ValueError('Required property \'last\' not present in RuleList JSON') 1739 if 'rules' in _dict: 1740 args['rules'] = [Rule.from_dict(x) for x in _dict.get('rules')] 1741 else: 1742 raise ValueError('Required property \'rules\' not present in RuleList JSON') 1743 return cls(**args)
Initialize a RuleList object from a json dictionary.
1750 def to_dict(self) -> Dict: 1751 """Return a json dictionary representing this model.""" 1752 _dict = {} 1753 if hasattr(self, 'offset') and self.offset is not None: 1754 _dict['offset'] = self.offset 1755 if hasattr(self, 'limit') and self.limit is not None: 1756 _dict['limit'] = self.limit 1757 if hasattr(self, 'total_count') and self.total_count is not None: 1758 _dict['total_count'] = self.total_count 1759 if hasattr(self, 'first') and self.first is not None: 1760 _dict['first'] = self.first.to_dict() 1761 if hasattr(self, 'last') and self.last is not None: 1762 _dict['last'] = self.last.to_dict() 1763 if hasattr(self, 'rules') and self.rules is not None: 1764 _dict['rules'] = [x.to_dict() for x in self.rules] 1765 return _dict
Return a json dictionary representing this model.
1785class RuleRequest(): 1786 """ 1787 Properties that you can associate with a rule. 1788 1789 :attr str account_id: (optional) Your IBM Cloud account ID. 1790 :attr str name: A human-readable alias to assign to your rule. 1791 :attr str description: An extended description of your rule. 1792 :attr str rule_type: (optional) The type of rule. Rules that you create are 1793 `user_defined`. 1794 :attr TargetResource target: The properties that describe the resource that you 1795 want to target 1796 with the rule or template. 1797 :attr RuleRequiredConfig required_config: 1798 :attr List[EnforcementAction] enforcement_actions: The actions that the service 1799 must run on your behalf when a request to create or modify the target resource 1800 does not comply with your conditions. 1801 :attr List[str] labels: (optional) Labels that you can use to group and search 1802 for similar rules, such as those that help you to meet a specific organization 1803 guideline. 1804 """ 1805 1806 def __init__(self, 1807 name: str, 1808 description: str, 1809 target: 'TargetResource', 1810 required_config: 'RuleRequiredConfig', 1811 enforcement_actions: List['EnforcementAction'], 1812 *, 1813 account_id: str = None, 1814 rule_type: str = None, 1815 labels: List[str] = None) -> None: 1816 """ 1817 Initialize a RuleRequest object. 1818 1819 :param str name: A human-readable alias to assign to your rule. 1820 :param str description: An extended description of your rule. 1821 :param TargetResource target: The properties that describe the resource 1822 that you want to target 1823 with the rule or template. 1824 :param RuleRequiredConfig required_config: 1825 :param List[EnforcementAction] enforcement_actions: The actions that the 1826 service must run on your behalf when a request to create or modify the 1827 target resource does not comply with your conditions. 1828 :param str account_id: (optional) Your IBM Cloud account ID. 1829 :param str rule_type: (optional) The type of rule. Rules that you create 1830 are `user_defined`. 1831 :param List[str] labels: (optional) Labels that you can use to group and 1832 search for similar rules, such as those that help you to meet a specific 1833 organization guideline. 1834 """ 1835 self.account_id = account_id 1836 self.name = name 1837 self.description = description 1838 self.rule_type = rule_type 1839 self.target = target 1840 self.required_config = required_config 1841 self.enforcement_actions = enforcement_actions 1842 self.labels = labels 1843 1844 @classmethod 1845 def from_dict(cls, _dict: Dict) -> 'RuleRequest': 1846 """Initialize a RuleRequest object from a json dictionary.""" 1847 args = {} 1848 if 'account_id' in _dict: 1849 args['account_id'] = _dict.get('account_id') 1850 if 'name' in _dict: 1851 args['name'] = _dict.get('name') 1852 else: 1853 raise ValueError('Required property \'name\' not present in RuleRequest JSON') 1854 if 'description' in _dict: 1855 args['description'] = _dict.get('description') 1856 else: 1857 raise ValueError('Required property \'description\' not present in RuleRequest JSON') 1858 if 'rule_type' in _dict: 1859 args['rule_type'] = _dict.get('rule_type') 1860 if 'target' in _dict: 1861 args['target'] = TargetResource.from_dict(_dict.get('target')) 1862 else: 1863 raise ValueError('Required property \'target\' not present in RuleRequest JSON') 1864 if 'required_config' in _dict: 1865 args['required_config'] = _dict.get('required_config') 1866 else: 1867 raise ValueError('Required property \'required_config\' not present in RuleRequest JSON') 1868 if 'enforcement_actions' in _dict: 1869 args['enforcement_actions'] = [EnforcementAction.from_dict(x) for x in _dict.get('enforcement_actions')] 1870 else: 1871 raise ValueError('Required property \'enforcement_actions\' not present in RuleRequest JSON') 1872 if 'labels' in _dict: 1873 args['labels'] = _dict.get('labels') 1874 return cls(**args) 1875 1876 @classmethod 1877 def _from_dict(cls, _dict): 1878 """Initialize a RuleRequest object from a json dictionary.""" 1879 return cls.from_dict(_dict) 1880 1881 def to_dict(self) -> Dict: 1882 """Return a json dictionary representing this model.""" 1883 _dict = {} 1884 if hasattr(self, 'account_id') and self.account_id is not None: 1885 _dict['account_id'] = self.account_id 1886 if hasattr(self, 'name') and self.name is not None: 1887 _dict['name'] = self.name 1888 if hasattr(self, 'description') and self.description is not None: 1889 _dict['description'] = self.description 1890 if hasattr(self, 'rule_type') and self.rule_type is not None: 1891 _dict['rule_type'] = self.rule_type 1892 if hasattr(self, 'target') and self.target is not None: 1893 _dict['target'] = self.target.to_dict() 1894 if hasattr(self, 'required_config') and self.required_config is not None: 1895 if isinstance(self.required_config, dict): 1896 _dict['required_config'] = self.required_config 1897 else: 1898 _dict['required_config'] = self.required_config.to_dict() 1899 if hasattr(self, 'enforcement_actions') and self.enforcement_actions is not None: 1900 _dict['enforcement_actions'] = [x.to_dict() for x in self.enforcement_actions] 1901 if hasattr(self, 'labels') and self.labels is not None: 1902 _dict['labels'] = self.labels 1903 return _dict 1904 1905 def _to_dict(self): 1906 """Return a json dictionary representing this model.""" 1907 return self.to_dict() 1908 1909 def __str__(self) -> str: 1910 """Return a `str` version of this RuleRequest object.""" 1911 return json.dumps(self.to_dict(), indent=2) 1912 1913 def __eq__(self, other: 'RuleRequest') -> bool: 1914 """Return `true` when self and other are equal, false otherwise.""" 1915 if not isinstance(other, self.__class__): 1916 return False 1917 return self.__dict__ == other.__dict__ 1918 1919 def __ne__(self, other: 'RuleRequest') -> bool: 1920 """Return `true` when self and other are not equal, false otherwise.""" 1921 return not self == other 1922 1923 class RuleTypeEnum(str, Enum): 1924 """ 1925 The type of rule. Rules that you create are `user_defined`. 1926 """ 1927 USER_DEFINED = 'user_defined'
Properties that you can associate with a rule.
:attr str account_id: (optional) Your IBM Cloud account ID.
:attr str name: A human-readable alias to assign to your rule.
:attr str description: An extended description of your rule.
:attr str rule_type: (optional) The type of rule. Rules that you create are
user_defined.
:attr TargetResource target: The properties that describe the resource that you
want to target
with the rule or template.
:attr RuleRequiredConfig required_config:
:attr List[EnforcementAction] enforcement_actions: The actions that the service
must run on your behalf when a request to create or modify the target resource
does not comply with your conditions.
:attr List[str] labels: (optional) Labels that you can use to group and search
for similar rules, such as those that help you to meet a specific organization
guideline.
1806 def __init__(self, 1807 name: str, 1808 description: str, 1809 target: 'TargetResource', 1810 required_config: 'RuleRequiredConfig', 1811 enforcement_actions: List['EnforcementAction'], 1812 *, 1813 account_id: str = None, 1814 rule_type: str = None, 1815 labels: List[str] = None) -> None: 1816 """ 1817 Initialize a RuleRequest object. 1818 1819 :param str name: A human-readable alias to assign to your rule. 1820 :param str description: An extended description of your rule. 1821 :param TargetResource target: The properties that describe the resource 1822 that you want to target 1823 with the rule or template. 1824 :param RuleRequiredConfig required_config: 1825 :param List[EnforcementAction] enforcement_actions: The actions that the 1826 service must run on your behalf when a request to create or modify the 1827 target resource does not comply with your conditions. 1828 :param str account_id: (optional) Your IBM Cloud account ID. 1829 :param str rule_type: (optional) The type of rule. Rules that you create 1830 are `user_defined`. 1831 :param List[str] labels: (optional) Labels that you can use to group and 1832 search for similar rules, such as those that help you to meet a specific 1833 organization guideline. 1834 """ 1835 self.account_id = account_id 1836 self.name = name 1837 self.description = description 1838 self.rule_type = rule_type 1839 self.target = target 1840 self.required_config = required_config 1841 self.enforcement_actions = enforcement_actions 1842 self.labels = labels
Initialize a RuleRequest object.
Parameters
- str name: A human-readable alias to assign to your rule.
- str description: An extended description of your rule.
- TargetResource target: The properties that describe the resource that you want to target with the rule or template.
- RuleRequiredConfig required_config:
- List[EnforcementAction] enforcement_actions: The actions that the service must run on your behalf when a request to create or modify the target resource does not comply with your conditions.
- str account_id: (optional) Your IBM Cloud account ID.
- str rule_type: (optional) The type of rule. Rules that you create
are
user_defined. - List[str] labels: (optional) Labels that you can use to group and search for similar rules, such as those that help you to meet a specific organization guideline.
1844 @classmethod 1845 def from_dict(cls, _dict: Dict) -> 'RuleRequest': 1846 """Initialize a RuleRequest object from a json dictionary.""" 1847 args = {} 1848 if 'account_id' in _dict: 1849 args['account_id'] = _dict.get('account_id') 1850 if 'name' in _dict: 1851 args['name'] = _dict.get('name') 1852 else: 1853 raise ValueError('Required property \'name\' not present in RuleRequest JSON') 1854 if 'description' in _dict: 1855 args['description'] = _dict.get('description') 1856 else: 1857 raise ValueError('Required property \'description\' not present in RuleRequest JSON') 1858 if 'rule_type' in _dict: 1859 args['rule_type'] = _dict.get('rule_type') 1860 if 'target' in _dict: 1861 args['target'] = TargetResource.from_dict(_dict.get('target')) 1862 else: 1863 raise ValueError('Required property \'target\' not present in RuleRequest JSON') 1864 if 'required_config' in _dict: 1865 args['required_config'] = _dict.get('required_config') 1866 else: 1867 raise ValueError('Required property \'required_config\' not present in RuleRequest JSON') 1868 if 'enforcement_actions' in _dict: 1869 args['enforcement_actions'] = [EnforcementAction.from_dict(x) for x in _dict.get('enforcement_actions')] 1870 else: 1871 raise ValueError('Required property \'enforcement_actions\' not present in RuleRequest JSON') 1872 if 'labels' in _dict: 1873 args['labels'] = _dict.get('labels') 1874 return cls(**args)
Initialize a RuleRequest object from a json dictionary.
1881 def to_dict(self) -> Dict: 1882 """Return a json dictionary representing this model.""" 1883 _dict = {} 1884 if hasattr(self, 'account_id') and self.account_id is not None: 1885 _dict['account_id'] = self.account_id 1886 if hasattr(self, 'name') and self.name is not None: 1887 _dict['name'] = self.name 1888 if hasattr(self, 'description') and self.description is not None: 1889 _dict['description'] = self.description 1890 if hasattr(self, 'rule_type') and self.rule_type is not None: 1891 _dict['rule_type'] = self.rule_type 1892 if hasattr(self, 'target') and self.target is not None: 1893 _dict['target'] = self.target.to_dict() 1894 if hasattr(self, 'required_config') and self.required_config is not None: 1895 if isinstance(self.required_config, dict): 1896 _dict['required_config'] = self.required_config 1897 else: 1898 _dict['required_config'] = self.required_config.to_dict() 1899 if hasattr(self, 'enforcement_actions') and self.enforcement_actions is not None: 1900 _dict['enforcement_actions'] = [x.to_dict() for x in self.enforcement_actions] 1901 if hasattr(self, 'labels') and self.labels is not None: 1902 _dict['labels'] = self.labels 1903 return _dict
Return a json dictionary representing this model.
1373 class RuleTypeEnum(str, Enum): 1374 """ 1375 The type of rule. Rules that you create are `user_defined`. 1376 """ 1377 USER_DEFINED = 'user_defined'
The type of rule. Rules that you create are user_defined.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
1930class RuleRequiredConfig(): 1931 """ 1932 RuleRequiredConfig. 1933 1934 """ 1935 1936 def __init__(self) -> None: 1937 """ 1938 Initialize a RuleRequiredConfig object. 1939 1940 """ 1941 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 1942 ", ".join(['RuleRequiredConfigSingleProperty', 'RuleRequiredConfigMultipleProperties'])) 1943 raise Exception(msg)
RuleRequiredConfig.
1936 def __init__(self) -> None: 1937 """ 1938 Initialize a RuleRequiredConfig object. 1939 1940 """ 1941 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 1942 ", ".join(['RuleRequiredConfigSingleProperty', 'RuleRequiredConfigMultipleProperties'])) 1943 raise Exception(msg)
Initialize a RuleRequiredConfig object.
1945class RuleResponseError(): 1946 """ 1947 RuleResponseError. 1948 1949 :attr str code: Specifies the problem that caused the error. 1950 :attr str message: Describes the problem. 1951 """ 1952 1953 def __init__(self, 1954 code: str, 1955 message: str) -> None: 1956 """ 1957 Initialize a RuleResponseError object. 1958 1959 :param str code: Specifies the problem that caused the error. 1960 :param str message: Describes the problem. 1961 """ 1962 self.code = code 1963 self.message = message 1964 1965 @classmethod 1966 def from_dict(cls, _dict: Dict) -> 'RuleResponseError': 1967 """Initialize a RuleResponseError object from a json dictionary.""" 1968 args = {} 1969 if 'code' in _dict: 1970 args['code'] = _dict.get('code') 1971 else: 1972 raise ValueError('Required property \'code\' not present in RuleResponseError JSON') 1973 if 'message' in _dict: 1974 args['message'] = _dict.get('message') 1975 else: 1976 raise ValueError('Required property \'message\' not present in RuleResponseError JSON') 1977 return cls(**args) 1978 1979 @classmethod 1980 def _from_dict(cls, _dict): 1981 """Initialize a RuleResponseError object from a json dictionary.""" 1982 return cls.from_dict(_dict) 1983 1984 def to_dict(self) -> Dict: 1985 """Return a json dictionary representing this model.""" 1986 _dict = {} 1987 if hasattr(self, 'code') and self.code is not None: 1988 _dict['code'] = self.code 1989 if hasattr(self, 'message') and self.message is not None: 1990 _dict['message'] = self.message 1991 return _dict 1992 1993 def _to_dict(self): 1994 """Return a json dictionary representing this model.""" 1995 return self.to_dict() 1996 1997 def __str__(self) -> str: 1998 """Return a `str` version of this RuleResponseError object.""" 1999 return json.dumps(self.to_dict(), indent=2) 2000 2001 def __eq__(self, other: 'RuleResponseError') -> bool: 2002 """Return `true` when self and other are equal, false otherwise.""" 2003 if not isinstance(other, self.__class__): 2004 return False 2005 return self.__dict__ == other.__dict__ 2006 2007 def __ne__(self, other: 'RuleResponseError') -> bool: 2008 """Return `true` when self and other are not equal, false otherwise.""" 2009 return not self == other
RuleResponseError.
:attr str code: Specifies the problem that caused the error. :attr str message: Describes the problem.
1953 def __init__(self, 1954 code: str, 1955 message: str) -> None: 1956 """ 1957 Initialize a RuleResponseError object. 1958 1959 :param str code: Specifies the problem that caused the error. 1960 :param str message: Describes the problem. 1961 """ 1962 self.code = code 1963 self.message = message
Initialize a RuleResponseError object.
Parameters
- str code: Specifies the problem that caused the error.
- str message: Describes the problem.
1965 @classmethod 1966 def from_dict(cls, _dict: Dict) -> 'RuleResponseError': 1967 """Initialize a RuleResponseError object from a json dictionary.""" 1968 args = {} 1969 if 'code' in _dict: 1970 args['code'] = _dict.get('code') 1971 else: 1972 raise ValueError('Required property \'code\' not present in RuleResponseError JSON') 1973 if 'message' in _dict: 1974 args['message'] = _dict.get('message') 1975 else: 1976 raise ValueError('Required property \'message\' not present in RuleResponseError JSON') 1977 return cls(**args)
Initialize a RuleResponseError object from a json dictionary.
1984 def to_dict(self) -> Dict: 1985 """Return a json dictionary representing this model.""" 1986 _dict = {} 1987 if hasattr(self, 'code') and self.code is not None: 1988 _dict['code'] = self.code 1989 if hasattr(self, 'message') and self.message is not None: 1990 _dict['message'] = self.message 1991 return _dict
Return a json dictionary representing this model.
2011class RuleScope(): 2012 """ 2013 The extent at which the rule can be attached across your accounts. 2014 2015 :attr str note: (optional) A short description or alias to assign to the scope. 2016 :attr str scope_id: The ID of the scope, such as an enterprise, account, or 2017 account group, that you want to evaluate. 2018 :attr str scope_type: The type of scope that you want to evaluate. 2019 """ 2020 2021 def __init__(self, 2022 scope_id: str, 2023 scope_type: str, 2024 *, 2025 note: str = None) -> None: 2026 """ 2027 Initialize a RuleScope object. 2028 2029 :param str scope_id: The ID of the scope, such as an enterprise, account, 2030 or account group, that you want to evaluate. 2031 :param str scope_type: The type of scope that you want to evaluate. 2032 :param str note: (optional) A short description or alias to assign to the 2033 scope. 2034 """ 2035 self.note = note 2036 self.scope_id = scope_id 2037 self.scope_type = scope_type 2038 2039 @classmethod 2040 def from_dict(cls, _dict: Dict) -> 'RuleScope': 2041 """Initialize a RuleScope object from a json dictionary.""" 2042 args = {} 2043 if 'note' in _dict: 2044 args['note'] = _dict.get('note') 2045 if 'scope_id' in _dict: 2046 args['scope_id'] = _dict.get('scope_id') 2047 else: 2048 raise ValueError('Required property \'scope_id\' not present in RuleScope JSON') 2049 if 'scope_type' in _dict: 2050 args['scope_type'] = _dict.get('scope_type') 2051 else: 2052 raise ValueError('Required property \'scope_type\' not present in RuleScope JSON') 2053 return cls(**args) 2054 2055 @classmethod 2056 def _from_dict(cls, _dict): 2057 """Initialize a RuleScope object from a json dictionary.""" 2058 return cls.from_dict(_dict) 2059 2060 def to_dict(self) -> Dict: 2061 """Return a json dictionary representing this model.""" 2062 _dict = {} 2063 if hasattr(self, 'note') and self.note is not None: 2064 _dict['note'] = self.note 2065 if hasattr(self, 'scope_id') and self.scope_id is not None: 2066 _dict['scope_id'] = self.scope_id 2067 if hasattr(self, 'scope_type') and self.scope_type is not None: 2068 _dict['scope_type'] = self.scope_type 2069 return _dict 2070 2071 def _to_dict(self): 2072 """Return a json dictionary representing this model.""" 2073 return self.to_dict() 2074 2075 def __str__(self) -> str: 2076 """Return a `str` version of this RuleScope object.""" 2077 return json.dumps(self.to_dict(), indent=2) 2078 2079 def __eq__(self, other: 'RuleScope') -> bool: 2080 """Return `true` when self and other are equal, false otherwise.""" 2081 if not isinstance(other, self.__class__): 2082 return False 2083 return self.__dict__ == other.__dict__ 2084 2085 def __ne__(self, other: 'RuleScope') -> bool: 2086 """Return `true` when self and other are not equal, false otherwise.""" 2087 return not self == other 2088 2089 class ScopeTypeEnum(str, Enum): 2090 """ 2091 The type of scope that you want to evaluate. 2092 """ 2093 ENTERPRISE = 'enterprise' 2094 ENTERPRISE_ACCOUNT_GROUP = 'enterprise.account_group' 2095 ENTERPRISE_ACCOUNT = 'enterprise.account' 2096 ACCOUNT = 'account' 2097 ACCOUNT_RESOURCE_GROUP = 'account.resource_group'
The extent at which the rule can be attached across your accounts.
:attr str note: (optional) A short description or alias to assign to the scope. :attr str scope_id: The ID of the scope, such as an enterprise, account, or account group, that you want to evaluate. :attr str scope_type: The type of scope that you want to evaluate.
2021 def __init__(self, 2022 scope_id: str, 2023 scope_type: str, 2024 *, 2025 note: str = None) -> None: 2026 """ 2027 Initialize a RuleScope object. 2028 2029 :param str scope_id: The ID of the scope, such as an enterprise, account, 2030 or account group, that you want to evaluate. 2031 :param str scope_type: The type of scope that you want to evaluate. 2032 :param str note: (optional) A short description or alias to assign to the 2033 scope. 2034 """ 2035 self.note = note 2036 self.scope_id = scope_id 2037 self.scope_type = scope_type
Initialize a RuleScope object.
Parameters
- str scope_id: The ID of the scope, such as an enterprise, account, or account group, that you want to evaluate.
- str scope_type: The type of scope that you want to evaluate.
- str note: (optional) A short description or alias to assign to the scope.
2039 @classmethod 2040 def from_dict(cls, _dict: Dict) -> 'RuleScope': 2041 """Initialize a RuleScope object from a json dictionary.""" 2042 args = {} 2043 if 'note' in _dict: 2044 args['note'] = _dict.get('note') 2045 if 'scope_id' in _dict: 2046 args['scope_id'] = _dict.get('scope_id') 2047 else: 2048 raise ValueError('Required property \'scope_id\' not present in RuleScope JSON') 2049 if 'scope_type' in _dict: 2050 args['scope_type'] = _dict.get('scope_type') 2051 else: 2052 raise ValueError('Required property \'scope_type\' not present in RuleScope JSON') 2053 return cls(**args)
Initialize a RuleScope object from a json dictionary.
2060 def to_dict(self) -> Dict: 2061 """Return a json dictionary representing this model.""" 2062 _dict = {} 2063 if hasattr(self, 'note') and self.note is not None: 2064 _dict['note'] = self.note 2065 if hasattr(self, 'scope_id') and self.scope_id is not None: 2066 _dict['scope_id'] = self.scope_id 2067 if hasattr(self, 'scope_type') and self.scope_type is not None: 2068 _dict['scope_type'] = self.scope_type 2069 return _dict
Return a json dictionary representing this model.
2089 class ScopeTypeEnum(str, Enum): 2090 """ 2091 The type of scope that you want to evaluate. 2092 """ 2093 ENTERPRISE = 'enterprise' 2094 ENTERPRISE_ACCOUNT_GROUP = 'enterprise.account_group' 2095 ENTERPRISE_ACCOUNT = 'enterprise.account' 2096 ACCOUNT = 'account' 2097 ACCOUNT_RESOURCE_GROUP = 'account.resource_group'
The type of scope that you want to evaluate.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
2100class RuleSingleProperty(): 2101 """ 2102 The requirement that must be met to determine the resource's level of compliance in 2103 accordance with the rule. 2104 To apply a single property check, define a configuration property and the desired 2105 value that you want to check against. 2106 2107 :attr str description: (optional) 2108 :attr str property: A resource configuration variable that describes the 2109 property that you want to apply to the target resource. 2110 Available options depend on the target service and resource. 2111 :attr str operator: The way in which the `property` field is compared to its 2112 value. 2113 To learn more, see the 2114 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2115 :attr str value: (optional) The way in which you want your property to be 2116 applied. 2117 Value options differ depending on the rule that you configure. If you use a 2118 boolean operator, you do not need to input a value. 2119 """ 2120 2121 def __init__(self, 2122 property: str, 2123 operator: str, 2124 *, 2125 description: str = None, 2126 value: str = None) -> None: 2127 """ 2128 Initialize a RuleSingleProperty object. 2129 2130 :param str property: A resource configuration variable that describes the 2131 property that you want to apply to the target resource. 2132 Available options depend on the target service and resource. 2133 :param str operator: The way in which the `property` field is compared to 2134 its value. 2135 To learn more, see the 2136 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2137 :param str description: (optional) 2138 :param str value: (optional) The way in which you want your property to be 2139 applied. 2140 Value options differ depending on the rule that you configure. If you use a 2141 boolean operator, you do not need to input a value. 2142 """ 2143 self.description = description 2144 self.property = property 2145 self.operator = operator 2146 self.value = value 2147 2148 @classmethod 2149 def from_dict(cls, _dict: Dict) -> 'RuleSingleProperty': 2150 """Initialize a RuleSingleProperty object from a json dictionary.""" 2151 args = {} 2152 if 'description' in _dict: 2153 args['description'] = _dict.get('description') 2154 if 'property' in _dict: 2155 args['property'] = _dict.get('property') 2156 else: 2157 raise ValueError('Required property \'property\' not present in RuleSingleProperty JSON') 2158 if 'operator' in _dict: 2159 args['operator'] = _dict.get('operator') 2160 else: 2161 raise ValueError('Required property \'operator\' not present in RuleSingleProperty JSON') 2162 if 'value' in _dict: 2163 args['value'] = _dict.get('value') 2164 return cls(**args) 2165 2166 @classmethod 2167 def _from_dict(cls, _dict): 2168 """Initialize a RuleSingleProperty object from a json dictionary.""" 2169 return cls.from_dict(_dict) 2170 2171 def to_dict(self) -> Dict: 2172 """Return a json dictionary representing this model.""" 2173 _dict = {} 2174 if hasattr(self, 'description') and self.description is not None: 2175 _dict['description'] = self.description 2176 if hasattr(self, 'property') and self.property is not None: 2177 _dict['property'] = self.property 2178 if hasattr(self, 'operator') and self.operator is not None: 2179 _dict['operator'] = self.operator 2180 if hasattr(self, 'value') and self.value is not None: 2181 _dict['value'] = self.value 2182 return _dict 2183 2184 def _to_dict(self): 2185 """Return a json dictionary representing this model.""" 2186 return self.to_dict() 2187 2188 def __str__(self) -> str: 2189 """Return a `str` version of this RuleSingleProperty object.""" 2190 return json.dumps(self.to_dict(), indent=2) 2191 2192 def __eq__(self, other: 'RuleSingleProperty') -> bool: 2193 """Return `true` when self and other are equal, false otherwise.""" 2194 if not isinstance(other, self.__class__): 2195 return False 2196 return self.__dict__ == other.__dict__ 2197 2198 def __ne__(self, other: 'RuleSingleProperty') -> bool: 2199 """Return `true` when self and other are not equal, false otherwise.""" 2200 return not self == other 2201 2202 class OperatorEnum(str, Enum): 2203 """ 2204 The way in which the `property` field is compared to its value. 2205 To learn more, see the 2206 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2207 """ 2208 IS_TRUE = 'is_true' 2209 IS_FALSE = 'is_false' 2210 IS_EMPTY = 'is_empty' 2211 IS_NOT_EMPTY = 'is_not_empty' 2212 STRING_EQUALS = 'string_equals' 2213 STRING_NOT_EQUALS = 'string_not_equals' 2214 STRING_MATCH = 'string_match' 2215 STRING_NOT_MATCH = 'string_not_match' 2216 NUM_EQUALS = 'num_equals' 2217 NUM_NOT_EQUALS = 'num_not_equals' 2218 NUM_LESS_THAN = 'num_less_than' 2219 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2220 NUM_GREATER_THAN = 'num_greater_than' 2221 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2222 IPS_IN_RANGE = 'ips_in_range' 2223 STRINGS_IN_LIST = 'strings_in_list'
The requirement that must be met to determine the resource's level of compliance in accordance with the rule. To apply a single property check, define a configuration property and the desired value that you want to check against.
:attr str description: (optional)
:attr str property: A resource configuration variable that describes the
property that you want to apply to the target resource.
Available options depend on the target service and resource.
:attr str operator: The way in which the property field is compared to its
value.
To learn more, see the
docs.
:attr str value: (optional) The way in which you want your property to be
applied.
Value options differ depending on the rule that you configure. If you use a
boolean operator, you do not need to input a value.
2121 def __init__(self, 2122 property: str, 2123 operator: str, 2124 *, 2125 description: str = None, 2126 value: str = None) -> None: 2127 """ 2128 Initialize a RuleSingleProperty object. 2129 2130 :param str property: A resource configuration variable that describes the 2131 property that you want to apply to the target resource. 2132 Available options depend on the target service and resource. 2133 :param str operator: The way in which the `property` field is compared to 2134 its value. 2135 To learn more, see the 2136 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2137 :param str description: (optional) 2138 :param str value: (optional) The way in which you want your property to be 2139 applied. 2140 Value options differ depending on the rule that you configure. If you use a 2141 boolean operator, you do not need to input a value. 2142 """ 2143 self.description = description 2144 self.property = property 2145 self.operator = operator 2146 self.value = value
Initialize a RuleSingleProperty object.
Parameters
- str property: A resource configuration variable that describes the property that you want to apply to the target resource. Available options depend on the target service and resource.
- str operator: The way in which the
propertyfield is compared to its value. To learn more, see the docs. - str description: (optional)
- str value: (optional) The way in which you want your property to be applied. Value options differ depending on the rule that you configure. If you use a boolean operator, you do not need to input a value.
2148 @classmethod 2149 def from_dict(cls, _dict: Dict) -> 'RuleSingleProperty': 2150 """Initialize a RuleSingleProperty object from a json dictionary.""" 2151 args = {} 2152 if 'description' in _dict: 2153 args['description'] = _dict.get('description') 2154 if 'property' in _dict: 2155 args['property'] = _dict.get('property') 2156 else: 2157 raise ValueError('Required property \'property\' not present in RuleSingleProperty JSON') 2158 if 'operator' in _dict: 2159 args['operator'] = _dict.get('operator') 2160 else: 2161 raise ValueError('Required property \'operator\' not present in RuleSingleProperty JSON') 2162 if 'value' in _dict: 2163 args['value'] = _dict.get('value') 2164 return cls(**args)
Initialize a RuleSingleProperty object from a json dictionary.
2171 def to_dict(self) -> Dict: 2172 """Return a json dictionary representing this model.""" 2173 _dict = {} 2174 if hasattr(self, 'description') and self.description is not None: 2175 _dict['description'] = self.description 2176 if hasattr(self, 'property') and self.property is not None: 2177 _dict['property'] = self.property 2178 if hasattr(self, 'operator') and self.operator is not None: 2179 _dict['operator'] = self.operator 2180 if hasattr(self, 'value') and self.value is not None: 2181 _dict['value'] = self.value 2182 return _dict
Return a json dictionary representing this model.
2202 class OperatorEnum(str, Enum): 2203 """ 2204 The way in which the `property` field is compared to its value. 2205 To learn more, see the 2206 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2207 """ 2208 IS_TRUE = 'is_true' 2209 IS_FALSE = 'is_false' 2210 IS_EMPTY = 'is_empty' 2211 IS_NOT_EMPTY = 'is_not_empty' 2212 STRING_EQUALS = 'string_equals' 2213 STRING_NOT_EQUALS = 'string_not_equals' 2214 STRING_MATCH = 'string_match' 2215 STRING_NOT_MATCH = 'string_not_match' 2216 NUM_EQUALS = 'num_equals' 2217 NUM_NOT_EQUALS = 'num_not_equals' 2218 NUM_LESS_THAN = 'num_less_than' 2219 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2220 NUM_GREATER_THAN = 'num_greater_than' 2221 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2222 IPS_IN_RANGE = 'ips_in_range' 2223 STRINGS_IN_LIST = 'strings_in_list'
The way in which the property field is compared to its value.
To learn more, see the
docs.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
2226class TargetResource(): 2227 """ 2228 The properties that describe the resource that you want to target with the rule or 2229 template. 2230 2231 :attr str service_name: The programmatic name of the IBM Cloud service that you 2232 want to target with the rule or template. 2233 :attr str resource_kind: The type of resource that you want to target. 2234 :attr List[TargetResourceAdditionalTargetAttributesItem] 2235 additional_target_attributes: (optional) An extra qualifier for the resource 2236 kind. When you include additional attributes, only the resources that match the 2237 definition are included in the rule or template. 2238 """ 2239 2240 def __init__(self, 2241 service_name: str, 2242 resource_kind: str, 2243 *, 2244 additional_target_attributes: List['TargetResourceAdditionalTargetAttributesItem'] = None) -> None: 2245 """ 2246 Initialize a TargetResource object. 2247 2248 :param str service_name: The programmatic name of the IBM Cloud service 2249 that you want to target with the rule or template. 2250 :param str resource_kind: The type of resource that you want to target. 2251 :param List[TargetResourceAdditionalTargetAttributesItem] 2252 additional_target_attributes: (optional) An extra qualifier for the 2253 resource kind. When you include additional attributes, only the resources 2254 that match the definition are included in the rule or template. 2255 """ 2256 self.service_name = service_name 2257 self.resource_kind = resource_kind 2258 self.additional_target_attributes = additional_target_attributes 2259 2260 @classmethod 2261 def from_dict(cls, _dict: Dict) -> 'TargetResource': 2262 """Initialize a TargetResource object from a json dictionary.""" 2263 args = {} 2264 if 'service_name' in _dict: 2265 args['service_name'] = _dict.get('service_name') 2266 else: 2267 raise ValueError('Required property \'service_name\' not present in TargetResource JSON') 2268 if 'resource_kind' in _dict: 2269 args['resource_kind'] = _dict.get('resource_kind') 2270 else: 2271 raise ValueError('Required property \'resource_kind\' not present in TargetResource JSON') 2272 if 'additional_target_attributes' in _dict: 2273 args['additional_target_attributes'] = [TargetResourceAdditionalTargetAttributesItem.from_dict(x) for x in _dict.get('additional_target_attributes')] 2274 return cls(**args) 2275 2276 @classmethod 2277 def _from_dict(cls, _dict): 2278 """Initialize a TargetResource object from a json dictionary.""" 2279 return cls.from_dict(_dict) 2280 2281 def to_dict(self) -> Dict: 2282 """Return a json dictionary representing this model.""" 2283 _dict = {} 2284 if hasattr(self, 'service_name') and self.service_name is not None: 2285 _dict['service_name'] = self.service_name 2286 if hasattr(self, 'resource_kind') and self.resource_kind is not None: 2287 _dict['resource_kind'] = self.resource_kind 2288 if hasattr(self, 'additional_target_attributes') and self.additional_target_attributes is not None: 2289 _dict['additional_target_attributes'] = [x.to_dict() for x in self.additional_target_attributes] 2290 return _dict 2291 2292 def _to_dict(self): 2293 """Return a json dictionary representing this model.""" 2294 return self.to_dict() 2295 2296 def __str__(self) -> str: 2297 """Return a `str` version of this TargetResource object.""" 2298 return json.dumps(self.to_dict(), indent=2) 2299 2300 def __eq__(self, other: 'TargetResource') -> bool: 2301 """Return `true` when self and other are equal, false otherwise.""" 2302 if not isinstance(other, self.__class__): 2303 return False 2304 return self.__dict__ == other.__dict__ 2305 2306 def __ne__(self, other: 'TargetResource') -> bool: 2307 """Return `true` when self and other are not equal, false otherwise.""" 2308 return not self == other
The properties that describe the resource that you want to target with the rule or template.
:attr str service_name: The programmatic name of the IBM Cloud service that you want to target with the rule or template. :attr str resource_kind: The type of resource that you want to target. :attr List[TargetResourceAdditionalTargetAttributesItem] additional_target_attributes: (optional) An extra qualifier for the resource kind. When you include additional attributes, only the resources that match the definition are included in the rule or template.
2240 def __init__(self, 2241 service_name: str, 2242 resource_kind: str, 2243 *, 2244 additional_target_attributes: List['TargetResourceAdditionalTargetAttributesItem'] = None) -> None: 2245 """ 2246 Initialize a TargetResource object. 2247 2248 :param str service_name: The programmatic name of the IBM Cloud service 2249 that you want to target with the rule or template. 2250 :param str resource_kind: The type of resource that you want to target. 2251 :param List[TargetResourceAdditionalTargetAttributesItem] 2252 additional_target_attributes: (optional) An extra qualifier for the 2253 resource kind. When you include additional attributes, only the resources 2254 that match the definition are included in the rule or template. 2255 """ 2256 self.service_name = service_name 2257 self.resource_kind = resource_kind 2258 self.additional_target_attributes = additional_target_attributes
Initialize a TargetResource object.
Parameters
- str service_name: The programmatic name of the IBM Cloud service that you want to target with the rule or template.
- str resource_kind: The type of resource that you want to target. :param List[TargetResourceAdditionalTargetAttributesItem] additional_target_attributes: (optional) An extra qualifier for the resource kind. When you include additional attributes, only the resources that match the definition are included in the rule or template.
2260 @classmethod 2261 def from_dict(cls, _dict: Dict) -> 'TargetResource': 2262 """Initialize a TargetResource object from a json dictionary.""" 2263 args = {} 2264 if 'service_name' in _dict: 2265 args['service_name'] = _dict.get('service_name') 2266 else: 2267 raise ValueError('Required property \'service_name\' not present in TargetResource JSON') 2268 if 'resource_kind' in _dict: 2269 args['resource_kind'] = _dict.get('resource_kind') 2270 else: 2271 raise ValueError('Required property \'resource_kind\' not present in TargetResource JSON') 2272 if 'additional_target_attributes' in _dict: 2273 args['additional_target_attributes'] = [TargetResourceAdditionalTargetAttributesItem.from_dict(x) for x in _dict.get('additional_target_attributes')] 2274 return cls(**args)
Initialize a TargetResource object from a json dictionary.
2281 def to_dict(self) -> Dict: 2282 """Return a json dictionary representing this model.""" 2283 _dict = {} 2284 if hasattr(self, 'service_name') and self.service_name is not None: 2285 _dict['service_name'] = self.service_name 2286 if hasattr(self, 'resource_kind') and self.resource_kind is not None: 2287 _dict['resource_kind'] = self.resource_kind 2288 if hasattr(self, 'additional_target_attributes') and self.additional_target_attributes is not None: 2289 _dict['additional_target_attributes'] = [x.to_dict() for x in self.additional_target_attributes] 2290 return _dict
Return a json dictionary representing this model.
2310class TargetResourceAdditionalTargetAttributesItem(): 2311 """ 2312 The attributes that are associated with a rule or template target. 2313 2314 :attr str name: The name of the additional attribute that you want to use to 2315 further qualify the target. 2316 Options differ depending on the service or resource that you are targeting with 2317 a rule or template. For more information, refer to the service documentation. 2318 :attr str value: The value that you want to apply to `name` field. 2319 Options differ depending on the rule or template that you configure. For more 2320 information, refer to the service documentation. 2321 :attr str operator: The way in which the `name` field is compared to its value. 2322 There are three types of operators: string, numeric, and boolean. 2323 """ 2324 2325 def __init__(self, 2326 name: str, 2327 value: str, 2328 operator: str) -> None: 2329 """ 2330 Initialize a TargetResourceAdditionalTargetAttributesItem object. 2331 2332 :param str name: The name of the additional attribute that you want to use 2333 to further qualify the target. 2334 Options differ depending on the service or resource that you are targeting 2335 with a rule or template. For more information, refer to the service 2336 documentation. 2337 :param str value: The value that you want to apply to `name` field. 2338 Options differ depending on the rule or template that you configure. For 2339 more information, refer to the service documentation. 2340 :param str operator: The way in which the `name` field is compared to its 2341 value. 2342 There are three types of operators: string, numeric, and boolean. 2343 """ 2344 self.name = name 2345 self.value = value 2346 self.operator = operator 2347 2348 @classmethod 2349 def from_dict(cls, _dict: Dict) -> 'TargetResourceAdditionalTargetAttributesItem': 2350 """Initialize a TargetResourceAdditionalTargetAttributesItem object from a json dictionary.""" 2351 args = {} 2352 if 'name' in _dict: 2353 args['name'] = _dict.get('name') 2354 else: 2355 raise ValueError('Required property \'name\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2356 if 'value' in _dict: 2357 args['value'] = _dict.get('value') 2358 else: 2359 raise ValueError('Required property \'value\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2360 if 'operator' in _dict: 2361 args['operator'] = _dict.get('operator') 2362 else: 2363 raise ValueError('Required property \'operator\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2364 return cls(**args) 2365 2366 @classmethod 2367 def _from_dict(cls, _dict): 2368 """Initialize a TargetResourceAdditionalTargetAttributesItem object from a json dictionary.""" 2369 return cls.from_dict(_dict) 2370 2371 def to_dict(self) -> Dict: 2372 """Return a json dictionary representing this model.""" 2373 _dict = {} 2374 if hasattr(self, 'name') and self.name is not None: 2375 _dict['name'] = self.name 2376 if hasattr(self, 'value') and self.value is not None: 2377 _dict['value'] = self.value 2378 if hasattr(self, 'operator') and self.operator is not None: 2379 _dict['operator'] = self.operator 2380 return _dict 2381 2382 def _to_dict(self): 2383 """Return a json dictionary representing this model.""" 2384 return self.to_dict() 2385 2386 def __str__(self) -> str: 2387 """Return a `str` version of this TargetResourceAdditionalTargetAttributesItem object.""" 2388 return json.dumps(self.to_dict(), indent=2) 2389 2390 def __eq__(self, other: 'TargetResourceAdditionalTargetAttributesItem') -> bool: 2391 """Return `true` when self and other are equal, false otherwise.""" 2392 if not isinstance(other, self.__class__): 2393 return False 2394 return self.__dict__ == other.__dict__ 2395 2396 def __ne__(self, other: 'TargetResourceAdditionalTargetAttributesItem') -> bool: 2397 """Return `true` when self and other are not equal, false otherwise.""" 2398 return not self == other 2399 2400 class OperatorEnum(str, Enum): 2401 """ 2402 The way in which the `name` field is compared to its value. 2403 There are three types of operators: string, numeric, and boolean. 2404 """ 2405 STRING_EQUALS = 'string_equals' 2406 STRING_NOT_EQUALS = 'string_not_equals' 2407 STRING_MATCH = 'string_match' 2408 STRING_NOT_MATCH = 'string_not_match' 2409 STRINGS_IN_LIST = 'strings_in_list' 2410 IPS_IN_RANGE = 'ips_in_range' 2411 NUM_EQUALS = 'num_equals' 2412 NUM_NOT_EQUALS = 'num_not_equals' 2413 NUM_LESS_THAN = 'num_less_than' 2414 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2415 NUM_GREATER_THAN = 'num_greater_than' 2416 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2417 IS_EMPTY = 'is_empty' 2418 IS_NOT_EMPTY = 'is_not_empty' 2419 IS_TRUE = 'is_true' 2420 IS_FALSE = 'is_false'
The attributes that are associated with a rule or template target.
:attr str name: The name of the additional attribute that you want to use to
further qualify the target.
Options differ depending on the service or resource that you are targeting with
a rule or template. For more information, refer to the service documentation.
:attr str value: The value that you want to apply to name field.
Options differ depending on the rule or template that you configure. For more
information, refer to the service documentation.
:attr str operator: The way in which the name field is compared to its value.
There are three types of operators: string, numeric, and boolean.
2325 def __init__(self, 2326 name: str, 2327 value: str, 2328 operator: str) -> None: 2329 """ 2330 Initialize a TargetResourceAdditionalTargetAttributesItem object. 2331 2332 :param str name: The name of the additional attribute that you want to use 2333 to further qualify the target. 2334 Options differ depending on the service or resource that you are targeting 2335 with a rule or template. For more information, refer to the service 2336 documentation. 2337 :param str value: The value that you want to apply to `name` field. 2338 Options differ depending on the rule or template that you configure. For 2339 more information, refer to the service documentation. 2340 :param str operator: The way in which the `name` field is compared to its 2341 value. 2342 There are three types of operators: string, numeric, and boolean. 2343 """ 2344 self.name = name 2345 self.value = value 2346 self.operator = operator
Initialize a TargetResourceAdditionalTargetAttributesItem object.
Parameters
- str name: The name of the additional attribute that you want to use to further qualify the target. Options differ depending on the service or resource that you are targeting with a rule or template. For more information, refer to the service documentation.
- str value: The value that you want to apply to
namefield. Options differ depending on the rule or template that you configure. For more information, refer to the service documentation. - str operator: The way in which the
namefield is compared to its value. There are three types of operators: string, numeric, and boolean.
2348 @classmethod 2349 def from_dict(cls, _dict: Dict) -> 'TargetResourceAdditionalTargetAttributesItem': 2350 """Initialize a TargetResourceAdditionalTargetAttributesItem object from a json dictionary.""" 2351 args = {} 2352 if 'name' in _dict: 2353 args['name'] = _dict.get('name') 2354 else: 2355 raise ValueError('Required property \'name\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2356 if 'value' in _dict: 2357 args['value'] = _dict.get('value') 2358 else: 2359 raise ValueError('Required property \'value\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2360 if 'operator' in _dict: 2361 args['operator'] = _dict.get('operator') 2362 else: 2363 raise ValueError('Required property \'operator\' not present in TargetResourceAdditionalTargetAttributesItem JSON') 2364 return cls(**args)
Initialize a TargetResourceAdditionalTargetAttributesItem object from a json dictionary.
2371 def to_dict(self) -> Dict: 2372 """Return a json dictionary representing this model.""" 2373 _dict = {} 2374 if hasattr(self, 'name') and self.name is not None: 2375 _dict['name'] = self.name 2376 if hasattr(self, 'value') and self.value is not None: 2377 _dict['value'] = self.value 2378 if hasattr(self, 'operator') and self.operator is not None: 2379 _dict['operator'] = self.operator 2380 return _dict
Return a json dictionary representing this model.
2202 class OperatorEnum(str, Enum): 2203 """ 2204 The way in which the `property` field is compared to its value. 2205 To learn more, see the 2206 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2207 """ 2208 IS_TRUE = 'is_true' 2209 IS_FALSE = 'is_false' 2210 IS_EMPTY = 'is_empty' 2211 IS_NOT_EMPTY = 'is_not_empty' 2212 STRING_EQUALS = 'string_equals' 2213 STRING_NOT_EQUALS = 'string_not_equals' 2214 STRING_MATCH = 'string_match' 2215 STRING_NOT_MATCH = 'string_not_match' 2216 NUM_EQUALS = 'num_equals' 2217 NUM_NOT_EQUALS = 'num_not_equals' 2218 NUM_LESS_THAN = 'num_less_than' 2219 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2220 NUM_GREATER_THAN = 'num_greater_than' 2221 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2222 IPS_IN_RANGE = 'ips_in_range' 2223 STRINGS_IN_LIST = 'strings_in_list'
The way in which the name field is compared to its value.
There are three types of operators: string, numeric, and boolean.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
2423class TemplateAttachment(): 2424 """ 2425 The scopes to attach to a template. 2426 2427 :attr str attachment_id: The UUID that uniquely identifies the attachment. 2428 :attr str template_id: The UUID that uniquely identifies the template. 2429 :attr str account_id: Your IBM Cloud account ID. 2430 :attr TemplateScope included_scope: The extent at which the template can be 2431 attached across your accounts. 2432 :attr List[TemplateScope] excluded_scopes: (optional) 2433 """ 2434 2435 def __init__(self, 2436 attachment_id: str, 2437 template_id: str, 2438 account_id: str, 2439 included_scope: 'TemplateScope', 2440 *, 2441 excluded_scopes: List['TemplateScope'] = None) -> None: 2442 """ 2443 Initialize a TemplateAttachment object. 2444 2445 :param str attachment_id: The UUID that uniquely identifies the attachment. 2446 :param str template_id: The UUID that uniquely identifies the template. 2447 :param str account_id: Your IBM Cloud account ID. 2448 :param TemplateScope included_scope: The extent at which the template can 2449 be attached across your accounts. 2450 :param List[TemplateScope] excluded_scopes: (optional) 2451 """ 2452 self.attachment_id = attachment_id 2453 self.template_id = template_id 2454 self.account_id = account_id 2455 self.included_scope = included_scope 2456 self.excluded_scopes = excluded_scopes 2457 2458 @classmethod 2459 def from_dict(cls, _dict: Dict) -> 'TemplateAttachment': 2460 """Initialize a TemplateAttachment object from a json dictionary.""" 2461 args = {} 2462 if 'attachment_id' in _dict: 2463 args['attachment_id'] = _dict.get('attachment_id') 2464 else: 2465 raise ValueError('Required property \'attachment_id\' not present in TemplateAttachment JSON') 2466 if 'template_id' in _dict: 2467 args['template_id'] = _dict.get('template_id') 2468 else: 2469 raise ValueError('Required property \'template_id\' not present in TemplateAttachment JSON') 2470 if 'account_id' in _dict: 2471 args['account_id'] = _dict.get('account_id') 2472 else: 2473 raise ValueError('Required property \'account_id\' not present in TemplateAttachment JSON') 2474 if 'included_scope' in _dict: 2475 args['included_scope'] = TemplateScope.from_dict(_dict.get('included_scope')) 2476 else: 2477 raise ValueError('Required property \'included_scope\' not present in TemplateAttachment JSON') 2478 if 'excluded_scopes' in _dict: 2479 args['excluded_scopes'] = [TemplateScope.from_dict(x) for x in _dict.get('excluded_scopes')] 2480 return cls(**args) 2481 2482 @classmethod 2483 def _from_dict(cls, _dict): 2484 """Initialize a TemplateAttachment object from a json dictionary.""" 2485 return cls.from_dict(_dict) 2486 2487 def to_dict(self) -> Dict: 2488 """Return a json dictionary representing this model.""" 2489 _dict = {} 2490 if hasattr(self, 'attachment_id') and self.attachment_id is not None: 2491 _dict['attachment_id'] = self.attachment_id 2492 if hasattr(self, 'template_id') and self.template_id is not None: 2493 _dict['template_id'] = self.template_id 2494 if hasattr(self, 'account_id') and self.account_id is not None: 2495 _dict['account_id'] = self.account_id 2496 if hasattr(self, 'included_scope') and self.included_scope is not None: 2497 _dict['included_scope'] = self.included_scope.to_dict() 2498 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 2499 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 2500 return _dict 2501 2502 def _to_dict(self): 2503 """Return a json dictionary representing this model.""" 2504 return self.to_dict() 2505 2506 def __str__(self) -> str: 2507 """Return a `str` version of this TemplateAttachment object.""" 2508 return json.dumps(self.to_dict(), indent=2) 2509 2510 def __eq__(self, other: 'TemplateAttachment') -> bool: 2511 """Return `true` when self and other are equal, false otherwise.""" 2512 if not isinstance(other, self.__class__): 2513 return False 2514 return self.__dict__ == other.__dict__ 2515 2516 def __ne__(self, other: 'TemplateAttachment') -> bool: 2517 """Return `true` when self and other are not equal, false otherwise.""" 2518 return not self == other
The scopes to attach to a template.
:attr str attachment_id: The UUID that uniquely identifies the attachment. :attr str template_id: The UUID that uniquely identifies the template. :attr str account_id: Your IBM Cloud account ID. :attr TemplateScope included_scope: The extent at which the template can be attached across your accounts. :attr List[TemplateScope] excluded_scopes: (optional)
2435 def __init__(self, 2436 attachment_id: str, 2437 template_id: str, 2438 account_id: str, 2439 included_scope: 'TemplateScope', 2440 *, 2441 excluded_scopes: List['TemplateScope'] = None) -> None: 2442 """ 2443 Initialize a TemplateAttachment object. 2444 2445 :param str attachment_id: The UUID that uniquely identifies the attachment. 2446 :param str template_id: The UUID that uniquely identifies the template. 2447 :param str account_id: Your IBM Cloud account ID. 2448 :param TemplateScope included_scope: The extent at which the template can 2449 be attached across your accounts. 2450 :param List[TemplateScope] excluded_scopes: (optional) 2451 """ 2452 self.attachment_id = attachment_id 2453 self.template_id = template_id 2454 self.account_id = account_id 2455 self.included_scope = included_scope 2456 self.excluded_scopes = excluded_scopes
Initialize a TemplateAttachment object.
Parameters
- str attachment_id: The UUID that uniquely identifies the attachment.
- str template_id: The UUID that uniquely identifies the template.
- str account_id: Your IBM Cloud account ID.
- TemplateScope included_scope: The extent at which the template can be attached across your accounts.
- List[TemplateScope] excluded_scopes: (optional)
2458 @classmethod 2459 def from_dict(cls, _dict: Dict) -> 'TemplateAttachment': 2460 """Initialize a TemplateAttachment object from a json dictionary.""" 2461 args = {} 2462 if 'attachment_id' in _dict: 2463 args['attachment_id'] = _dict.get('attachment_id') 2464 else: 2465 raise ValueError('Required property \'attachment_id\' not present in TemplateAttachment JSON') 2466 if 'template_id' in _dict: 2467 args['template_id'] = _dict.get('template_id') 2468 else: 2469 raise ValueError('Required property \'template_id\' not present in TemplateAttachment JSON') 2470 if 'account_id' in _dict: 2471 args['account_id'] = _dict.get('account_id') 2472 else: 2473 raise ValueError('Required property \'account_id\' not present in TemplateAttachment JSON') 2474 if 'included_scope' in _dict: 2475 args['included_scope'] = TemplateScope.from_dict(_dict.get('included_scope')) 2476 else: 2477 raise ValueError('Required property \'included_scope\' not present in TemplateAttachment JSON') 2478 if 'excluded_scopes' in _dict: 2479 args['excluded_scopes'] = [TemplateScope.from_dict(x) for x in _dict.get('excluded_scopes')] 2480 return cls(**args)
Initialize a TemplateAttachment object from a json dictionary.
2487 def to_dict(self) -> Dict: 2488 """Return a json dictionary representing this model.""" 2489 _dict = {} 2490 if hasattr(self, 'attachment_id') and self.attachment_id is not None: 2491 _dict['attachment_id'] = self.attachment_id 2492 if hasattr(self, 'template_id') and self.template_id is not None: 2493 _dict['template_id'] = self.template_id 2494 if hasattr(self, 'account_id') and self.account_id is not None: 2495 _dict['account_id'] = self.account_id 2496 if hasattr(self, 'included_scope') and self.included_scope is not None: 2497 _dict['included_scope'] = self.included_scope.to_dict() 2498 if hasattr(self, 'excluded_scopes') and self.excluded_scopes is not None: 2499 _dict['excluded_scopes'] = [x.to_dict() for x in self.excluded_scopes] 2500 return _dict
Return a json dictionary representing this model.
2520class TemplateScope(): 2521 """ 2522 The extent at which the template can be attached across your accounts. 2523 2524 :attr str note: (optional) A short description or alias to assign to the scope. 2525 :attr str scope_id: The ID of the scope, such as an enterprise, account, or 2526 account group, where you want to apply the customized defaults that are 2527 associated with a template. 2528 :attr str scope_type: The type of scope. 2529 """ 2530 2531 def __init__(self, 2532 scope_id: str, 2533 scope_type: str, 2534 *, 2535 note: str = None) -> None: 2536 """ 2537 Initialize a TemplateScope object. 2538 2539 :param str scope_id: The ID of the scope, such as an enterprise, account, 2540 or account group, where you want to apply the customized defaults that are 2541 associated with a template. 2542 :param str scope_type: The type of scope. 2543 :param str note: (optional) A short description or alias to assign to the 2544 scope. 2545 """ 2546 self.note = note 2547 self.scope_id = scope_id 2548 self.scope_type = scope_type 2549 2550 @classmethod 2551 def from_dict(cls, _dict: Dict) -> 'TemplateScope': 2552 """Initialize a TemplateScope object from a json dictionary.""" 2553 args = {} 2554 if 'note' in _dict: 2555 args['note'] = _dict.get('note') 2556 if 'scope_id' in _dict: 2557 args['scope_id'] = _dict.get('scope_id') 2558 else: 2559 raise ValueError('Required property \'scope_id\' not present in TemplateScope JSON') 2560 if 'scope_type' in _dict: 2561 args['scope_type'] = _dict.get('scope_type') 2562 else: 2563 raise ValueError('Required property \'scope_type\' not present in TemplateScope JSON') 2564 return cls(**args) 2565 2566 @classmethod 2567 def _from_dict(cls, _dict): 2568 """Initialize a TemplateScope object from a json dictionary.""" 2569 return cls.from_dict(_dict) 2570 2571 def to_dict(self) -> Dict: 2572 """Return a json dictionary representing this model.""" 2573 _dict = {} 2574 if hasattr(self, 'note') and self.note is not None: 2575 _dict['note'] = self.note 2576 if hasattr(self, 'scope_id') and self.scope_id is not None: 2577 _dict['scope_id'] = self.scope_id 2578 if hasattr(self, 'scope_type') and self.scope_type is not None: 2579 _dict['scope_type'] = self.scope_type 2580 return _dict 2581 2582 def _to_dict(self): 2583 """Return a json dictionary representing this model.""" 2584 return self.to_dict() 2585 2586 def __str__(self) -> str: 2587 """Return a `str` version of this TemplateScope object.""" 2588 return json.dumps(self.to_dict(), indent=2) 2589 2590 def __eq__(self, other: 'TemplateScope') -> bool: 2591 """Return `true` when self and other are equal, false otherwise.""" 2592 if not isinstance(other, self.__class__): 2593 return False 2594 return self.__dict__ == other.__dict__ 2595 2596 def __ne__(self, other: 'TemplateScope') -> bool: 2597 """Return `true` when self and other are not equal, false otherwise.""" 2598 return not self == other 2599 2600 class ScopeTypeEnum(str, Enum): 2601 """ 2602 The type of scope. 2603 """ 2604 ENTERPRISE = 'enterprise' 2605 ENTERPRISE_ACCOUNT_GROUP = 'enterprise.account_group' 2606 ENTERPRISE_ACCOUNT = 'enterprise.account' 2607 ACCOUNT = 'account' 2608 ACCOUNT_RESOURCE_GROUP = 'account.resource_group'
The extent at which the template can be attached across your accounts.
:attr str note: (optional) A short description or alias to assign to the scope. :attr str scope_id: The ID of the scope, such as an enterprise, account, or account group, where you want to apply the customized defaults that are associated with a template. :attr str scope_type: The type of scope.
2531 def __init__(self, 2532 scope_id: str, 2533 scope_type: str, 2534 *, 2535 note: str = None) -> None: 2536 """ 2537 Initialize a TemplateScope object. 2538 2539 :param str scope_id: The ID of the scope, such as an enterprise, account, 2540 or account group, where you want to apply the customized defaults that are 2541 associated with a template. 2542 :param str scope_type: The type of scope. 2543 :param str note: (optional) A short description or alias to assign to the 2544 scope. 2545 """ 2546 self.note = note 2547 self.scope_id = scope_id 2548 self.scope_type = scope_type
Initialize a TemplateScope object.
Parameters
- str scope_id: The ID of the scope, such as an enterprise, account, or account group, where you want to apply the customized defaults that are associated with a template.
- str scope_type: The type of scope.
- str note: (optional) A short description or alias to assign to the scope.
2550 @classmethod 2551 def from_dict(cls, _dict: Dict) -> 'TemplateScope': 2552 """Initialize a TemplateScope object from a json dictionary.""" 2553 args = {} 2554 if 'note' in _dict: 2555 args['note'] = _dict.get('note') 2556 if 'scope_id' in _dict: 2557 args['scope_id'] = _dict.get('scope_id') 2558 else: 2559 raise ValueError('Required property \'scope_id\' not present in TemplateScope JSON') 2560 if 'scope_type' in _dict: 2561 args['scope_type'] = _dict.get('scope_type') 2562 else: 2563 raise ValueError('Required property \'scope_type\' not present in TemplateScope JSON') 2564 return cls(**args)
Initialize a TemplateScope object from a json dictionary.
2571 def to_dict(self) -> Dict: 2572 """Return a json dictionary representing this model.""" 2573 _dict = {} 2574 if hasattr(self, 'note') and self.note is not None: 2575 _dict['note'] = self.note 2576 if hasattr(self, 'scope_id') and self.scope_id is not None: 2577 _dict['scope_id'] = self.scope_id 2578 if hasattr(self, 'scope_type') and self.scope_type is not None: 2579 _dict['scope_type'] = self.scope_type 2580 return _dict
Return a json dictionary representing this model.
2089 class ScopeTypeEnum(str, Enum): 2090 """ 2091 The type of scope that you want to evaluate. 2092 """ 2093 ENTERPRISE = 'enterprise' 2094 ENTERPRISE_ACCOUNT_GROUP = 'enterprise.account_group' 2095 ENTERPRISE_ACCOUNT = 'enterprise.account' 2096 ACCOUNT = 'account' 2097 ACCOUNT_RESOURCE_GROUP = 'account.resource_group'
The type of scope.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
2611class RuleConditionAndLvl2(RuleCondition): 2612 """ 2613 A condition with the `and` logical operator. 2614 2615 :attr str description: (optional) 2616 :attr List[RuleSingleProperty] and_: 2617 """ 2618 2619 def __init__(self, 2620 and_: List['RuleSingleProperty'], 2621 *, 2622 description: str = None) -> None: 2623 """ 2624 Initialize a RuleConditionAndLvl2 object. 2625 2626 :param List[RuleSingleProperty] and_: 2627 :param str description: (optional) 2628 """ 2629 # pylint: disable=super-init-not-called 2630 self.description = description 2631 self.and_ = and_ 2632 2633 @classmethod 2634 def from_dict(cls, _dict: Dict) -> 'RuleConditionAndLvl2': 2635 """Initialize a RuleConditionAndLvl2 object from a json dictionary.""" 2636 args = {} 2637 if 'description' in _dict: 2638 args['description'] = _dict.get('description') 2639 if 'and' in _dict: 2640 args['and_'] = [RuleSingleProperty.from_dict(x) for x in _dict.get('and')] 2641 else: 2642 raise ValueError('Required property \'and\' not present in RuleConditionAndLvl2 JSON') 2643 return cls(**args) 2644 2645 @classmethod 2646 def _from_dict(cls, _dict): 2647 """Initialize a RuleConditionAndLvl2 object from a json dictionary.""" 2648 return cls.from_dict(_dict) 2649 2650 def to_dict(self) -> Dict: 2651 """Return a json dictionary representing this model.""" 2652 _dict = {} 2653 if hasattr(self, 'description') and self.description is not None: 2654 _dict['description'] = self.description 2655 if hasattr(self, 'and_') and self.and_ is not None: 2656 _dict['and'] = [x.to_dict() for x in self.and_] 2657 return _dict 2658 2659 def _to_dict(self): 2660 """Return a json dictionary representing this model.""" 2661 return self.to_dict() 2662 2663 def __str__(self) -> str: 2664 """Return a `str` version of this RuleConditionAndLvl2 object.""" 2665 return json.dumps(self.to_dict(), indent=2) 2666 2667 def __eq__(self, other: 'RuleConditionAndLvl2') -> bool: 2668 """Return `true` when self and other are equal, false otherwise.""" 2669 if not isinstance(other, self.__class__): 2670 return False 2671 return self.__dict__ == other.__dict__ 2672 2673 def __ne__(self, other: 'RuleConditionAndLvl2') -> bool: 2674 """Return `true` when self and other are not equal, false otherwise.""" 2675 return not self == other
A condition with the and logical operator.
:attr str description: (optional) :attr List[RuleSingleProperty] and_:
2619 def __init__(self, 2620 and_: List['RuleSingleProperty'], 2621 *, 2622 description: str = None) -> None: 2623 """ 2624 Initialize a RuleConditionAndLvl2 object. 2625 2626 :param List[RuleSingleProperty] and_: 2627 :param str description: (optional) 2628 """ 2629 # pylint: disable=super-init-not-called 2630 self.description = description 2631 self.and_ = and_
Initialize a RuleConditionAndLvl2 object.
Parameters
- List[RuleSingleProperty] and_:
- str description: (optional)
2633 @classmethod 2634 def from_dict(cls, _dict: Dict) -> 'RuleConditionAndLvl2': 2635 """Initialize a RuleConditionAndLvl2 object from a json dictionary.""" 2636 args = {} 2637 if 'description' in _dict: 2638 args['description'] = _dict.get('description') 2639 if 'and' in _dict: 2640 args['and_'] = [RuleSingleProperty.from_dict(x) for x in _dict.get('and')] 2641 else: 2642 raise ValueError('Required property \'and\' not present in RuleConditionAndLvl2 JSON') 2643 return cls(**args)
Initialize a RuleConditionAndLvl2 object from a json dictionary.
2650 def to_dict(self) -> Dict: 2651 """Return a json dictionary representing this model.""" 2652 _dict = {} 2653 if hasattr(self, 'description') and self.description is not None: 2654 _dict['description'] = self.description 2655 if hasattr(self, 'and_') and self.and_ is not None: 2656 _dict['and'] = [x.to_dict() for x in self.and_] 2657 return _dict
Return a json dictionary representing this model.
2677class RuleConditionOrLvl2(RuleCondition): 2678 """ 2679 A condition with the `or` logical operator. 2680 2681 :attr str description: (optional) 2682 :attr List[RuleSingleProperty] or_: 2683 """ 2684 2685 def __init__(self, 2686 or_: List['RuleSingleProperty'], 2687 *, 2688 description: str = None) -> None: 2689 """ 2690 Initialize a RuleConditionOrLvl2 object. 2691 2692 :param List[RuleSingleProperty] or_: 2693 :param str description: (optional) 2694 """ 2695 # pylint: disable=super-init-not-called 2696 self.description = description 2697 self.or_ = or_ 2698 2699 @classmethod 2700 def from_dict(cls, _dict: Dict) -> 'RuleConditionOrLvl2': 2701 """Initialize a RuleConditionOrLvl2 object from a json dictionary.""" 2702 args = {} 2703 if 'description' in _dict: 2704 args['description'] = _dict.get('description') 2705 if 'or' in _dict: 2706 args['or_'] = [RuleSingleProperty.from_dict(x) for x in _dict.get('or')] 2707 else: 2708 raise ValueError('Required property \'or\' not present in RuleConditionOrLvl2 JSON') 2709 return cls(**args) 2710 2711 @classmethod 2712 def _from_dict(cls, _dict): 2713 """Initialize a RuleConditionOrLvl2 object from a json dictionary.""" 2714 return cls.from_dict(_dict) 2715 2716 def to_dict(self) -> Dict: 2717 """Return a json dictionary representing this model.""" 2718 _dict = {} 2719 if hasattr(self, 'description') and self.description is not None: 2720 _dict['description'] = self.description 2721 if hasattr(self, 'or_') and self.or_ is not None: 2722 _dict['or'] = [x.to_dict() for x in self.or_] 2723 return _dict 2724 2725 def _to_dict(self): 2726 """Return a json dictionary representing this model.""" 2727 return self.to_dict() 2728 2729 def __str__(self) -> str: 2730 """Return a `str` version of this RuleConditionOrLvl2 object.""" 2731 return json.dumps(self.to_dict(), indent=2) 2732 2733 def __eq__(self, other: 'RuleConditionOrLvl2') -> bool: 2734 """Return `true` when self and other are equal, false otherwise.""" 2735 if not isinstance(other, self.__class__): 2736 return False 2737 return self.__dict__ == other.__dict__ 2738 2739 def __ne__(self, other: 'RuleConditionOrLvl2') -> bool: 2740 """Return `true` when self and other are not equal, false otherwise.""" 2741 return not self == other
A condition with the or logical operator.
:attr str description: (optional) :attr List[RuleSingleProperty] or_:
2685 def __init__(self, 2686 or_: List['RuleSingleProperty'], 2687 *, 2688 description: str = None) -> None: 2689 """ 2690 Initialize a RuleConditionOrLvl2 object. 2691 2692 :param List[RuleSingleProperty] or_: 2693 :param str description: (optional) 2694 """ 2695 # pylint: disable=super-init-not-called 2696 self.description = description 2697 self.or_ = or_
Initialize a RuleConditionOrLvl2 object.
Parameters
- List[RuleSingleProperty] or_:
- str description: (optional)
2699 @classmethod 2700 def from_dict(cls, _dict: Dict) -> 'RuleConditionOrLvl2': 2701 """Initialize a RuleConditionOrLvl2 object from a json dictionary.""" 2702 args = {} 2703 if 'description' in _dict: 2704 args['description'] = _dict.get('description') 2705 if 'or' in _dict: 2706 args['or_'] = [RuleSingleProperty.from_dict(x) for x in _dict.get('or')] 2707 else: 2708 raise ValueError('Required property \'or\' not present in RuleConditionOrLvl2 JSON') 2709 return cls(**args)
Initialize a RuleConditionOrLvl2 object from a json dictionary.
2716 def to_dict(self) -> Dict: 2717 """Return a json dictionary representing this model.""" 2718 _dict = {} 2719 if hasattr(self, 'description') and self.description is not None: 2720 _dict['description'] = self.description 2721 if hasattr(self, 'or_') and self.or_ is not None: 2722 _dict['or'] = [x.to_dict() for x in self.or_] 2723 return _dict
Return a json dictionary representing this model.
2743class RuleConditionSingleProperty(RuleCondition): 2744 """ 2745 The requirement that must be met to determine the resource's level of compliance in 2746 accordance with the rule. 2747 To apply a single property check, define a configuration property and the desired 2748 value that you want to check against. 2749 2750 :attr str description: (optional) 2751 :attr str property: A resource configuration variable that describes the 2752 property that you want to apply to the target resource. 2753 Available options depend on the target service and resource. 2754 :attr str operator: The way in which the `property` field is compared to its 2755 value. 2756 To learn more, see the 2757 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2758 :attr str value: (optional) The way in which you want your property to be 2759 applied. 2760 Value options differ depending on the rule that you configure. If you use a 2761 boolean operator, you do not need to input a value. 2762 """ 2763 2764 def __init__(self, 2765 property: str, 2766 operator: str, 2767 *, 2768 description: str = None, 2769 value: str = None) -> None: 2770 """ 2771 Initialize a RuleConditionSingleProperty object. 2772 2773 :param str property: A resource configuration variable that describes the 2774 property that you want to apply to the target resource. 2775 Available options depend on the target service and resource. 2776 :param str operator: The way in which the `property` field is compared to 2777 its value. 2778 To learn more, see the 2779 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2780 :param str description: (optional) 2781 :param str value: (optional) The way in which you want your property to be 2782 applied. 2783 Value options differ depending on the rule that you configure. If you use a 2784 boolean operator, you do not need to input a value. 2785 """ 2786 # pylint: disable=super-init-not-called 2787 self.description = description 2788 self.property = property 2789 self.operator = operator 2790 self.value = value 2791 2792 @classmethod 2793 def from_dict(cls, _dict: Dict) -> 'RuleConditionSingleProperty': 2794 """Initialize a RuleConditionSingleProperty object from a json dictionary.""" 2795 args = {} 2796 if 'description' in _dict: 2797 args['description'] = _dict.get('description') 2798 if 'property' in _dict: 2799 args['property'] = _dict.get('property') 2800 else: 2801 raise ValueError('Required property \'property\' not present in RuleConditionSingleProperty JSON') 2802 if 'operator' in _dict: 2803 args['operator'] = _dict.get('operator') 2804 else: 2805 raise ValueError('Required property \'operator\' not present in RuleConditionSingleProperty JSON') 2806 if 'value' in _dict: 2807 args['value'] = _dict.get('value') 2808 return cls(**args) 2809 2810 @classmethod 2811 def _from_dict(cls, _dict): 2812 """Initialize a RuleConditionSingleProperty object from a json dictionary.""" 2813 return cls.from_dict(_dict) 2814 2815 def to_dict(self) -> Dict: 2816 """Return a json dictionary representing this model.""" 2817 _dict = {} 2818 if hasattr(self, 'description') and self.description is not None: 2819 _dict['description'] = self.description 2820 if hasattr(self, 'property') and self.property is not None: 2821 _dict['property'] = self.property 2822 if hasattr(self, 'operator') and self.operator is not None: 2823 _dict['operator'] = self.operator 2824 if hasattr(self, 'value') and self.value is not None: 2825 _dict['value'] = self.value 2826 return _dict 2827 2828 def _to_dict(self): 2829 """Return a json dictionary representing this model.""" 2830 return self.to_dict() 2831 2832 def __str__(self) -> str: 2833 """Return a `str` version of this RuleConditionSingleProperty object.""" 2834 return json.dumps(self.to_dict(), indent=2) 2835 2836 def __eq__(self, other: 'RuleConditionSingleProperty') -> bool: 2837 """Return `true` when self and other are equal, false otherwise.""" 2838 if not isinstance(other, self.__class__): 2839 return False 2840 return self.__dict__ == other.__dict__ 2841 2842 def __ne__(self, other: 'RuleConditionSingleProperty') -> bool: 2843 """Return `true` when self and other are not equal, false otherwise.""" 2844 return not self == other 2845 2846 class OperatorEnum(str, Enum): 2847 """ 2848 The way in which the `property` field is compared to its value. 2849 To learn more, see the 2850 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2851 """ 2852 IS_TRUE = 'is_true' 2853 IS_FALSE = 'is_false' 2854 IS_EMPTY = 'is_empty' 2855 IS_NOT_EMPTY = 'is_not_empty' 2856 STRING_EQUALS = 'string_equals' 2857 STRING_NOT_EQUALS = 'string_not_equals' 2858 STRING_MATCH = 'string_match' 2859 STRING_NOT_MATCH = 'string_not_match' 2860 NUM_EQUALS = 'num_equals' 2861 NUM_NOT_EQUALS = 'num_not_equals' 2862 NUM_LESS_THAN = 'num_less_than' 2863 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2864 NUM_GREATER_THAN = 'num_greater_than' 2865 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2866 IPS_IN_RANGE = 'ips_in_range' 2867 STRINGS_IN_LIST = 'strings_in_list'
The requirement that must be met to determine the resource's level of compliance in accordance with the rule. To apply a single property check, define a configuration property and the desired value that you want to check against.
:attr str description: (optional)
:attr str property: A resource configuration variable that describes the
property that you want to apply to the target resource.
Available options depend on the target service and resource.
:attr str operator: The way in which the property field is compared to its
value.
To learn more, see the
docs.
:attr str value: (optional) The way in which you want your property to be
applied.
Value options differ depending on the rule that you configure. If you use a
boolean operator, you do not need to input a value.
2764 def __init__(self, 2765 property: str, 2766 operator: str, 2767 *, 2768 description: str = None, 2769 value: str = None) -> None: 2770 """ 2771 Initialize a RuleConditionSingleProperty object. 2772 2773 :param str property: A resource configuration variable that describes the 2774 property that you want to apply to the target resource. 2775 Available options depend on the target service and resource. 2776 :param str operator: The way in which the `property` field is compared to 2777 its value. 2778 To learn more, see the 2779 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2780 :param str description: (optional) 2781 :param str value: (optional) The way in which you want your property to be 2782 applied. 2783 Value options differ depending on the rule that you configure. If you use a 2784 boolean operator, you do not need to input a value. 2785 """ 2786 # pylint: disable=super-init-not-called 2787 self.description = description 2788 self.property = property 2789 self.operator = operator 2790 self.value = value
Initialize a RuleConditionSingleProperty object.
Parameters
- str property: A resource configuration variable that describes the property that you want to apply to the target resource. Available options depend on the target service and resource.
- str operator: The way in which the
propertyfield is compared to its value. To learn more, see the docs. - str description: (optional)
- str value: (optional) The way in which you want your property to be applied. Value options differ depending on the rule that you configure. If you use a boolean operator, you do not need to input a value.
2792 @classmethod 2793 def from_dict(cls, _dict: Dict) -> 'RuleConditionSingleProperty': 2794 """Initialize a RuleConditionSingleProperty object from a json dictionary.""" 2795 args = {} 2796 if 'description' in _dict: 2797 args['description'] = _dict.get('description') 2798 if 'property' in _dict: 2799 args['property'] = _dict.get('property') 2800 else: 2801 raise ValueError('Required property \'property\' not present in RuleConditionSingleProperty JSON') 2802 if 'operator' in _dict: 2803 args['operator'] = _dict.get('operator') 2804 else: 2805 raise ValueError('Required property \'operator\' not present in RuleConditionSingleProperty JSON') 2806 if 'value' in _dict: 2807 args['value'] = _dict.get('value') 2808 return cls(**args)
Initialize a RuleConditionSingleProperty object from a json dictionary.
2815 def to_dict(self) -> Dict: 2816 """Return a json dictionary representing this model.""" 2817 _dict = {} 2818 if hasattr(self, 'description') and self.description is not None: 2819 _dict['description'] = self.description 2820 if hasattr(self, 'property') and self.property is not None: 2821 _dict['property'] = self.property 2822 if hasattr(self, 'operator') and self.operator is not None: 2823 _dict['operator'] = self.operator 2824 if hasattr(self, 'value') and self.value is not None: 2825 _dict['value'] = self.value 2826 return _dict
Return a json dictionary representing this model.
2202 class OperatorEnum(str, Enum): 2203 """ 2204 The way in which the `property` field is compared to its value. 2205 To learn more, see the 2206 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2207 """ 2208 IS_TRUE = 'is_true' 2209 IS_FALSE = 'is_false' 2210 IS_EMPTY = 'is_empty' 2211 IS_NOT_EMPTY = 'is_not_empty' 2212 STRING_EQUALS = 'string_equals' 2213 STRING_NOT_EQUALS = 'string_not_equals' 2214 STRING_MATCH = 'string_match' 2215 STRING_NOT_MATCH = 'string_not_match' 2216 NUM_EQUALS = 'num_equals' 2217 NUM_NOT_EQUALS = 'num_not_equals' 2218 NUM_LESS_THAN = 'num_less_than' 2219 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2220 NUM_GREATER_THAN = 'num_greater_than' 2221 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2222 IPS_IN_RANGE = 'ips_in_range' 2223 STRINGS_IN_LIST = 'strings_in_list'
The way in which the property field is compared to its value.
To learn more, see the
docs.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
2870class RuleRequiredConfigMultipleProperties(RuleRequiredConfig): 2871 """ 2872 The requirements that must be met to determine the resource's level of compliance in 2873 accordance with the rule. 2874 Use logical operators (`and`/`or`) to define multiple property checks and conditions. 2875 To define requirements for a rule, list one or more property check objects in the 2876 `and` array. To add conditions to a property check, use `or`. 2877 2878 """ 2879 2880 def __init__(self) -> None: 2881 """ 2882 Initialize a RuleRequiredConfigMultipleProperties object. 2883 2884 """ 2885 # pylint: disable=super-init-not-called 2886 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 2887 ", ".join(['RuleRequiredConfigMultiplePropertiesConditionOr', 'RuleRequiredConfigMultiplePropertiesConditionAnd'])) 2888 raise Exception(msg)
The requirements that must be met to determine the resource's level of compliance in
accordance with the rule.
Use logical operators (and/or) to define multiple property checks and conditions.
To define requirements for a rule, list one or more property check objects in the
and array. To add conditions to a property check, use or.
2880 def __init__(self) -> None: 2881 """ 2882 Initialize a RuleRequiredConfigMultipleProperties object. 2883 2884 """ 2885 # pylint: disable=super-init-not-called 2886 msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( 2887 ", ".join(['RuleRequiredConfigMultiplePropertiesConditionOr', 'RuleRequiredConfigMultiplePropertiesConditionAnd'])) 2888 raise Exception(msg)
Initialize a RuleRequiredConfigMultipleProperties object.
2890class RuleRequiredConfigSingleProperty(RuleRequiredConfig): 2891 """ 2892 The requirement that must be met to determine the resource's level of compliance in 2893 accordance with the rule. 2894 To apply a single property check, define a configuration property and the desired 2895 value that you want to check against. 2896 2897 :attr str description: (optional) 2898 :attr str property: A resource configuration variable that describes the 2899 property that you want to apply to the target resource. 2900 Available options depend on the target service and resource. 2901 :attr str operator: The way in which the `property` field is compared to its 2902 value. 2903 To learn more, see the 2904 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2905 :attr str value: (optional) The way in which you want your property to be 2906 applied. 2907 Value options differ depending on the rule that you configure. If you use a 2908 boolean operator, you do not need to input a value. 2909 """ 2910 2911 def __init__(self, 2912 property: str, 2913 operator: str, 2914 *, 2915 description: str = None, 2916 value: str = None) -> None: 2917 """ 2918 Initialize a RuleRequiredConfigSingleProperty object. 2919 2920 :param str property: A resource configuration variable that describes the 2921 property that you want to apply to the target resource. 2922 Available options depend on the target service and resource. 2923 :param str operator: The way in which the `property` field is compared to 2924 its value. 2925 To learn more, see the 2926 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2927 :param str description: (optional) 2928 :param str value: (optional) The way in which you want your property to be 2929 applied. 2930 Value options differ depending on the rule that you configure. If you use a 2931 boolean operator, you do not need to input a value. 2932 """ 2933 # pylint: disable=super-init-not-called 2934 self.description = description 2935 self.property = property 2936 self.operator = operator 2937 self.value = value 2938 2939 @classmethod 2940 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigSingleProperty': 2941 """Initialize a RuleRequiredConfigSingleProperty object from a json dictionary.""" 2942 args = {} 2943 if 'description' in _dict: 2944 args['description'] = _dict.get('description') 2945 if 'property' in _dict: 2946 args['property'] = _dict.get('property') 2947 else: 2948 raise ValueError('Required property \'property\' not present in RuleRequiredConfigSingleProperty JSON') 2949 if 'operator' in _dict: 2950 args['operator'] = _dict.get('operator') 2951 else: 2952 raise ValueError('Required property \'operator\' not present in RuleRequiredConfigSingleProperty JSON') 2953 if 'value' in _dict: 2954 args['value'] = _dict.get('value') 2955 return cls(**args) 2956 2957 @classmethod 2958 def _from_dict(cls, _dict): 2959 """Initialize a RuleRequiredConfigSingleProperty object from a json dictionary.""" 2960 return cls.from_dict(_dict) 2961 2962 def to_dict(self) -> Dict: 2963 """Return a json dictionary representing this model.""" 2964 _dict = {} 2965 if hasattr(self, 'description') and self.description is not None: 2966 _dict['description'] = self.description 2967 if hasattr(self, 'property') and self.property is not None: 2968 _dict['property'] = self.property 2969 if hasattr(self, 'operator') and self.operator is not None: 2970 _dict['operator'] = self.operator 2971 if hasattr(self, 'value') and self.value is not None: 2972 _dict['value'] = self.value 2973 return _dict 2974 2975 def _to_dict(self): 2976 """Return a json dictionary representing this model.""" 2977 return self.to_dict() 2978 2979 def __str__(self) -> str: 2980 """Return a `str` version of this RuleRequiredConfigSingleProperty object.""" 2981 return json.dumps(self.to_dict(), indent=2) 2982 2983 def __eq__(self, other: 'RuleRequiredConfigSingleProperty') -> bool: 2984 """Return `true` when self and other are equal, false otherwise.""" 2985 if not isinstance(other, self.__class__): 2986 return False 2987 return self.__dict__ == other.__dict__ 2988 2989 def __ne__(self, other: 'RuleRequiredConfigSingleProperty') -> bool: 2990 """Return `true` when self and other are not equal, false otherwise.""" 2991 return not self == other 2992 2993 class OperatorEnum(str, Enum): 2994 """ 2995 The way in which the `property` field is compared to its value. 2996 To learn more, see the 2997 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2998 """ 2999 IS_TRUE = 'is_true' 3000 IS_FALSE = 'is_false' 3001 IS_EMPTY = 'is_empty' 3002 IS_NOT_EMPTY = 'is_not_empty' 3003 STRING_EQUALS = 'string_equals' 3004 STRING_NOT_EQUALS = 'string_not_equals' 3005 STRING_MATCH = 'string_match' 3006 STRING_NOT_MATCH = 'string_not_match' 3007 NUM_EQUALS = 'num_equals' 3008 NUM_NOT_EQUALS = 'num_not_equals' 3009 NUM_LESS_THAN = 'num_less_than' 3010 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 3011 NUM_GREATER_THAN = 'num_greater_than' 3012 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 3013 IPS_IN_RANGE = 'ips_in_range' 3014 STRINGS_IN_LIST = 'strings_in_list'
The requirement that must be met to determine the resource's level of compliance in accordance with the rule. To apply a single property check, define a configuration property and the desired value that you want to check against.
:attr str description: (optional)
:attr str property: A resource configuration variable that describes the
property that you want to apply to the target resource.
Available options depend on the target service and resource.
:attr str operator: The way in which the property field is compared to its
value.
To learn more, see the
docs.
:attr str value: (optional) The way in which you want your property to be
applied.
Value options differ depending on the rule that you configure. If you use a
boolean operator, you do not need to input a value.
2911 def __init__(self, 2912 property: str, 2913 operator: str, 2914 *, 2915 description: str = None, 2916 value: str = None) -> None: 2917 """ 2918 Initialize a RuleRequiredConfigSingleProperty object. 2919 2920 :param str property: A resource configuration variable that describes the 2921 property that you want to apply to the target resource. 2922 Available options depend on the target service and resource. 2923 :param str operator: The way in which the `property` field is compared to 2924 its value. 2925 To learn more, see the 2926 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2927 :param str description: (optional) 2928 :param str value: (optional) The way in which you want your property to be 2929 applied. 2930 Value options differ depending on the rule that you configure. If you use a 2931 boolean operator, you do not need to input a value. 2932 """ 2933 # pylint: disable=super-init-not-called 2934 self.description = description 2935 self.property = property 2936 self.operator = operator 2937 self.value = value
Initialize a RuleRequiredConfigSingleProperty object.
Parameters
- str property: A resource configuration variable that describes the property that you want to apply to the target resource. Available options depend on the target service and resource.
- str operator: The way in which the
propertyfield is compared to its value. To learn more, see the docs. - str description: (optional)
- str value: (optional) The way in which you want your property to be applied. Value options differ depending on the rule that you configure. If you use a boolean operator, you do not need to input a value.
2939 @classmethod 2940 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigSingleProperty': 2941 """Initialize a RuleRequiredConfigSingleProperty object from a json dictionary.""" 2942 args = {} 2943 if 'description' in _dict: 2944 args['description'] = _dict.get('description') 2945 if 'property' in _dict: 2946 args['property'] = _dict.get('property') 2947 else: 2948 raise ValueError('Required property \'property\' not present in RuleRequiredConfigSingleProperty JSON') 2949 if 'operator' in _dict: 2950 args['operator'] = _dict.get('operator') 2951 else: 2952 raise ValueError('Required property \'operator\' not present in RuleRequiredConfigSingleProperty JSON') 2953 if 'value' in _dict: 2954 args['value'] = _dict.get('value') 2955 return cls(**args)
Initialize a RuleRequiredConfigSingleProperty object from a json dictionary.
2962 def to_dict(self) -> Dict: 2963 """Return a json dictionary representing this model.""" 2964 _dict = {} 2965 if hasattr(self, 'description') and self.description is not None: 2966 _dict['description'] = self.description 2967 if hasattr(self, 'property') and self.property is not None: 2968 _dict['property'] = self.property 2969 if hasattr(self, 'operator') and self.operator is not None: 2970 _dict['operator'] = self.operator 2971 if hasattr(self, 'value') and self.value is not None: 2972 _dict['value'] = self.value 2973 return _dict
Return a json dictionary representing this model.
2202 class OperatorEnum(str, Enum): 2203 """ 2204 The way in which the `property` field is compared to its value. 2205 To learn more, see the 2206 [docs](/docs/security-compliance?topic=security-compliance-what-is-rule#rule-operators). 2207 """ 2208 IS_TRUE = 'is_true' 2209 IS_FALSE = 'is_false' 2210 IS_EMPTY = 'is_empty' 2211 IS_NOT_EMPTY = 'is_not_empty' 2212 STRING_EQUALS = 'string_equals' 2213 STRING_NOT_EQUALS = 'string_not_equals' 2214 STRING_MATCH = 'string_match' 2215 STRING_NOT_MATCH = 'string_not_match' 2216 NUM_EQUALS = 'num_equals' 2217 NUM_NOT_EQUALS = 'num_not_equals' 2218 NUM_LESS_THAN = 'num_less_than' 2219 NUM_LESS_THAN_EQUALS = 'num_less_than_equals' 2220 NUM_GREATER_THAN = 'num_greater_than' 2221 NUM_GREATER_THAN_EQUALS = 'num_greater_than_equals' 2222 IPS_IN_RANGE = 'ips_in_range' 2223 STRINGS_IN_LIST = 'strings_in_list'
The way in which the property field is compared to its value.
To learn more, see the
docs.
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
3017class RuleRequiredConfigMultiplePropertiesConditionAnd(RuleRequiredConfigMultipleProperties): 3018 """ 3019 A condition with the `and` logical operator. 3020 3021 :attr str description: (optional) 3022 :attr List[RuleCondition] and_: 3023 """ 3024 3025 def __init__(self, 3026 and_: List['RuleCondition'], 3027 *, 3028 description: str = None) -> None: 3029 """ 3030 Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object. 3031 3032 :param List[RuleCondition] and_: 3033 :param str description: (optional) 3034 """ 3035 # pylint: disable=super-init-not-called 3036 self.description = description 3037 self.and_ = and_ 3038 3039 @classmethod 3040 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigMultiplePropertiesConditionAnd': 3041 """Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object from a json dictionary.""" 3042 args = {} 3043 if 'description' in _dict: 3044 args['description'] = _dict.get('description') 3045 if 'and' in _dict: 3046 args['and_'] = _dict.get('and') 3047 else: 3048 raise ValueError('Required property \'and\' not present in RuleRequiredConfigMultiplePropertiesConditionAnd JSON') 3049 return cls(**args) 3050 3051 @classmethod 3052 def _from_dict(cls, _dict): 3053 """Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object from a json dictionary.""" 3054 return cls.from_dict(_dict) 3055 3056 def to_dict(self) -> Dict: 3057 """Return a json dictionary representing this model.""" 3058 _dict = {} 3059 if hasattr(self, 'description') and self.description is not None: 3060 _dict['description'] = self.description 3061 if hasattr(self, 'and_') and self.and_ is not None: 3062 and_list = [] 3063 for x in self.and_: 3064 if isinstance(x, dict): 3065 and_list.append(x) 3066 else: 3067 and_list.append(x.to_dict()) 3068 _dict['and'] = and_list 3069 return _dict 3070 3071 def _to_dict(self): 3072 """Return a json dictionary representing this model.""" 3073 return self.to_dict() 3074 3075 def __str__(self) -> str: 3076 """Return a `str` version of this RuleRequiredConfigMultiplePropertiesConditionAnd object.""" 3077 return json.dumps(self.to_dict(), indent=2) 3078 3079 def __eq__(self, other: 'RuleRequiredConfigMultiplePropertiesConditionAnd') -> bool: 3080 """Return `true` when self and other are equal, false otherwise.""" 3081 if not isinstance(other, self.__class__): 3082 return False 3083 return self.__dict__ == other.__dict__ 3084 3085 def __ne__(self, other: 'RuleRequiredConfigMultiplePropertiesConditionAnd') -> bool: 3086 """Return `true` when self and other are not equal, false otherwise.""" 3087 return not self == other
A condition with the and logical operator.
:attr str description: (optional) :attr List[RuleCondition] and_:
3025 def __init__(self, 3026 and_: List['RuleCondition'], 3027 *, 3028 description: str = None) -> None: 3029 """ 3030 Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object. 3031 3032 :param List[RuleCondition] and_: 3033 :param str description: (optional) 3034 """ 3035 # pylint: disable=super-init-not-called 3036 self.description = description 3037 self.and_ = and_
Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object.
Parameters
- List[RuleCondition] and_:
- str description: (optional)
3039 @classmethod 3040 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigMultiplePropertiesConditionAnd': 3041 """Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object from a json dictionary.""" 3042 args = {} 3043 if 'description' in _dict: 3044 args['description'] = _dict.get('description') 3045 if 'and' in _dict: 3046 args['and_'] = _dict.get('and') 3047 else: 3048 raise ValueError('Required property \'and\' not present in RuleRequiredConfigMultiplePropertiesConditionAnd JSON') 3049 return cls(**args)
Initialize a RuleRequiredConfigMultiplePropertiesConditionAnd object from a json dictionary.
3056 def to_dict(self) -> Dict: 3057 """Return a json dictionary representing this model.""" 3058 _dict = {} 3059 if hasattr(self, 'description') and self.description is not None: 3060 _dict['description'] = self.description 3061 if hasattr(self, 'and_') and self.and_ is not None: 3062 and_list = [] 3063 for x in self.and_: 3064 if isinstance(x, dict): 3065 and_list.append(x) 3066 else: 3067 and_list.append(x.to_dict()) 3068 _dict['and'] = and_list 3069 return _dict
Return a json dictionary representing this model.
3089class RuleRequiredConfigMultiplePropertiesConditionOr(RuleRequiredConfigMultipleProperties): 3090 """ 3091 A condition with the `or` logical operator. 3092 3093 :attr str description: (optional) 3094 :attr List[RuleCondition] or_: 3095 """ 3096 3097 def __init__(self, 3098 or_: List['RuleCondition'], 3099 *, 3100 description: str = None) -> None: 3101 """ 3102 Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object. 3103 3104 :param List[RuleCondition] or_: 3105 :param str description: (optional) 3106 """ 3107 # pylint: disable=super-init-not-called 3108 self.description = description 3109 self.or_ = or_ 3110 3111 @classmethod 3112 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigMultiplePropertiesConditionOr': 3113 """Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object from a json dictionary.""" 3114 args = {} 3115 if 'description' in _dict: 3116 args['description'] = _dict.get('description') 3117 if 'or' in _dict: 3118 args['or_'] = _dict.get('or') 3119 else: 3120 raise ValueError('Required property \'or\' not present in RuleRequiredConfigMultiplePropertiesConditionOr JSON') 3121 return cls(**args) 3122 3123 @classmethod 3124 def _from_dict(cls, _dict): 3125 """Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object from a json dictionary.""" 3126 return cls.from_dict(_dict) 3127 3128 def to_dict(self) -> Dict: 3129 """Return a json dictionary representing this model.""" 3130 _dict = {} 3131 if hasattr(self, 'description') and self.description is not None: 3132 _dict['description'] = self.description 3133 if hasattr(self, 'or_') and self.or_ is not None: 3134 or_list = [] 3135 for x in self.or_: 3136 if isinstance(x, dict): 3137 or_list.append(x) 3138 else: 3139 or_list.append(x.to_dict()) 3140 _dict['or'] = or_list 3141 return _dict 3142 3143 def _to_dict(self): 3144 """Return a json dictionary representing this model.""" 3145 return self.to_dict() 3146 3147 def __str__(self) -> str: 3148 """Return a `str` version of this RuleRequiredConfigMultiplePropertiesConditionOr object.""" 3149 return json.dumps(self.to_dict(), indent=2) 3150 3151 def __eq__(self, other: 'RuleRequiredConfigMultiplePropertiesConditionOr') -> bool: 3152 """Return `true` when self and other are equal, false otherwise.""" 3153 if not isinstance(other, self.__class__): 3154 return False 3155 return self.__dict__ == other.__dict__ 3156 3157 def __ne__(self, other: 'RuleRequiredConfigMultiplePropertiesConditionOr') -> bool: 3158 """Return `true` when self and other are not equal, false otherwise.""" 3159 return not self == other
A condition with the or logical operator.
:attr str description: (optional) :attr List[RuleCondition] or_:
3097 def __init__(self, 3098 or_: List['RuleCondition'], 3099 *, 3100 description: str = None) -> None: 3101 """ 3102 Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object. 3103 3104 :param List[RuleCondition] or_: 3105 :param str description: (optional) 3106 """ 3107 # pylint: disable=super-init-not-called 3108 self.description = description 3109 self.or_ = or_
Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object.
Parameters
- List[RuleCondition] or_:
- str description: (optional)
3111 @classmethod 3112 def from_dict(cls, _dict: Dict) -> 'RuleRequiredConfigMultiplePropertiesConditionOr': 3113 """Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object from a json dictionary.""" 3114 args = {} 3115 if 'description' in _dict: 3116 args['description'] = _dict.get('description') 3117 if 'or' in _dict: 3118 args['or_'] = _dict.get('or') 3119 else: 3120 raise ValueError('Required property \'or\' not present in RuleRequiredConfigMultiplePropertiesConditionOr JSON') 3121 return cls(**args)
Initialize a RuleRequiredConfigMultiplePropertiesConditionOr object from a json dictionary.
3128 def to_dict(self) -> Dict: 3129 """Return a json dictionary representing this model.""" 3130 _dict = {} 3131 if hasattr(self, 'description') and self.description is not None: 3132 _dict['description'] = self.description 3133 if hasattr(self, 'or_') and self.or_ is not None: 3134 or_list = [] 3135 for x in self.or_: 3136 if isinstance(x, dict): 3137 or_list.append(x) 3138 else: 3139 or_list.append(x.to_dict()) 3140 _dict['or'] = or_list 3141 return _dict
Return a json dictionary representing this model.