Skip to content

Instantly share code, notes, and snippets.

View BedrosovaYulia's full-sized avatar

Yuliya Bedrosova BedrosovaYulia

View GitHub Profile
@BedrosovaYulia
BedrosovaYulia / copy_b24_leads.py
Last active July 25, 2019 08:45
AWS Lambda & Bitrix24 example1
import json
from botocore.vendored import requests
from urllib.parse import parse_qs
def lambda_handler(event, context):
data=parse_qs(event['params'])#параметры приходят согласно настройкам меппинга в гетавее
event=data['event'][0]
key=data['auth[application_token]'][0]
@BedrosovaYulia
BedrosovaYulia / PostTracking.py
Last active July 29, 2019 06:33
AWS Lambda Function for the Russian Post tracking via SOAP client
import json
from zeep import Client
def lambda_handler(event, context):
url = 'https://tracking.russianpost.ru/rtm34?wsdl'
barcode = event['barcode']
my_login = '****************'
my_password = '**************'
@BedrosovaYulia
BedrosovaYulia / B24ListItemUpdate.py
Created July 30, 2019 07:53
Updating Bitrix24 list item from AWS Lambda
import json
from botocore.vendored import requests
def lambda_handler(event, context):
ib_id=event['ib_id']
el_id=event['id']
data={
'IBLOCK_TYPE_ID': 'lists',
@BedrosovaYulia
BedrosovaYulia / PostTrackingB24.py
Created July 30, 2019 17:49
AWS Lambda Python3 Post Tracking function integrated with Bitrix24 - Example1
import json
from zeep import Client
from botocore.vendored import requests
from urllib.parse import parse_qs
def lambda_handler(event, context):
url = 'https://tracking.russianpost.ru/rtm34?wsdl'
barcode = event['barcode']
my_login = '************'
secrets_list = []
response = self._lambda_client.list_secrets()
for secrets_dict in response['SecretList']:
secrets_list.append(secrets_dict)
while "NextMarker" in response:
response = self._lambda_client.list_secrets(
Marker=response["NextMarker"])
for secrets_dict in response['SecretList']:
secrets_list.append(secrets_dict)
config_delegator = ConfigDelegator(event["resultToken"], CONFIG_CLIENT)
config_delegator.add_evaluation(
answer["type"], answer["annotation"], item['Name'], self._resource_type)
{
"invokingEvent": "{\"configurationItem\":{\"configurationItemCaptureTime\":\"2016-02-17T01:36:34.043Z\",\"awsAccountId\":\"123456789012\",\"configurationItemStatus\":\"OK\",\"resourceId\":\"i-00000000\",\"ARN\":\"arn:aws:ec2:us-east-2:123456789012:instance/i-00000000\",\"awsRegion\":\"us-east-2\",\"availabilityZone\":\"us-east-2a\",\"resourceType\":\"AWS::EC2::Instance\",\"tags\":{\"Foo\":\"Bar\"},\"relationships\":[{\"resourceId\":\"eipalloc-00000000\",\"resourceType\":\"AWS::EC2::EIP\",\"name\":\"Is attached to ElasticIp\"}],\"configuration\":{\"foo\":\"bar\"}},\"messageType\":\"ConfigurationItemChangeNotification\"}",
"ruleParameters": "{\"myParameterKey\":\"myParameterValue\"}",
"resultToken": "myResultToken",
"eventLeftScope": false,
"executionRoleArn": "arn:aws:iam::123456789012:role/config-role",
"configRuleArn": "arn:aws:config:us-east-2:123456789012:config-rule/config-rule-0123456",
"configRuleName": "change-triggered-config-rule",
"configRuleId": "config-rule-01234
@staticmethod
def prepare_report(item):
"""Prepare report for answer to AWS Config"""
rotation_arn = item['RotationLambdaARN']
aa_days = item['RotationRules']['AutomaticallyAfterDays']
secret_name = item['Name']
if not rotation_arn:
answer = {
def add_b24_product(key, name, price, file_name, file_url):
import requests
import base64
image_64_encode = str(base64.b64encode(requests.get(file_url).content))[2:-1]
product_data = {
"fields" : {
"iblockId": 1,
<?
$arr_file=Array(
"name" => $_FILES[IMAGE_ID][name],
"size" => $_FILES[IMAGE_ID][size],
"tmp_name" => $_FILES[IMAGE_ID][tmp_name],
"type" => "",
"old_file" => "",
"del" => "Y",
"MODULE_ID" => "iblock");
$fid = CFile::SaveFile($arr_file, "landings");