How to use delete_platform_application method in localstack

Best Python code snippet using localstack_python

sns.py

Source: sns.py Github

copy

Full Screen

...80 deletedEndpoint = client.delete_endpoint(81 EndpointArn=endpointArn82 )83 return deletedEndpoint84 def delete_platform_application(self, client, platformApplicationArn):85 deletedPlatformApplication = client.delete_platform_application(86 PlatformApplicationArn=platformApplicationArn87 )88 return deletedPlatformApplication89 def push_apns(self, section, client, pushToken, message=None):90 key_str, cer_str, key_filename, cer_filename=('',)*491 config = configparser.ConfigParser()92 config.read(os.path.abspath(os.path.join(os.path.dirname(__file__), 'sns_config.ini')))93 if config.sections() != None:94 try:95 key_filename = config.get(section, 'apns_key_filename')96 cer_filename = config.get(section, 'apns_cer_filename')97 except:98 print("there's no filename to push notification.")99 return100 else:101 print("check your config...")102 return103 try:104 dir_name = os.path.dirname(__file__)105 key_path = os.path.abspath(os.path.join(dir_name, key_filename))106 cer_path = os.path.abspath(os.path.join(dir_name, cer_filename))107 key = open(key_path, 'r')108 cer = open(cer_path, 'r')109 key_str = key.read()110 cer_str = cer.read()111 if key_str == '' or cer_str == '':112 print('key file or cer file is invalid...')113 return114 except FileNotFoundError:115 print("please check if file is exist")116 return117 ### apns118 apns_attributes = {119 "PlatformCredential": key_str,120 "PlatformPrincipal": cer_str121 }122 #print (key_str + "---------")123 #print (cer_str + "---------")124 platform = 'APNS'125 responseAPNS = self.create_platform_application(client, platform, key_str, cer_str)126 print ("APNS: {}".format(responseAPNS))127 platformApplicationArn = responseAPNS['PlatformApplicationArn']128 platformEndpoint = self.create_endpoint(client, platformApplicationArn, pushToken)129 endpointArn = platformEndpoint['EndpointArn']130 print ("endpoint: {}".format(endpointArn))131 msg = self.get_push_message_apns(message)132 response = self.publish(client, endpointArn, msg)133 print ("published: {}".format(response))134 deletedEndpoint = self.delete_endpoint(client, endpointArn)135 print("delete endpoint: {}".format(deletedEndpoint))136 deletedPlatformApplication = self.delete_platform_application(client, platformApplicationArn)137 print("delete platform application: {}".format(deletedPlatformApplication))138 def push_gcm(self, section, client, registrationId, message=None):139 config = configparser.ConfigParser()140 config.read(os.path.abspath(os.path.join(os.path.dirname(__file__), 'sns_config.ini')))141 server_key = None142 if config.sections() != None:143 try:144 server_key = config.get(section, 'serverKey')145 print("serverKey: {}".format(server_key))146 except:147 print("there's no serverKey to create GCM application")148 return149 responseGCM = self.create_platform_application(client, 'GCM', server_key, '')150 print("PlatformApplicationArn: {}".format(responseGCM['PlatformApplicationArn']))151 platform_application_arn = responseGCM['PlatformApplicationArn']152 platformEndpoint = self.create_endpoint(client, platform_application_arn, registrationId)153 endpointArn = platformEndpoint['EndpointArn']154 print ("endpoint: {}".format(endpointArn))155 msg = self.get_push_message_gcm(message)156 response = self.publish(client, endpointArn, msg)157 print ("published: {}".format(response))158 deletedEndpoint = self.delete_endpoint(client, endpointArn)159 print("delete endpoint: {}".format(deletedEndpoint))160 deletedPlatformApplication = self.delete_platform_application(client, platform_application_arn)161 print("delete platform application: {}".format(deletedPlatformApplication))162if __name__ == "__main__":163 sns = SNSObject()164 client = boto3.client('sns')165 section = input("please insert sectdion name: ")166 selected = input("please insert your choice: (1 - GCM, 2 - APNS) ")167 pushToken = input('please insert your pushToken: ')168 message = input('please insert message. if you don\'t insert it, you\'ll get the default message: ')169 if selected == '2':170 if len(message) > 0:171 sns.push_apns(section, client, pushToken, message)172 else:173 sns.push_apns(section, client, pushToken)174 else:...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful