Get schedule from Garoon SOAP API with Python + Zeep

memorandum.

Previous article

Get user information from Garoon SOAP API with Python + Zeep https://qiita.com/yamashi6/items/d360546eb4ccf2495951

reference

Common specifications of Garoon SOAP API https://developer.cybozu.io/hc/ja/articles/202228464

Search for appointments https://developer.cybozu.io/hc/ja/articles/202235474

Source

from zeep import Client
from zeep import xsd

client = Client(wsdl='https://(Subdomain name).cybozu.com/g/index.csp?WSDL')

#You can't use schedule acquisition unless you bind
sc_client = client.bind('ScheduleService', 'SchedulePort')

header = xsd.ComplexType([
                xsd.Element('Action', xsd.String()),
                xsd.Element('Security', 
                    xsd.ComplexType([xsd.Element(
                        'UsernameToken',
                        xsd.ComplexType([
                            xsd.Element('Username', xsd.String()),
                            xsd.Element('Password', xsd.String()),
                        ])
                    )]
                )),

                xsd.Element('Timestamp', 
                    xsd.ComplexType([
                        xsd.Element('Created', xsd.String()),
                        xsd.Element('Expires', xsd.String()),
                    ])
                ),

                xsd.Element('Locale', xsd.String()),
            ])

header_value = header(
        Action="ScheduleSearchEvents", 
        #Changing users and passwords
        Security={'UsernameToken':{'Username':'','Password':''}}, 
        Timestamp={'Created':'2010-08-12T14:45:00Z','Expires':'2037-08-12T14:45:00Z'},
        Locale="jp")

#This way of writing is also OK
# header_value = header("ScheduleSearchEvents", 
#         {'UsernameToken':{'Username':'', 'Password':''}}, 
#         {'Created':'2010-08-12T14:45:00Z','Expires':'2037-08-12T14:45:00Z'},
#         'jp') 

request = xsd.Element('parameters',
            xsd.ComplexType([
                xsd.Attribute('text', xsd.String()),
                xsd.Attribute('start', xsd.String()),
                xsd.Attribute('end', xsd.String()),
                xsd.Attribute('title_search', xsd.Boolean()),
                xsd.Attribute('customer_search', xsd.Boolean()),
                xsd.Attribute('memo_search', xsd.Boolean()),
                xsd.Attribute('follow_search', xsd.Boolean()),
                xsd.Attribute('all_repeat_events', xsd.Boolean())])
        )


request_data = request("test","2019-06-06T02:00:00Z", "2019-07-07T02:00:00Z", True, False, False, False, False)

#This way of writing is also OK
# request_data = request(
#     text='test', 
#     start= "2019-06-06T02:00:00Z", 
#     end="2019-10-07T02:00:00Z",
#     title_search= True,
#     customer_search=False,
#     memo_search=False,
#     follow_search=False,
#     all_repeat_events=False   
# )

try:
    response = sc_client.ScheduleSearchEvents(request_data, _soapheaders=[header_value])
    #Returned in list
    print(response)

except:
    import traceback
    traceback.print_exc()

Execution result

Returned in list

[{
    'members': {
        'member': [
            {
                'user': {
                    'id': '1',
                    'order': 0,
                    '_attr_1': {
                        'name': 'Yamada Taro'
                    }
                },
                'organization': None,
                'facility': None,
                '_value_1': None,
                '_attr_1': None
            }
        ],
        '_value_1': None,
        '_attr_1': None
    },
    'observers': None,
    'customer': None,
    'repeat_info': None,
    'when': {
        '_attr_1': None,
        'datetime': [
            {
                '_value_1': None,
                'start': datetime.datetime(2019, 6, 20, 10, 0, tzinfo=<isodate.tzinfo.Utc object at 0x000001B4773B0F08>),
                'end': datetime.datetime(2019, 6, 20, 12, 0, tzinfo=<isodate.tzinfo.Utc object at 0x000001B4773B0F08>),
                'facility_id': None,
                '_attr_1': {
            }
            }
        ],
        'date': None
    },
    'follows': None,
    'file': [],
    'remove_file_id': [],
    '_value_1': None,
    'id': '11111',
    'event_type': 'normal',
    'version': '111111111',
    'public_type': 'public',
    'plan': 'Meeting',
    'detail': 'test',
    'description': 'test',
    'timezone': 'Asia/Tokyo',
    'end_timezone': 'Asia/Tokyo',
    'allday': False,
    'start_only': False,
    'hidden_private': None,
    'facility_using_purpose': None,
    '_attr_1': {
}
}]

Recommended Posts

Get schedule from Garoon SOAP API with Python + Zeep
Handle SOAP API from Python (Zeep)
Get reviews with python googlemap api
Get upcoming weather from python weather api
Get data from analytics API with Google API Client for python
Get html from element with Python selenium
[Note] Get data from PostgreSQL with Python
Get US stock price from Python with Web API with Raspberry Pi
[Python] Get Python package information with PyPI API
Get Gmail subject and body with Python and Gmail API
Get date with python
[First API] Try to get Qiita articles with Python
[Python] Get the text of the law from the e-GOV Law API
Get mail from Gmail and label it with Python3
[Python] Get user information and article information with Qiita API
Get data from database via ODBC with Python (Access)
Get country code with python
Use Trello API with python
Get Twitter timeline with python
Use Twitter API with Python
Get Youtube data with python
Get information with zabbix api
Web API with Python + Falcon
Get thread ID with python
Play RocketChat with API / Python
Get started with Python! ~ ② Grammar ~
Call the API with python3.
Use subsonic API with python3
Get stock price with Python
Get home directory with python
Get keyboard events with python
With skype, notify with skype from python!
Use e-Stat API from Python
Get Alembic information with Python
Get ranking with Rakuten API
Get your heart rate from the fitbit API in Python!
Get message from first offset with kafka consumer in python
Python: Extract file information from shared drive with Google Drive API
Get PowerShell commands from malware dynamic analysis site with BeautifulSoup + Python
Get started with Python! ~ ① Environment construction ~
Call C from Python with DragonFFI
Create Awaitable with Python / C API
Using Rstan from Python with PypeR
Install Python from source with Ansible
Create folders from '01' to '12' with python
Run Rotrics DexArm with python API
How to get followers and followers from python using the Mastodon API
Quine Post with Qiita API (Python)
Get the weather with Python requests
Get web screen capture with python
Get the weather with Python requests 2
Get one column from DataFrame with DataFrame
[Python] Get economic data with DataReader
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
How to get started with Python
Hit the Etherpad-lite API with Python
[python] Read information with Redmine API
Run Aprili from Python with Orange
[Small story] Get timestamp with Python
Use kabu Station® API from Python
Use the Flickr API from Python