Sharepoint Calendar get todays meetings (also recurrent ones) using python - python

My main goal is to get all today meetings in a sharepoint site (using python)
What i already do:
Filter meetings properly and get the specific fields
?$filter=fields/fRecurrence eq 1 and fields/EndDate ge '2022-11-08 18:00:00'&$expand=fields($select=Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType, Duration,TimeZone)
Request all meetings with all needed info, inclusive RecurrenceData (XLM)
There is the HTTP request and a response sample (some items and info as been removed):
REQUEST:
https://graph.microsoft.com/v1.0/sites/[SITE]/sites/[SITE]/lists/[ID]/items?$filter=fields/fRecurrence eq 1 and fields/EndDate ge '2022-11-08 18:00:00'&$expand=fields($select=Title,EventDate,EndDate,fRecurrence,RecurrenceData,Eventype, Duration,TimeZone)
RESPONSE:
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('[SITE]')/sites('[SITE]')/lists('[ID]')/items(fields(Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType,Duration,TimeZone,RecurrenceID,UniqueId))",
"value": [
{
"#odata.etag": "[TAG]",
"createdDateTime": "2019-09-09T17:42:40Z",
"eTag": "[TAG]",
"id": "2065",
"lastModifiedDateTime": "2019-09-10T08:51:34Z",
"webUrl": "https://[BUISNESS COMPANY].sharepoint.com/teams/[THINGS]/[THINGS]/Lists/[ROOM NAME]/2022_.000",
"createdBy": {
"user": {
"email": "[USER]",
"id": "[UID]",
"displayName": "[USER NAME]"
}
},
"lastModifiedBy": {
"user": {
"email": "[USER]",
"id": "[UID]",
"displayName": "[USER NAME]"
}
},
"parentReference": {
"id": "[ID]",
"siteId": "[BUISNESS COMPANY].sharepoint.com,[UID],[UID]"
},
"contentType": {
"id": "[THINGS]",
"name": "Event"
},
"https://graph.microsoft.com/v1.0/$metadata#sites('[SITE]')/sites('[SITE]')/lists('[ID]')/items(fields(Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType,Duration,TimeZone,RecurrenceID,UniqueId))/$entity",
"fields": {
"#odata.etag": "[TAG]",
"Title": "TITLE",
"EventDate": "2019-12-10T10:00:00Z",
"EndDate": "2169-09-12T10:00:00Z",
"fRecurrence": true,
"EventType": 1,
"Duration": 3600,
"RecurrenceData": "<recurrence><rule><firstDayOfWeek>mo</firstDayOfWeek><repeat><monthlyByDay tu=\"TRUE\" weekdayOfMonth=\"second\" monthFrequency=\"3\" /></repeat><repeatForever>FALSE</repeatForever></rule></recurrence>",
"TimeZone": [THINGS],
"UniqueId": "[UID]"
}
}, {...}, {...}, ... ]
In "EventDate": "2019-12-10T10:00:00Z" and the "EndDate": "2169-09-12T10:00:00Z" we have the start and end date of the "event", however this event is recurent, and have some "rules" -> RecurrenceData.
QUESTIONS:
HOW CAN I PARSE THE RULES (using python) TO KNOW IF WE HAVE THIS MEETING TODAY (2022-11-08 18:00:00) OR NOT;
2)OR, HOW CAN I MEKE A REQUEST TO THE SERVER AND RECEVE ONLY THE TODAYS MEETINGS (DOESN'T METTER IF RECURENT OR NOT)
Maybe usefull links:
In C#
Sherepoint recurrence data schema

Related

Is there a way to set public IP to delete when Azure VM is deleted using Python REST API?

I would like to Delete a VM with its attached resources including Network Interfaces, data disks, OS Disk and Public IP when a certain URL is called with a delete method:
http://servername.com/azr/vm_name/subscription_id/resource_group
However, I'm having some issues attaching the Public IP For deletion.
I'm doing this by:
Calling Azure GET VM API to get the VM and resource details and saving the response JSON into a variable "response_json"
{
"name": "TestAZR",
"id": "/subscriptions/xx-xxx-xx/resourceGroups/xxx-xxx-xx/providers/Microsoft.Compute/virtualMachines/TestAZR",
"type": "Microsoft.Compute/virtualMachines",
"location": "eastus",
"properties": {
"vmId": "xxx-xxx-xxx",
"hardwareProfile": {
"vmSize": "Standard_DS1_v2"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-datacenter-gensecond",
"version": "latest"
},
"osDisk": {
"osType": "Windows",
"name": "TestAZR_disk1",
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "xx",
"id": "/subscriptions/xx-xxx/resourceGroups/xx=xxx=x/providers/Microsoft.Compute/disks/TestAZR_disk1
},
"deleteOption": "Detach",
"diskSizeGB": 127
},
"dataDisks": [
{
"lun": 0,
"name": "TestAZR_DataDisk_0",
"createOption": "Attach",
"caching": "ReadOnly",
"writeAcceleratorEnabled": false,
"managedDisk": {
"storageAccountType": "Premium_LRS",
"id": "/subscriptions/xx-xxx-/resourceGroups/xx-xxx-x/providers/Microsoft.Compute/disks/TestAZR_DataDisk_0"
},
"deleteOption": "Detach",
"diskSizeGB": 1024,
"toBeDetached": false
},
{
"lun": 1,
"name": "TestAZR_DataDisk_1",
"createOption": "Attach",
"caching": "ReadOnly",
"writeAcceleratorEnabled": false,
"managedDisk": {
"storageAccountType": "Premium_LRS",
"id": "/subscriptions/xx-xxx-x/resourceGroups/xx-xxx-xx/providers/Microsoft.Compute/disks/TestAZR_DataDisk_1"
},
"deleteOption": "Detach",
"diskSizeGB": 1024,
"toBeDetached": false
}
]
},
"osProfile": {
"computerName": "TestAZR",
"adminUsername": "AAAA",
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true,
"patchSettings": {
"patchMode": "AutomaticByOS",
"assessmentMode": "ImageDefault",
"enableHotpatching": false
},
"enableVMAgentPlatformUpdates": false
},
"secrets": [],
"allowExtensionOperations": true,
"requireGuestProvisionSignal": true
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/xx-xxx-x/resourceGroups/xx-xxx-x/providers/Microsoft.Network/networkInterfaces/testazrexecute35_z1",
"properties": {
"deleteOption": "Detach"
}
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
},
"provisioningState": "Succeeded",
"timeCreated": "2022-09-15T19:04:13.2910488+00:00"
},
"zones": [
"1"
]
}
Modifying the response_json setting each "DeleteOption" with "Delete" so they get deleted with the VM
Sending the response_json in a PATCH API with the request.
Deleting VM with the DELETE VM API
This works for deleting VM along with Network Interface, Data Disks and OS Disk but Public IP doesn't seem to be deleted with Network Interface automatically.
So I tried this alternatively:
I use the GET Network interface API that contains the Public IP name inside:
{
"name": "testazr845_z1",
"id": "/subscriptions/xx-xxx-xx/resourceGroups/xx-xxx-xx/providers/Microsoft.Network/networkInterfaces/testazr845_z1",
"etag": "W/\"xx-xxx-xx\"",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "xx-xxx-",
"ipConfigurations": [
{
"name": "ipconfig1",
"id": "/subscriptions/xxx-xxxx-xx/resourceGroups/xxx-xxx-xx/providers/Microsoft.Network/networkInterfaces/testazr845_z1/ipConfigurations/ipconfig1",
"etag": "W/\"xxx-xxx-xx\"",
"type": "Microsoft.Network/networkInterfaces/ipConfigurations",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"name": "TestAZR-ip",
"id": "/subscriptions/xxx-xxx-x/resourceGroups/xx-xxx-xx/providers/Microsoft.Network/publicIPAddresses/TestAZR-ip",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "xx-xxxx-xx",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4,
"ipTags": [],
"ipConfiguration": {
"id": "/subscriptions/xxx-xxxx-x/resourceGroups/xx-xxx-xx/providers/Microsoft.Network/networkInterfaces/testazr845_z1/ipConfigurations/ipconfig1"
},
"deleteOption": "Detach"
},
"type": "Microsoft.Network/publicIPAddresses",
"sku": {
"name": "Basic",
"tier": "Regional"
}
},
"subnet": {
"id": "/subscriptions/xx-xxxx-xx/resourceGroups/VPCxAzrDev/providers/Microsoft.Network/virtualNetworks/xx-xx/subnets/alphatest_ase_subnet"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": [],
"internalDomainNameSuffix": ""
},
"macAddress": "",
"enableAcceleratedNetworking":,
"vnetEncryptionSupported":,
"enableIPForwarding":,
"primary":,
"virtualMachine": {
"id": "/subscriptions/xx-xxx-xx/resourceGroups/xxx-xxx/providers/Microsoft.Compute/virtualMachines/TestAZR"
},
"hostedWorkloads": [],
"tapConfigurations": [],
"nicType": "Standard",
"allowPort25Out": true
},
"type": "Microsoft.Network/networkInterfaces",
"location": "eastus",
"kind": "Regular"
}
I save that response into a variable json "network_interface_json", and in it I modify it with {"DeleteOption" : "Delete"} for the Public IP
I send this json in the PATCH API that's listed for deleting resources with VM
https://learn.microsoft.com/en-us/azure/virtual-machines/delete?tabs=rest2%2Ccli3%2Cportal4%2Cportal5
However I'm getting the following error message when sending this request:
{
"error": {
"code": "LinkedAuthorizationFailed",
"message": "The client '123124-12312-xx' with object id '1231-xx-xx' has permission to perform action 'Microsoft.Network/networkInterfaces/write' on scope '/subscriptions/xxx-xx-xx/resourceGroups/xx-xx-x/providers/Microsoft.Network/networkInterfaces/AZRTEST; however, it does not have permission to perform action 'Microsoft.Network/virtualNetworks/subnets/join/action' on the linked scope(s) '/subscriptions/xx-xxx-x/resourceGroups/VPCxAzureDevelopment/providers/Microsoft.Network/virtualNetworks/VPCxAzureDevelopment-eastus/subnets/xxx-xxx-subnet' or the linked scope(s) are invalid."
}
}
So it seems to be a permissions issue? Or maybe the json I'm using isn't correct to send for PATCH API? I've tried removing the subnet part but this doesn't seem to work, open to any suggestions.

