Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomasDOTwtf
hub
Commits
2a94dea0
Commit
2a94dea0
authored
8 months ago
by
Andreas Hubel
Browse files
Options
Downloads
Patches
Plain Diff
chore(schedulejson): add request header config option
parent
1de78d3e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/schedules/schedulejson.py
+11
-6
11 additions, 6 deletions
src/core/schedules/schedulejson.py
with
11 additions
and
6 deletions
src/core/schedules/schedulejson.py
+
11
−
6
View file @
2a94dea0
...
@@ -16,8 +16,10 @@ class ScheduleJSONSupport(BaseScheduleSupport):
...
@@ -16,8 +16,10 @@ class ScheduleJSONSupport(BaseScheduleSupport):
readonly
=
True
readonly
=
True
configuration_fields
=
{
configuration_fields
=
{
# 'key': (type, default value, mandatory, translation text)
'
feedback
'
:
(
'
bool
'
,
True
,
False
,
'
Enable/Disable feedback url generation
'
),
'
feedback
'
:
(
'
bool
'
,
True
,
False
,
'
Enable/Disable feedback url generation
'
),
'
kind
'
:
(
'
string
'
,
'
assembly
'
,
False
,
'
kind of events, either
"
assembly
"
or
"
official
"
or
"
sos
"
or
"
lightning
"'
),
'
kind
'
:
(
'
string
'
,
'
assembly
'
,
False
,
'
kind of events, either
"
assembly
"
or
"
official
"
or
"
sos
"
or
"
lightning
"'
),
'
headers
'
:
(
'
dict
'
,
{},
False
,
'
HTTP headers to send with the request e.g. Authorization
'
),
}
}
def
ready
(
self
):
def
ready
(
self
):
...
@@ -38,9 +40,12 @@ class ScheduleJSONSupport(BaseScheduleSupport):
...
@@ -38,9 +40,12 @@ class ScheduleJSONSupport(BaseScheduleSupport):
all events need to have an unique but stable identifier, i.e.
all events need to have an unique but stable identifier, i.e.
if the name of the event changes the identifier must not change!
if the name of the event changes the identifier must not change!
"""
"""
headers
=
{}
if
self
.
conf_value
(
'
headers
'
):
headers
=
self
.
conf_value
(
'
headers
'
)
schedule
=
ScheduleJSON
.
from_url
(
self
.
remote_url
,
l
anguage
=
'
en
'
)
schedule
=
ScheduleJSON
.
from_url
(
self
.
remote_url
,
headers
=
{
**
headers
,
'
Accept-L
anguage
'
:
'
en
'
}
)
schedule_de
=
ScheduleJSON
.
from_url
(
self
.
remote_url
,
l
anguage
=
'
de
'
,
event_map
=
True
)
schedule_de
=
ScheduleJSON
.
from_url
(
self
.
remote_url
,
headers
=
{
**
headers
,
'
Accept-L
anguage
'
:
'
de
'
}
,
event_map
=
True
)
instance
=
urlparse
(
schedule
.
get
(
'
base_url
'
,
self
.
remote_url
))
instance
=
urlparse
(
schedule
.
get
(
'
base_url
'
,
self
.
remote_url
))
host
=
f
'
//
{
instance
.
netloc
}
'
host
=
f
'
//
{
instance
.
netloc
}
'
...
@@ -101,8 +106,8 @@ class ScheduleJSON:
...
@@ -101,8 +106,8 @@ class ScheduleJSON:
self
.
_events
=
{
e
.
get
(
'
guid
'
):
e
for
e
in
self
.
events
()}
self
.
_events
=
{
e
.
get
(
'
guid
'
):
e
for
e
in
self
.
events
()}
@classmethod
@classmethod
def
from_url
(
cls
,
url
,
client
=
None
,
language
=
None
,
event_map
=
False
):
def
from_url
(
cls
,
url
,
client
=
None
,
headers
=
None
,
event_map
=
False
):
r
=
(
client
if
client
else
s
).
get
(
url
,
headers
=
{
'
Accept-Language
'
:
language
}
if
language
else
None
)
r
=
(
client
if
client
else
s
).
get
(
url
,
headers
=
headers
)
if
r
.
ok
is
False
:
if
r
.
ok
is
False
:
raise
Exception
(
f
'
Request failed, HTTP
{
r
.
status_code
}
.
'
)
raise
Exception
(
f
'
Request failed, HTTP
{
r
.
status_code
}
.
'
)
...
...
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