FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/gitlab/v4/objects/topics.py at feat/graphql · python-gitlab/python-gitlab · GitHub
python-gitlab
python-gitlab
Repository navigation
Code
Issues
16
(16)
Pull requests
15
(15)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
gitlab
/
v4
/
objects
/
topics.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (57 loc) · 2.15 KB
Breadcrumbs
python-gitlab
/
gitlab
/
v4
/
objects
/
topics.py
Copy path
File metadata and controls
69 lines (57 loc) · 2.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from
typing
import
Any
,
cast
,
Dict
,
TYPE_CHECKING
,
Union
from
gitlab
import
cli
from
gitlab
import
exceptions
as
exc
from
gitlab
import
types
from
gitlab
.
base
import
RESTManager
,
RESTObject
from
gitlab
.
mixins
import
CRUDMixin
,
ObjectDeleteMixin
,
SaveMixin
from
gitlab
.
types
import
RequiredOptional
__all__
=
[
"Topic"
,
"TopicManager"
,
]
class
Topic
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
pass
class
TopicManager
(
CRUDMixin
,
RESTManager
):
_path
=
"/topics"
_obj_cls
=
Topic
_create_attrs
=
RequiredOptional
(
# NOTE: The `title` field was added and is required in GitLab 15.0 or
# newer. But not present before that.
required
=
(
"name"
,),
optional
=
(
"avatar"
,
"description"
,
"title"
),
)
_update_attrs
=
RequiredOptional
(
optional
=
(
"avatar"
,
"description"
,
"name"
))
_types
=
{
"avatar"
:
types
.
ImageAttribute
}
def
get
(
self
,
id
:
Union
[
str
,
int
],
lazy
:
bool
=
False
,
**
kwargs
:
Any
)
->
Topic
:
return
cast
(
Topic
,
super
().
get
(
id
=
id
,
lazy
=
lazy
,
**
kwargs
))
@
cli
.
register_custom_action
(
"TopicManager"
,
mandatory
=
(
"source_topic_id"
,
"target_topic_id"
),
)
@
exc
.
on_http_error
(
exc
.
GitlabMRClosedError
)
def
merge
(
self
,
source_topic_id
:
Union
[
int
,
str
],
target_topic_id
:
Union
[
int
,
str
],
**
kwargs
:
Any
,
)
->
Dict
[
str
,
Any
]:
"""Merge two topics, assigning all projects to the target topic.
Args:
source_topic_id: ID of source project topic
target_topic_id: ID of target project topic
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabTopicMergeError: If the merge failed
Returns:
The merged topic data (*not* a RESTObject)
"""
path
=
f"
{
self
.
path
}
/merge"
data
=
{
"source_topic_id"
:
source_topic_id
,
"target_topic_id"
:
target_topic_id
,
}
server_data
=
self
.
gitlab
.
http_post
(
path
,
post_data
=
data
,
**
kwargs
)
if
TYPE_CHECKING
:
assert
isinstance
(
server_data
,
dict
)
return
server_data
Back
|
FazBrowse Home
|
New Git URL