Google Calendar API Recurrent Event, EXDate not working

I want to create a recurrent event into Google Calendar with one day exclusive. I used Google Calendar APi explorer.
Below is the Request Data
{
"end": {
"dateTime": "2020-02-24T19:00:00+05:00",
"timeZone": "Asia/Karachi"
},
"start": {
"dateTime": "2020-02-24T18:30:00+05:00",
"timeZone": "Asia/Karachi"
},
"description": "PSL live Streaming ..",
"summary": "PSL live Streaming ..",
"location": "National Stadium Karachi",
"recurrence": [
"RRULE:FREQ=DAILY;UNTIL=20200229T185959Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU",
"EXDATE;VALUE=DATE:20200225"
],
"reminders": {
"useDefault": false,
"overrides": [
{
"method": "email",
"minutes": 15
},
{
"method": "popup",
"minutes": 15
}
]
}
I got response
{
"kind": "calendar#event",
"status": "confirmed",
"summary": "PSL live Streaming ..",
"description": "PSL live Streaming ..",
"location": "National Stadium Karachi",
"start": {
"dateTime": "2020-02-24T18:30:00+05:00",
"timeZone": "Asia/Karachi"
},
"end": {
"dateTime": "2020-02-24T19:00:00+05:00",
"timeZone": "Asia/Karachi"
},
"recurrence": [
"EXDATE;VALUE=DATE:20200225",
"RRULE:FREQ=DAILY;UNTIL=20200229T185959Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU"
],
"sequence": 0,
"reminders": {
"useDefault": false,
"overrides": [
{
"method": "email",
"minutes": 15
},
{
"method": "popup",
"minutes": 15
}
]
}
}
This event should not be created on 25th, but when i go to google calendar is see event is also created on 25h.
Any hint, what's been wrong here?
You provided a dateTime in start and end, and a date in EXDATE.
Since you provided a dateTime for start and end, you should also provide a dateTime in EXDATE, and the time part should match the one you provided in start. Otherwise, the API won't know what event to exclude.
That is to say, the recurrence should be like this:
"RRULE:FREQ=DAILY;UNTIL=20200229T185959Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU",
"EXDATE;TZID=Asia/Karachi:20200225T183000"
Reference:
RFC5545

django - iterate between json response objects

I have a response object that I am receiving from an api call. The response has several objects that are returned in a single call. What I want to do is grab information from each of the objects returned and store them in varialbes to use them within the application. I know to grab info from a json response when it returns a single objects but I am getting confused with multiples objects... I know how to automate the iteration process through something like a forloop... it wont iterate.
here is a sample response that I am getting:
I want to grab the _id from both items.
{
'user':"<class 'synapse_pay_rest.models.users.user.User'>(id=..622d)",
'json':{
'_id':'..6e80',
'_links':{
'self':{
'href':'https://uat-api.synapsefi.com/v3.1/users/..22d/nodes/..56e80'
}
},
'allowed':'CREDIT-AND-DEBIT',
'client':{
'id':'..26a34',
'name':'Charlie Brown LLC'
},
'extra':{
'note':None,
'other':{
},
'supp_id':''
},
'info':{
'account_num':'8902',
'address':'PO BOX 85139, RICHMOND, VA, US',
'balance':{
'amount':'750.00',
'currency':'USD'
},
'bank_long_name':'CAPITAL ONE N.A.',
'bank_name':'CAPITAL ONE N.A.',
'class':'SAVINGS',
'match_info':{
'email_match':'not_found',
'name_match':'not_found',
'phonenumber_match':'not_found'
},
'name_on_account':' ',
'nickname':'SynapsePay Test Savings Account - 8902',
'routing_num':'6110',
'type':'BUSINESS'
},
<class 'synapse_pay_rest.models.nodes.ach_us_node.AchUsNode'>({
'user':"<class 'synapse_pay_rest.models.users.user.User'>(id=..622d)",
'json':{
'_id':'..56e83',
'_links':{
'self':{
'href':'https://uat-api.synapsefi.com/v3.1/users/..d622d/nodes/..6e83'
}
},
'allowed':'CREDIT-AND-DEBIT',
'client':{
'id':'599378ec6aef1b0021026a34',
'name':'Charlie Brown LLC'
},
'extra':{
'note':None,
'other':{
},
'supp_id':''
},
'info':{
'account_num':'8901',
'address':'PO BOX 85139, RICHMOND, VA, US',
'balance':{
'amount':'800.00',
'currency':'USD'
},
'bank_long_name':'CAPITAL ONE N.A.',
'bank_name':'CAPITAL ONE N.A.',
'class':'CHECKING',
'match_info':{
'email_match':'not_found',
'name_match':'not_found',
'phonenumber_match':'not_found'
},
'name_on_account':' ',
'nickname':'SynapsePay Test Checking Account - 8901',
'routing_num':'6110',
'type':'BUSINESS'
},
})
Here is the code that I have:
It wont grab any values...
the iteration needs to be done to the nodes variable which is hte json response object.
def listedLinkAccounts(request):
currentUser = loggedInUser(request)
currentProfile = Profile.objects.get(user = currentUser)
user_id = currentProfile.synapse_id
synapseUser = SynapseUser.by_id(client, str(user_id))
options = {
'page':1,
'per_page':20,
'type': 'ACH-US',
}
nodes = Node.all(synapseUser, **options)
print(nodes)
response = nodes
_id = response["_id"]
print(_id)
return nodes
here is a sample api response from the api documenation:
{
"error_code": "0",
"http_code": "200",
"limit": 20,
"node_count": 5,
"nodes": [
{
"_id": "594e5c694d1d62002f17e3dc",
"_links": {
"self": {
"href": "https://uat-api.synapsefi.com/v3.1/users/594e0fa2838454002ea317a0/nodes/594e5c694d1d62002f17e3dc"
}
},
"allowed": "CREDIT-AND-DEBIT",
"client": {
"id": "589acd9ecb3cd400fa75ac06",
"name": "SynapseFI"
},
"extra": {
"other": {},
"supp_id": "ABC124"
},
"info": {
"account_num": "7443",
"address": "PLACE DE LA REPUBLIQUE 4 CROIX 59170 FR",
"balance": {
"amount": "0.00",
"currency": "USD"
},
"bank_long_name": "3 SUISSES INTERNATIONAL",
"bank_name": "3 SUISSES INTERNATIONAL",
"name_on_account": " ",
"nickname": "Some Account"
},
"is_active": true,
"timeline": [
{
"date": 1498307689471,
"note": "Node created."
},
{
"date": 1498307690130,
"note": "Unable to send micro deposits as node type is not ACH-US."
}
],
"type": "WIRE-INT",
"user_id": "594e0fa2838454002ea317a0"
},
{
...
},
{
...
},
...
],
"page": 1,
"page_count": 1,
"success": true
}

How to get the ID of the parent comment (facebook Graph API)?

When sending a request
https://graph.facebook.com/v2.1/123456898765432/comments?access_token=TOKEN&pretty=1&filter=stream&limit=1&summary=1
I get an answer
{
"data": [
{
"created_time": "2015-06-17T10:32:04+0000",
"from": {
"name": "First Name",
"id": "12345678987654"
},
"message": "Message",
"can_remove": true,
"like_count": 0,
"user_likes": false,
"id": "123456898765432_123456789765433"
}
],
"paging": {
"cursors": {
"before": "...",
"after": "..."
},
},
"summary": {
"order": "chronological",
"total_count": 2532
}
}
But if the comment of the second level, I do not know the ID of the parent comment, and I can not answer it programmatically.
Maybe there are some arguments that can be specified, and additional data comment?
I found that there is still an argument metadata = 1
But it shows additional information counter on the object, and there is also no parent ID
I just had this problem and it seems that you can get the parent comment.
request
111791572258237_803009099803144?fields=comments.filter(stream).limit(50){message,id,from,parent}
(the ACCESS_TOKEN was omitted)
response
{
"message": "Sim, está acontecendo com várias pessoas. A Valve vai arrumar logo, provavelmente",
"id": "803009099803144_803075496463171",
"from": {
"name": "Jonathan Gouvea",
"id": "1218897258138073"
},
"parent": {
"created_time": "2016-01-28T19:58:39+0000",
"from": {
"name": "César Rodryguês",
"id": "552640601571460"
},
"message": "Dota ta fechando o de vcs quando vai entra na partida ?",
"id": "803009099803144_803068649797189"
}
},

How to fetch next page from REST API responses

EDIT - Here is the 1st object/record in the response. I get a total of 20 records, including this:
Note: The response has been parsed to remove unicode i.e. u' and has ' replaced by " to make this into a valid json.
{
"jobs": {
"_total": 1811,
"_count": 20,
"_start": 0,
"values": [{
"siteJobUrl": "xxx",
"company": {
"id": 21836,
"name": "CyberCoders"
},
"postingDate": {
"year": 2013,
"day": 10,
"month": 6
},
"descriptionSnippet": "Software Engineer- Hadoop, HDFS, HBaseWe are a well known consumer product development company and we are looking to add a Hadoop Engineer to our Engineering team. You will be working with the latest and greatest technologies to design, develop, and implement connectivity products that allow efficient exchange of data between our core database engine and the Hadoop ecosystem.What you need for thi",
"expirationDate": {
"year": 2013,
"day": 10,
"month": 7
},
"position": {
"industries": {
"_total": 1,
"values": [{
"code": "4",
"id": 4,
"name": "Computer Software"
}]
},
"title": "Software Engineer- Hadoop, HDFS, HBase",
"experienceLevel": {
"code": "2",
"name": "Entry level"
},
"location": {
"country": {
"code": "us"
},
"name": "Greater Pittsburgh Area"
},
"jobFunctions": {
"_total": 1,
"values": [{
"code": "it",
"name": "Information Technology"
}]
},
"jobType": {
"code": "F",
"name": "Full-time"
}
},
"customerJobCode": "CCW-ssehadooppaccw",
"locationDescription": "Pittsburgh, PA",
"jobPoster": {
"headline": "Senior Executive Technical Recruiter at CyberCoders (949)885-5121 chelsea.whalen#cybercoders.com",
"lastName": "W.",
"id": "y2zfe5j76F",
"firstName": "Chelsea"
},
"id": 6007298
},
I am trying to use the below python library to make a job search api call to the linkedin REST API.
https://github.com/ozgur/python-linkedin/
I can access 1st page output just fine. But when I increment the start to point to next page, I still get the same response. What am I missing here?
Here is my code snippet:
authentication = LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL,
PERMISSIONS.enums.values())
.......
application = LinkedInApplication(authentication)
........
# This is my request
response = application.search_job(
selectors=[{'jobs':
['id',
'customer-job-code',
'posting-date','expiration-date',
{'company':['id','name']},
{'position':['title',
'location',
'job-functions.',
'industries',
'job-type',
'experience-level']},
'skills-and-experience',
'description-snippet',
'salary',
{'job-poster':['id',
'first-name',
'last-name',
'headline']},
'referral-bonus',
'site-job-url',
'location-description']}],
params={'keywords': 'hadoop','count': 20},
headers={'start':20})
I had posted the query on linkedin developer forum too - http://developer.linkedin.com/forum/new-python-client-oauth-20
But got no response. I am new to python which is making it further difficult for me.
Appreciate your help.

Categories

Resources