summaryrefslogtreecommitdiff
path: root/python-sailthru-client.spec
blob: e4b969b8a7db43ad4073b0c81a578ee0a5454d7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
%global _empty_manifest_terminate_build 0
Name:		python-sailthru-client
Version:	2.3.5
Release:	1
Summary:	Python client for Sailthru API
License:	MIT License
URL:		https://github.com/sailthru/sailthru-python-client
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/c9/8e/d4d4f18496f0edb83f2dd2fb16b01724f64f93df58ae4c09eafe43f2ece9/sailthru-client-2.3.5.tar.gz
BuildArch:	noarch


%description
For installation instructions, documentation, and examples please visit:
[http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/python](http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/python)
A simple client library to remotely access the `Sailthru REST API` as per [http://getstarted.sailthru.com/api](http://getstarted.sailthru.com/developers/api)
Python binding for [Sailthru API](http://getstarted.sailthru.com/api) based on [Requests](http://docs.python-requests.org/en/latest/)
It will make requests in `JSON` format.
Supports Python 2.6, 2.7, 3.3+
### Installation (Tested with Python 2.7.x)
Installing with [pip](http://www.pip-installer.org/):
    pip install sailthru-client
### Running tests
Install tox and then type:
    tox
### API Rate Limiting
Here is an example how to check rate limiting and throttle API calls based on that. For more information about Rate Limiting, see [Sailthru Documentation](https://getstarted.sailthru.com/new-for-developers-overview/api/api-technical-details/#Rate_Limiting)
```python
sailthru_client = SailthruClient(api_key, api_secret)
# ... make some api calls ...
rate_limit_info = sailthru_client.get_last_rate_limit_info('user', 'POST')
# get_last_rate_limit_info returns None if given endpoint/method wasn't triggered previously
if rate_limit_info is not None:
    limit = rate_limit_info['limit'];
    remaining = rate_limit_info['remaining'];
    reset_timestamp = rate_limit_info['reset'];
    # throttle api calls based on last rate limit info
    if remaining <= 0:
         seconds_till_reset = reset_timestamp - time.time()
         # sleep or perform other business logic before next user api call
         time.sleep(seconds_till_reset);
```

%package -n python3-sailthru-client
Summary:	Python client for Sailthru API
Provides:	python-sailthru-client
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-sailthru-client
For installation instructions, documentation, and examples please visit:
[http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/python](http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/python)
A simple client library to remotely access the `Sailthru REST API` as per [http://getstarted.sailthru.com/api](http://getstarted.sailthru.com/developers/api)
Python binding for [Sailthru API](http://getstarted.sailthru.com/api) based on [Requests](http://docs.python-requests.org/en/latest/)
It will make requests in `JSON` format.
Supports Python 2.6, 2.7, 3.3+
### Installation (Tested with Python 2.7.x)
Installing with [pip](http://www.pip-installer.org/):
    pip install sailthru-client
### Running tests
Install tox and then type:
    tox
### API Rate Limiting
Here is an example how to check rate limiting and throttle API calls based on that. For more information about Rate Limiting, see [Sailthru Documentation](https://getstarted.sailthru.com/new-for-developers-overview/api/api-technical-details/#Rate_Limiting)
```python
sailthru_client = SailthruClient(api_key, api_secret)
# ... make some api calls ...
rate_limit_info = sailthru_client.get_last_rate_limit_info('user', 'POST')
# get_last_rate_limit_info returns None if given endpoint/method wasn't triggered previously
if rate_limit_info is not None:
    limit = rate_limit_info['limit'];
    remaining = rate_limit_info['remaining'];
    reset_timestamp = rate_limit_info['reset'];
    # throttle api calls based on last rate limit info
    if remaining <= 0:
         seconds_till_reset = reset_timestamp - time.time()
         # sleep or perform other business logic before next user api call
         time.sleep(seconds_till_reset);
```

%package help
Summary:	Development documents and examples for sailthru-client
Provides:	python3-sailthru-client-doc
%description help
For installation instructions, documentation, and examples please visit:
[http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/python](http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/python)
A simple client library to remotely access the `Sailthru REST API` as per [http://getstarted.sailthru.com/api](http://getstarted.sailthru.com/developers/api)
Python binding for [Sailthru API](http://getstarted.sailthru.com/api) based on [Requests](http://docs.python-requests.org/en/latest/)
It will make requests in `JSON` format.
Supports Python 2.6, 2.7, 3.3+
### Installation (Tested with Python 2.7.x)
Installing with [pip](http://www.pip-installer.org/):
    pip install sailthru-client
### Running tests
Install tox and then type:
    tox
### API Rate Limiting
Here is an example how to check rate limiting and throttle API calls based on that. For more information about Rate Limiting, see [Sailthru Documentation](https://getstarted.sailthru.com/new-for-developers-overview/api/api-technical-details/#Rate_Limiting)
```python
sailthru_client = SailthruClient(api_key, api_secret)
# ... make some api calls ...
rate_limit_info = sailthru_client.get_last_rate_limit_info('user', 'POST')
# get_last_rate_limit_info returns None if given endpoint/method wasn't triggered previously
if rate_limit_info is not None:
    limit = rate_limit_info['limit'];
    remaining = rate_limit_info['remaining'];
    reset_timestamp = rate_limit_info['reset'];
    # throttle api calls based on last rate limit info
    if remaining <= 0:
         seconds_till_reset = reset_timestamp - time.time()
         # sleep or perform other business logic before next user api call
         time.sleep(seconds_till_reset);
```

%prep
%autosetup -n sailthru-client-2.3.5

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-sailthru-client -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 2.3.5-1
- Package Spec generated