def update_page_rule(self, rule_id: str, *, targets: List['PageRulesBodyTargetsItem'] = None, actions: List['PageRulesBodyActionsItem'] = None, priority: int = None, status: str = None, **kwargs) -> DetailedResponse: """ Update a page rule. Replace a page rule. The final rule will exactly match the data passed with this request. :param str rule_id: rule id. :param List[PageRulesBodyTargetsItem] targets: (optional) targets. :param List[PageRulesBodyActionsItem] actions: (optional) actions. :param int priority: (optional) priority. :param str status: (optional) status. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `PageRulesResponseWithoutResultInfo` object """ if rule_id is None: raise ValueError('rule_id must be provided') if targets is not None: targets = [convert_model(x) for x in targets] if actions is not None: actions = [convert_model(x) for x in actions] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_page_rule') headers.update(sdk_headers) data = { 'targets': targets, 'actions': actions, 'priority': priority, 'status': status } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/zones/{1}/pagerules/{2}'.format( *self.encode_path_vars(self.crn, self.zone_id, rule_id)) request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response
def update_waf_rule(self, package_id: str, identifier: str, *, cis: 'WafRuleBodyCis' = None, owasp: 'WafRuleBodyOwasp' = None, **kwargs) -> DetailedResponse: """ Update WAF rule. Update the action the rule will perform if triggered on the zone. :param str package_id: package id. :param str identifier: rule identifier. :param WafRuleBodyCis cis: (optional) cis package. :param WafRuleBodyOwasp owasp: (optional) owasp package. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `WafRuleResponse` object """ if package_id is None: raise ValueError('package_id must be provided') if identifier is None: raise ValueError('identifier must be provided') if cis is not None: cis = convert_model(cis) if owasp is not None: owasp = convert_model(owasp) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_waf_rule') headers.update(sdk_headers) data = {'cis': cis, 'owasp': owasp} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/zones/{1}/firewall/waf/packages/{2}/rules/{3}'.format( *self.encode_path_vars(self.crn, self.zone_id, package_id, identifier)) request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request) return response
def update_custom_certificate( self, custom_cert_id: str, *, certificate: str = None, private_key: str = None, bundle_method: str = None, geo_restrictions: 'CustomCertReqGeoRestrictions' = None, **kwargs) -> DetailedResponse: """ Update specified custom certificate. For a given zone identifier, update a custom certificates. :param str custom_cert_id: custom certificate id. :param str certificate: (optional) certificates. :param str private_key: (optional) private key. :param str bundle_method: (optional) Methods shown in UI mapping to API: Compatible(ubiquitous), Modern(optimal), User Defined(force). :param CustomCertReqGeoRestrictions geo_restrictions: (optional) geo restrictions. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `CustomCertResp` object """ if custom_cert_id is None: raise ValueError('custom_cert_id must be provided') if geo_restrictions is not None: geo_restrictions = convert_model(geo_restrictions) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_custom_certificate') headers.update(sdk_headers) data = { 'certificate': certificate, 'private_key': private_key, 'bundle_method': bundle_method, 'geo_restrictions': geo_restrictions } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/zones/{1}/custom_certificates/{2}'.format( *self.encode_path_vars(self.crn, self.zone_identifier, custom_cert_id)) request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request) return response
def create_zone_user_agent_rule( self, *, mode: str = None, configuration: 'UseragentRuleInputConfiguration' = None, paused: bool = None, description: str = None, **kwargs) -> DetailedResponse: """ Create a new user-agent blocking rule. Create a new user-agent blocking rule for a given zone under a service instance. :param str mode: (optional) The type of action to perform. :param UseragentRuleInputConfiguration configuration: (optional) Target/Value pair to use for this rule. The value is the exact UserAgent to match. :param bool paused: (optional) Whether this user-agent rule is currently disabled. :param str description: (optional) Some useful information about this rule to help identify the purpose of it. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `UseragentRuleResp` object """ if configuration is not None: configuration = convert_model(configuration) headers = {} sdk_headers = get_sdk_headers( service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_zone_user_agent_rule') headers.update(sdk_headers) data = { 'mode': mode, 'configuration': configuration, 'paused': paused, 'description': description } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/zones/{1}/firewall/ua_rules'.format( *self.encode_path_vars(self.crn, self.zone_identifier)) request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request) return response
def update_resource_record(self, instance_id: str, dnszone_id: str, record_id: str, *, name: str = None, rdata: 'ResourceRecordUpdateInputRdata' = None, ttl: int = None, service: str = None, protocol: str = None, x_correlation_id: str = None, **kwargs) -> DetailedResponse: """ Update the properties of a resource record. Update the properties of a resource record. :param str instance_id: The unique identifier of a service instance. :param str dnszone_id: The unique identifier of a DNS zone. :param str record_id: The unique identifier of a resource record. :param str name: (optional) Name of the resource record. :param ResourceRecordUpdateInputRdata rdata: (optional) Content of the resource record. :param int ttl: (optional) Time to live in second. :param str service: (optional) Only used for SRV record. :param str protocol: (optional) Only used for SRV record. :param str x_correlation_id: (optional) Uniquely identifying a request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ResourceRecord` object """ if instance_id is None: raise ValueError('instance_id must be provided') if dnszone_id is None: raise ValueError('dnszone_id must be provided') if record_id is None: raise ValueError('record_id must be provided') if rdata is not None: rdata = convert_model(rdata) headers = { 'X-Correlation-ID': x_correlation_id } sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_resource_record') headers.update(sdk_headers) data = { 'name': name, 'rdata': rdata, 'ttl': ttl, 'service': service, 'protocol': protocol } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/instances/{0}/dnszones/{1}/resource_records/{2}'.format(*self.encode_path_vars(instance_id, dnszone_id, record_id)) request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response
def create_permitted_network( self, instance_id: str, dnszone_id: str, *, type: str = None, permitted_network: 'PermittedNetworkVpc' = None, x_correlation_id: str = None, **kwargs) -> DetailedResponse: """ Create a permitted network. Create a permitted network for a given DNS zone. :param str instance_id: The unique identifier of a service instance. :param str dnszone_id: The unique identifier of a DNS zone. :param str type: (optional) The type of a permitted network. :param PermittedNetworkVpc permitted_network: (optional) Permitted network data for VPC. :param str x_correlation_id: (optional) Uniquely identifying a request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `PermittedNetwork` object """ if instance_id is None: raise ValueError('instance_id must be provided') if dnszone_id is None: raise ValueError('dnszone_id must be provided') if permitted_network is not None: permitted_network = convert_model(permitted_network) headers = {'X-Correlation-ID': x_correlation_id} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_permitted_network') headers.update(sdk_headers) data = {'type': type, 'permitted_network': permitted_network} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/instances/{0}/dnszones/{1}/permitted_networks'.format( *self.encode_path_vars(instance_id, dnszone_id)) request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request) return response
def update_lockdown_rule(self, lockdown_rule_identifier: str, *, urls: List[str] = None, configurations: List['LockdownInputConfigurationsItem'] = None, id: str = None, paused: bool = None, description: str = None, **kwargs) -> DetailedResponse: """ Update a lockdown rule. Update an existing lockdown rule for a given zone under a given service instance. :param str lockdown_rule_identifier: Identifier of lockdown rule. :param List[str] urls: (optional) URLs to be included in this rule definition. Wildcards are permitted. The URL pattern entered here will be escaped before use. This limits the URL to just simple wildcard patterns. :param List[LockdownInputConfigurationsItem] configurations: (optional) List of IP addresses or CIDR ranges to use for this rule. This can include any number of ip or ip_range configurations that can access the provided URLs. :param str id: (optional) Lockdown rule identifier. :param bool paused: (optional) Whether this zone lockdown is currently paused. :param str description: (optional) A note that you can use to describe the reason for a Lockdown rule. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `LockdownResp` object """ if lockdown_rule_identifier is None: raise ValueError('lockdown_rule_identifier must be provided') if configurations is not None: configurations = [ convert_model(x) for x in configurations ] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_lockdown_rule') headers.update(sdk_headers) data = { 'urls': urls, 'configurations': configurations, 'id': id, 'paused': paused, 'description': description } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/zones/{1}/firewall/lockdowns/{2}'.format(*self.encode_path_vars(self.crn, self.zone_identifier, lockdown_rule_identifier)) request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response
def create_application( self, instance_id: str, *, application_details: 'ApplicationRequestApplicationDetails' = None, **kwargs) -> DetailedResponse: """ Deploy a Spark application. Deploys a Spark application on a given serverless Spark instance. :param str instance_id: The identifier of the instance where the Spark application is submitted. :param ApplicationRequestApplicationDetails application_details: (optional) Application details. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ApplicationResponse` object """ if instance_id is None: raise ValueError('instance_id must be provided') if application_details is not None: application_details = convert_model(application_details) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V3', operation_id='create_application') headers.update(sdk_headers) data = {'application_details': application_details} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' path_param_keys = ['instance_id'] path_param_values = self.encode_path_vars(instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v3/analytics_engines/{instance_id}/spark_applications'.format( **path_param_dict) request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response
def create_account_access_rule( self, *, mode: str = None, notes: str = None, configuration: 'AccessruleInputConfiguration' = None, **kwargs) -> DetailedResponse: """ Create an instance level firewall access rule. Create a new instance level firewall access rule for a given service instance. :param str mode: (optional) The action to apply to a matched request. :param str notes: (optional) A personal note about the rule. Typically used as a reminder or explanation for the rule. :param AccessruleInputConfiguration configuration: (optional) Configuration object specifying access rule. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `AccessruleResp` object """ if configuration is not None: configuration = convert_model(configuration) headers = {} sdk_headers = get_sdk_headers( service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_account_access_rule') headers.update(sdk_headers) data = {'mode': mode, 'notes': notes, 'configuration': configuration} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/firewall/access_rules/rules'.format( *self.encode_path_vars(self.crn)) request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request) return response
def change_certificate_priority( self, *, certificates: List['CertPriorityReqCertificatesItem'] = None, **kwargs) -> DetailedResponse: """ Set priority for given certificates. For a given zone identifier, set priority of certificates. :param List[CertPriorityReqCertificatesItem] certificates: (optional) certificates array. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse """ if certificates is not None: certificates = [convert_model(x) for x in certificates] headers = {} sdk_headers = get_sdk_headers( service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='change_certificate_priority') headers.update(sdk_headers) data = {'certificates': certificates} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/zones/{1}/custom_certificates/prioritize'.format( *self.encode_path_vars(self.crn, self.zone_identifier)) request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response
def update_range_app(self, app_identifier: str, protocol: str, dns: 'RangeAppReqDns', *, origin_direct: List[str] = None, origin_dns: 'RangeAppReqOriginDns' = None, origin_port: int = None, ip_firewall: bool = None, proxy_protocol: str = None, edge_ips: 'RangeAppReqEdgeIps' = None, traffic_type: str = None, tls: str = None, **kwargs) -> DetailedResponse: """ Update a specific range application. Update a Range Application inside a zone. :param str app_identifier: application identifier. :param str protocol: Defines the protocol and port for this application. :param RangeAppReqDns dns: Name and type of the DNS record for this application. :param List[str] origin_direct: (optional) IP address and port of the origin for this Range application. If configuring a load balancer, use 'origin_dns' and 'origin_port'. This can not be combined with 'origin_dns' and 'origin_port'. :param RangeAppReqOriginDns origin_dns: (optional) DNS record pointing to the origin for this Range application. This is used for configuring a load balancer. When specifying an individual IP address, use 'origin_direct'. This requires 'origin_port' and can not be combined with 'origin_direct'. :param int origin_port: (optional) Port at the origin that listens to traffic from this Range application. Requires 'origin_dns' and can not be combined with 'origin_direct'. :param bool ip_firewall: (optional) Enables the IP Firewall for this application. Only available for TCP applications. :param str proxy_protocol: (optional) Allows for the true client IP to be passed to the service. :param RangeAppReqEdgeIps edge_ips: (optional) Configures IP version for the hostname of this application. Default is {"type":"dynamic", "connectivity":"all"}. :param str traffic_type: (optional) Configure how traffic is handled at the edge. If set to "direct" traffic is passed through to the service. In the case of "http" or "https" HTTP/s features at the edge are applied ot this traffic. :param str tls: (optional) Configure if and how TLS connections are terminated at the edge. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `RangeApplicationObject` object """ if app_identifier is None: raise ValueError('app_identifier must be provided') if protocol is None: raise ValueError('protocol must be provided') if dns is None: raise ValueError('dns must be provided') dns = convert_model(dns) if origin_dns is not None: origin_dns = convert_model(origin_dns) if edge_ips is not None: edge_ips = convert_model(edge_ips) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_range_app') headers.update(sdk_headers) data = { 'protocol': protocol, 'dns': dns, 'origin_direct': origin_direct, 'origin_dns': origin_dns, 'origin_port': origin_port, 'ip_firewall': ip_firewall, 'proxy_protocol': proxy_protocol, 'edge_ips': edge_ips, 'traffic_type': traffic_type, 'tls': tls } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/zones/{1}/range/apps/{2}'.format(*self.encode_path_vars( self.crn, self.zone_identifier, app_identifier)) request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response
def invite_users(self, account_id: str, *, users: List['InviteUser'] = None, iam_policy: List['InviteUserIamPolicy'] = None, access_groups: List[str] = None, **kwargs) -> DetailedResponse: """ Invite users. Invite users to the account. You must use a user token for authorization. Service IDs can't invite users to the account. To use this method, the requesting user must have the editor or administrator role on the User Management service. For more information, see the [Inviting users](/docs/account?topic=account-iamuserinv) documentation. You can specify the user account role and the corresponding IAM policy information in the request body. <br/><br/>When you invite a user to an account, the user is initially created in the `PROCESSING` state. After the user is successfully created, all specified permissions are configured, and the activation email is sent, the invited user is transitioned to the `PENDING` state. When the invited user clicks the activation email and creates and confirms their IBM Cloud account, the user is transitioned to `ACTIVE` state. If the user email is already verified, no email is generated. :param str account_id: The account ID. :param List[InviteUser] users: (optional) A list of users to be invited. :param List[InviteUserIamPolicy] iam_policy: (optional) A list of IAM policies. :param List[str] access_groups: (optional) A list of access groups. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `UserList` object """ if account_id is None: raise ValueError('account_id must be provided') if users is not None: users = [convert_model(x) for x in users] if iam_policy is not None: iam_policy = [convert_model(x) for x in iam_policy] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='invite_users') headers.update(sdk_headers) data = { 'users': users, 'iam_policy': iam_policy, 'access_groups': access_groups } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' path_param_keys = ['account_id'] path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/accounts/{account_id}/users'.format(**path_param_dict) request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request) return response
def edit_load_balancer_pool( self, pool_identifier: str, *, name: str = None, check_regions: List[str] = None, origins: List['LoadBalancerPoolReqOriginsItem'] = None, description: str = None, minimum_origins: int = None, enabled: bool = None, monitor: str = None, notification_email: str = None, **kwargs) -> DetailedResponse: """ Edit a configured pool. Edit a specific configured load balancer pool. :param str pool_identifier: pool identifier. :param str name: (optional) name. :param List[str] check_regions: (optional) regions check. :param List[LoadBalancerPoolReqOriginsItem] origins: (optional) origins. :param str description: (optional) desc. :param int minimum_origins: (optional) The minimum number of origins that must be healthy for this pool to serve traffic. :param bool enabled: (optional) enabled/disabled. :param str monitor: (optional) monitor. :param str notification_email: (optional) notification email. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `LoadBalancerPoolReq` object """ if pool_identifier is None: raise ValueError('pool_identifier must be provided') if origins is not None: origins = [convert_model(x) for x in origins] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V0', operation_id='edit_load_balancer_pool') headers.update(sdk_headers) data = { 'name': name, 'check_regions': check_regions, 'origins': origins, 'description': description, 'minimum_origins': minimum_origins, 'enabled': enabled, 'monitor': monitor, 'notification_email': notification_email } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/load_balancers/pools/{1}'.format( *self.encode_path_vars(self.crn, pool_identifier)) request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response
def detach_tag(self, resources: List['Resource'], *, tag_name: str = None, tag_names: List[str] = None, account_id: str = None, tag_type: str = None, **kwargs) -> DetailedResponse: """ Detach tags. Detaches one or more tags from one or more resources. To detach a `user` tag on a resource you must have the permissions listed in the [Granting users access to tag resources](https://cloud.ibm.com/docs/account?topic=account-access) documentation. To detach a `service` tag you must be an authorized Service. If that is the case, then you can detach a `service` tag with your registered `prefix` from any resource in any account. The account ID must be set through the `account_id` query parameter. :param List[Resource] resources: List of resources on which the tag or tags should be detached. :param str tag_name: (optional) The name of the tag to detach. :param List[str] tag_names: (optional) An array of tag names to detach. :param str account_id: (optional) The ID of the billing account where the resources to be un-tagged lives. It is a required parameter if `tag_type` is set to `service`, otherwise it is inferred from the authorization IAM token. :param str tag_type: (optional) The type of the tag. Supported values are `user` and `service`. `service` is not supported for `providers=ims`. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `TagResults` object """ if resources is None: raise ValueError('resources must be provided') resources = [convert_model(x) for x in resources] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='detach_tag') headers.update(sdk_headers) params = {'account_id': account_id, 'tag_type': tag_type} data = { 'resources': resources, 'tag_name': tag_name, 'tag_names': tag_names } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' url = '/v3/tags/detach' request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request) return response
def update_rate_limit(self, rate_limit_identifier: str, *, threshold: int = None, period: int = None, action: 'RatelimitInputAction' = None, match: 'RatelimitInputMatch' = None, disabled: bool = None, description: str = None, bypass: List['RatelimitInputBypassItem'] = None, correlate: 'RatelimitInputCorrelate' = None, **kwargs) -> DetailedResponse: """ Update a rate limit. Update an existing rate limit for a given zone under a service instance. :param str rate_limit_identifier: Identifier of rate limit. :param int threshold: (optional) The threshold that triggers the rate limit mitigations, combine with period. i.e. threshold per period. :param int period: (optional) The time in seconds to count matching traffic. If the count exceeds threshold within this period the action will be performed. :param RatelimitInputAction action: (optional) action. :param RatelimitInputMatch match: (optional) Determines which traffic the rate limit counts towards the threshold. Needs to be one of "request" or "response" objects. :param bool disabled: (optional) Whether this ratelimit is currently disabled. :param str description: (optional) A note that you can use to describe the reason for a rate limit. :param List[RatelimitInputBypassItem] bypass: (optional) Criteria that would allow the rate limit to be bypassed, for example to express that you shouldn't apply a rate limit to a given set of URLs. :param RatelimitInputCorrelate correlate: (optional) Enable NAT based rate limits. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `RatelimitResp` object """ if rate_limit_identifier is None: raise ValueError('rate_limit_identifier must be provided') if action is not None: action = convert_model(action) if match is not None: match = convert_model(match) if bypass is not None: bypass = [ convert_model(x) for x in bypass ] if correlate is not None: correlate = convert_model(correlate) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_rate_limit') headers.update(sdk_headers) data = { 'threshold': threshold, 'period': period, 'action': action, 'match': match, 'disabled': disabled, 'description': description, 'bypass': bypass, 'correlate': correlate } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/v1/{0}/zones/{1}/rate_limits/{2}'.format(*self.encode_path_vars(self.crn, self.zone_identifier, rate_limit_identifier)) request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response