Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyOTRS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Som Connexió
OTRS
PyOTRS
Commits
d51b030d
Commit
d51b030d
authored
8 years ago
by
Robert Habermann
Browse files
Options
Downloads
Patches
Plain Diff
add additional operations (WIP!)
parent
fab20de4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyotrs/lib.py
+65
-19
65 additions, 19 deletions
pyotrs/lib.py
with
65 additions
and
19 deletions
pyotrs/lib.py
+
65
−
19
View file @
d51b030d
...
...
@@ -18,12 +18,32 @@ import datetime
import
requests
OPERATION_MAPPING_DEFAULT
=
{
'
SessionCreate
'
:
{
'
RequestMethod
'
:
'
POST
'
,
'
Route
'
:
'
/Session
'
},
'
TicketCreate
'
:
{
'
RequestMethod
'
:
'
POST
'
,
'
Route
'
:
'
/Ticket
'
},
'
TicketGet
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/Ticket/:TicketID
'
},
'
TicketGetList
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/TicketList
'
},
'
TicketSearch
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/Ticket
'
},
'
TicketUpdate
'
:
{
'
RequestMethod
'
:
'
PATCH
'
,
'
Route
'
:
'
/Ticket/:TicketID
'
}
'
SessionCreate
'
:
{
'
RequestMethod
'
:
'
POST
'
,
'
Route
'
:
'
/Session
'
},
'
TicketCreate
'
:
{
'
RequestMethod
'
:
'
POST
'
,
'
Route
'
:
'
/Ticket
'
},
'
TicketGet
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/Ticket/:TicketID
'
},
'
TicketGetList
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/TicketList
'
},
'
TicketSearch
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/Ticket
'
},
'
TicketUpdate
'
:
{
'
RequestMethod
'
:
'
PATCH
'
,
'
Route
'
:
'
/Ticket/:TicketID
'
},
'
LinkAdd
'
:
{
'
RequestMethod
'
:
'
POST
'
,
'
Route
'
:
'
/LinkAdd
'
},
'
LinkDelete
'
:
{
'
RequestMethod
'
:
'
DELETE
'
,
'
Route
'
:
'
/LinkDelete
'
},
'
LinkDeleteAll
'
:
{
'
RequestMethod
'
:
'
DELETE
'
,
'
Route
'
:
'
/LinkDeleteAll
'
},
'
LinkList
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/LinkList
'
},
'
PossibleLinkList
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/PossibleLinkList
'
},
'
PossibleObjectsList
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/PossibleObjectsList
'
},
'
PossibleTypesList
'
:
{
'
RequestMethod
'
:
'
GET
'
,
'
Route
'
:
'
/PossibleTypesList
'
}
}
TYPE_MAPPING_DEFAULT
=
{
...
...
@@ -32,7 +52,14 @@ TYPE_MAPPING_DEFAULT = {
'
TicketGet
'
:
'
Ticket
'
,
'
TicketGetList
'
:
'
Ticket
'
,
'
TicketSearch
'
:
'
TicketID
'
,
'
TicketUpdate
'
:
'
TicketID
'
'
TicketUpdate
'
:
'
TicketID
'
,
'
LinkAdd
'
:
'
LinkAdd
'
,
'
LinkDelete
'
:
'
LinkDelete
'
,
'
LinkDeleteAll
'
:
'
LinkDeleteAll
'
,
'
LinkList
'
:
'
LinkList
'
,
'
PossibleLinkList
'
:
'
PossibleLinkList
'
,
'
PossibleObjectsList
'
:
'
PossibleObjectsList
'
,
'
PossibleTypesList
'
:
'
PossibleTypesList
'
}
...
...
@@ -676,6 +703,9 @@ class Client(object):
raise
ArgumentMissingError
(
"
webservicename
"
)
self
.
webservicename
=
webservicename
# TODO 2016-30-10 (RH): check Name and Documentation
self
.
webservicename_link
=
"
GenericLinkConnectorREST
"
if
not
session_timeout
:
self
.
session_timeout
=
28800
# 8 hours is OTRS default
else
:
...
...
@@ -1163,7 +1193,10 @@ class Client(object):
"""
route
=
self
.
operation_map
[
self
.
operation
][
"
Route
"
]
if
not
(
route
.
startswith
(
"
/Ticket
"
)
or
route
.
startswith
(
"
/Session
"
)):
if
not
(
route
.
startswith
(
"
/Ticket
"
)
or
route
.
startswith
(
"
/Session
"
)
or
route
.
startswith
(
"
/Possible
"
)
or
route
.
startswith
(
"
/Link
"
)):
raise
ValueError
(
"
Route misconfigured: {0}
"
.
format
(
route
))
if
"
:
"
in
route
:
...
...
@@ -1176,16 +1209,29 @@ class Client(object):
raise
ValueError
(
"
TicketID is None but Route requires
"
"
TicketID: {0}
"
.
format
(
route
))
self
.
_url
=
(
"
{0}/otrs/nph-genericinterface.pl/Webservice/
"
"
{1}{2}{3}
"
.
format
(
self
.
baseurl
,
self
.
webservicename
,
route
,
ticket_id
))
if
route
.
startswith
(
"
/Link
"
)
or
route
.
startswith
(
"
/Possible
"
):
self
.
_url
=
(
"
{0}/otrs/nph-genericinterface.pl/Webservice/
"
"
{1}{2}{3}
"
.
format
(
self
.
baseurl
,
self
.
webservicename_link
,
route
,
ticket_id
))
else
:
self
.
_url
=
(
"
{0}/otrs/nph-genericinterface.pl/Webservice/
"
"
{1}{2}{3}
"
.
format
(
self
.
baseurl
,
self
.
webservicename
,
route
,
ticket_id
))
else
:
self
.
_url
=
(
"
{0}/otrs/nph-genericinterface.pl/Webservice/
"
"
{1}{2}
"
.
format
(
self
.
baseurl
,
self
.
webservicename
,
route
))
if
route
.
startswith
(
"
/Link
"
)
or
route
.
startswith
(
"
/Possible
"
):
self
.
_url
=
(
"
{0}/otrs/nph-genericinterface.pl/Webservice/
"
"
{1}{2}
"
.
format
(
self
.
baseurl
,
self
.
webservicename_link
,
route
))
else
:
self
.
_url
=
(
"
{0}/otrs/nph-genericinterface.pl/Webservice/
"
"
{1}{2}
"
.
format
(
self
.
baseurl
,
self
.
webservicename
,
route
))
return
self
.
_url
...
...
@@ -1203,7 +1249,7 @@ class Client(object):
**requests.Response**: Response received after sending the request.
.. note::
Supported HTTP Methods: GET, HEAD, PATCH, POST, PUT
Supported HTTP Methods:
DELETE,
GET, HEAD, PATCH, POST, PUT
"""
if
not
payload
:
raise
ArgumentMissingError
(
"
payload
"
)
...
...
@@ -1214,7 +1260,7 @@ class Client(object):
http_method
=
self
.
operation_map
[
self
.
operation
][
"
RequestMethod
"
]
if
http_method
not
in
[
"
GET
"
,
"
HEAD
"
,
"
PATCH
"
,
"
POST
"
,
"
PUT
"
]:
if
http_method
not
in
[
"
DELETE
"
,
"
GET
"
,
"
HEAD
"
,
"
PATCH
"
,
"
POST
"
,
"
PUT
"
]:
raise
ValueError
(
"
invalid http_method
"
)
headers
=
{
"
Content-Type
"
:
"
application/json
"
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment