wp-python 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wp_python/__init__.py +31 -0
- wp_python/auth.py +174 -0
- wp_python/client.py +293 -0
- wp_python/endpoints/__init__.py +43 -0
- wp_python/endpoints/application_passwords.py +235 -0
- wp_python/endpoints/autosaves.py +106 -0
- wp_python/endpoints/base.py +117 -0
- wp_python/endpoints/blocks.py +107 -0
- wp_python/endpoints/categories.py +91 -0
- wp_python/endpoints/comments.py +127 -0
- wp_python/endpoints/media.py +164 -0
- wp_python/endpoints/menus.py +120 -0
- wp_python/endpoints/pages.py +109 -0
- wp_python/endpoints/plugins.py +89 -0
- wp_python/endpoints/post_types.py +61 -0
- wp_python/endpoints/posts.py +131 -0
- wp_python/endpoints/revisions.py +121 -0
- wp_python/endpoints/search.py +81 -0
- wp_python/endpoints/settings.py +55 -0
- wp_python/endpoints/statuses.py +56 -0
- wp_python/endpoints/tags.py +79 -0
- wp_python/endpoints/taxonomies.py +41 -0
- wp_python/endpoints/themes.py +51 -0
- wp_python/endpoints/users.py +129 -0
- wp_python/exceptions.py +79 -0
- wp_python/models/__init__.py +49 -0
- wp_python/models/base.py +65 -0
- wp_python/models/category.py +41 -0
- wp_python/models/comment.py +75 -0
- wp_python/models/media.py +108 -0
- wp_python/models/menu.py +83 -0
- wp_python/models/page.py +80 -0
- wp_python/models/plugin.py +36 -0
- wp_python/models/post.py +112 -0
- wp_python/models/settings.py +32 -0
- wp_python/models/tag.py +38 -0
- wp_python/models/taxonomy.py +49 -0
- wp_python/models/theme.py +50 -0
- wp_python/models/user.py +82 -0
- wp_python-0.1.3.dist-info/METADATA +99 -0
- wp_python-0.1.3.dist-info/RECORD +43 -0
- wp_python-0.1.3.dist-info/WHEEL +4 -0
- wp_python-0.1.3.dist-info/licenses/LICENSE +19 -0
wp_python/models/page.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Page models."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from pydantic import Field, field_validator
|
|
7
|
+
|
|
8
|
+
from .base import WordPressModel, RenderedContent, parse_datetime
|
|
9
|
+
from .post import PostStatus
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Page(WordPressModel):
|
|
13
|
+
"""WordPress Page object."""
|
|
14
|
+
|
|
15
|
+
id: int
|
|
16
|
+
date: datetime | None = None
|
|
17
|
+
date_gmt: datetime | None = None
|
|
18
|
+
guid: RenderedContent | None = None
|
|
19
|
+
modified: datetime | None = None
|
|
20
|
+
modified_gmt: datetime | None = None
|
|
21
|
+
slug: str = ""
|
|
22
|
+
status: PostStatus = PostStatus.DRAFT
|
|
23
|
+
type: str = "page"
|
|
24
|
+
link: str = ""
|
|
25
|
+
title: RenderedContent | None = None
|
|
26
|
+
content: RenderedContent | None = None
|
|
27
|
+
excerpt: RenderedContent | None = None
|
|
28
|
+
author: int = 0
|
|
29
|
+
featured_media: int = 0
|
|
30
|
+
parent: int = 0
|
|
31
|
+
menu_order: int = 0
|
|
32
|
+
comment_status: str = "closed"
|
|
33
|
+
ping_status: str = "closed"
|
|
34
|
+
template: str = ""
|
|
35
|
+
meta: dict[str, Any] = Field(default_factory=dict)
|
|
36
|
+
|
|
37
|
+
@field_validator("date", "date_gmt", "modified", "modified_gmt", mode="before")
|
|
38
|
+
@classmethod
|
|
39
|
+
def parse_dates(cls, v: Any) -> datetime | None:
|
|
40
|
+
return parse_datetime(v)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class PageCreate(WordPressModel):
|
|
44
|
+
"""Data for creating a new page."""
|
|
45
|
+
|
|
46
|
+
title: str | None = None
|
|
47
|
+
content: str | None = None
|
|
48
|
+
excerpt: str | None = None
|
|
49
|
+
status: PostStatus = PostStatus.DRAFT
|
|
50
|
+
author: int | None = None
|
|
51
|
+
featured_media: int | None = None
|
|
52
|
+
parent: int | None = None
|
|
53
|
+
menu_order: int | None = None
|
|
54
|
+
comment_status: str | None = None
|
|
55
|
+
ping_status: str | None = None
|
|
56
|
+
template: str | None = None
|
|
57
|
+
meta: dict[str, Any] | None = None
|
|
58
|
+
slug: str | None = None
|
|
59
|
+
date: datetime | str | None = None
|
|
60
|
+
password: str | None = None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class PageUpdate(WordPressModel):
|
|
64
|
+
"""Data for updating a page."""
|
|
65
|
+
|
|
66
|
+
title: str | None = None
|
|
67
|
+
content: str | None = None
|
|
68
|
+
excerpt: str | None = None
|
|
69
|
+
status: PostStatus | None = None
|
|
70
|
+
author: int | None = None
|
|
71
|
+
featured_media: int | None = None
|
|
72
|
+
parent: int | None = None
|
|
73
|
+
menu_order: int | None = None
|
|
74
|
+
comment_status: str | None = None
|
|
75
|
+
ping_status: str | None = None
|
|
76
|
+
template: str | None = None
|
|
77
|
+
meta: dict[str, Any] | None = None
|
|
78
|
+
slug: str | None = None
|
|
79
|
+
date: datetime | str | None = None
|
|
80
|
+
password: str | None = None
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Plugin models."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from .base import WordPressModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Plugin(WordPressModel):
|
|
11
|
+
"""WordPress Plugin object."""
|
|
12
|
+
|
|
13
|
+
plugin: str = ""
|
|
14
|
+
status: str = "inactive"
|
|
15
|
+
name: str = ""
|
|
16
|
+
plugin_uri: str = ""
|
|
17
|
+
author: str = ""
|
|
18
|
+
author_uri: str = ""
|
|
19
|
+
description: dict[str, str] = Field(default_factory=dict)
|
|
20
|
+
version: str = ""
|
|
21
|
+
network_only: bool = False
|
|
22
|
+
requires_wp: str = ""
|
|
23
|
+
requires_php: str = ""
|
|
24
|
+
textdomain: str = ""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PluginActivate(WordPressModel):
|
|
28
|
+
"""Data for activating a plugin."""
|
|
29
|
+
|
|
30
|
+
status: str = "active"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class PluginDeactivate(WordPressModel):
|
|
34
|
+
"""Data for deactivating a plugin."""
|
|
35
|
+
|
|
36
|
+
status: str = "inactive"
|
wp_python/models/post.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""Post models."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from enum import Enum
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from pydantic import Field, field_validator
|
|
8
|
+
|
|
9
|
+
from .base import WordPressModel, RenderedContent, parse_datetime
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class PostStatus(str, Enum):
|
|
13
|
+
"""Post status options."""
|
|
14
|
+
|
|
15
|
+
PUBLISH = "publish"
|
|
16
|
+
FUTURE = "future"
|
|
17
|
+
DRAFT = "draft"
|
|
18
|
+
PENDING = "pending"
|
|
19
|
+
PRIVATE = "private"
|
|
20
|
+
TRASH = "trash"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class PostFormat(str, Enum):
|
|
24
|
+
"""Post format options."""
|
|
25
|
+
|
|
26
|
+
STANDARD = "standard"
|
|
27
|
+
ASIDE = "aside"
|
|
28
|
+
CHAT = "chat"
|
|
29
|
+
GALLERY = "gallery"
|
|
30
|
+
LINK = "link"
|
|
31
|
+
IMAGE = "image"
|
|
32
|
+
QUOTE = "quote"
|
|
33
|
+
STATUS = "status"
|
|
34
|
+
VIDEO = "video"
|
|
35
|
+
AUDIO = "audio"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Post(WordPressModel):
|
|
39
|
+
"""WordPress Post object."""
|
|
40
|
+
|
|
41
|
+
id: int
|
|
42
|
+
date: datetime | None = None
|
|
43
|
+
date_gmt: datetime | None = None
|
|
44
|
+
guid: RenderedContent | None = None
|
|
45
|
+
modified: datetime | None = None
|
|
46
|
+
modified_gmt: datetime | None = None
|
|
47
|
+
slug: str = ""
|
|
48
|
+
status: PostStatus = PostStatus.DRAFT
|
|
49
|
+
type: str = "post"
|
|
50
|
+
link: str = ""
|
|
51
|
+
title: RenderedContent | None = None
|
|
52
|
+
content: RenderedContent | None = None
|
|
53
|
+
excerpt: RenderedContent | None = None
|
|
54
|
+
author: int = 0
|
|
55
|
+
featured_media: int = 0
|
|
56
|
+
comment_status: str = "open"
|
|
57
|
+
ping_status: str = "open"
|
|
58
|
+
sticky: bool = False
|
|
59
|
+
template: str = ""
|
|
60
|
+
format: PostFormat = PostFormat.STANDARD
|
|
61
|
+
meta: dict[str, Any] = Field(default_factory=dict)
|
|
62
|
+
categories: list[int] = Field(default_factory=list)
|
|
63
|
+
tags: list[int] = Field(default_factory=list)
|
|
64
|
+
|
|
65
|
+
@field_validator("date", "date_gmt", "modified", "modified_gmt", mode="before")
|
|
66
|
+
@classmethod
|
|
67
|
+
def parse_dates(cls, v: Any) -> datetime | None:
|
|
68
|
+
return parse_datetime(v)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class PostCreate(WordPressModel):
|
|
72
|
+
"""Data for creating a new post."""
|
|
73
|
+
|
|
74
|
+
title: str | None = None
|
|
75
|
+
content: str | None = None
|
|
76
|
+
excerpt: str | None = None
|
|
77
|
+
status: PostStatus = PostStatus.DRAFT
|
|
78
|
+
author: int | None = None
|
|
79
|
+
featured_media: int | None = None
|
|
80
|
+
comment_status: str | None = None
|
|
81
|
+
ping_status: str | None = None
|
|
82
|
+
format: PostFormat | None = None
|
|
83
|
+
sticky: bool | None = None
|
|
84
|
+
categories: list[int] | None = None
|
|
85
|
+
tags: list[int] | None = None
|
|
86
|
+
meta: dict[str, Any] | None = None
|
|
87
|
+
template: str | None = None
|
|
88
|
+
slug: str | None = None
|
|
89
|
+
date: datetime | str | None = None
|
|
90
|
+
password: str | None = None
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class PostUpdate(WordPressModel):
|
|
94
|
+
"""Data for updating a post."""
|
|
95
|
+
|
|
96
|
+
title: str | None = None
|
|
97
|
+
content: str | None = None
|
|
98
|
+
excerpt: str | None = None
|
|
99
|
+
status: PostStatus | None = None
|
|
100
|
+
author: int | None = None
|
|
101
|
+
featured_media: int | None = None
|
|
102
|
+
comment_status: str | None = None
|
|
103
|
+
ping_status: str | None = None
|
|
104
|
+
format: PostFormat | None = None
|
|
105
|
+
sticky: bool | None = None
|
|
106
|
+
categories: list[int] | None = None
|
|
107
|
+
tags: list[int] | None = None
|
|
108
|
+
meta: dict[str, Any] | None = None
|
|
109
|
+
template: str | None = None
|
|
110
|
+
slug: str | None = None
|
|
111
|
+
date: datetime | str | None = None
|
|
112
|
+
password: str | None = None
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Settings models."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from .base import WordPressModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Settings(WordPressModel):
|
|
11
|
+
"""WordPress Site Settings."""
|
|
12
|
+
|
|
13
|
+
title: str = ""
|
|
14
|
+
description: str = ""
|
|
15
|
+
url: str = ""
|
|
16
|
+
email: str = ""
|
|
17
|
+
timezone: str = ""
|
|
18
|
+
date_format: str = ""
|
|
19
|
+
time_format: str = ""
|
|
20
|
+
start_of_week: int = 0
|
|
21
|
+
language: str = ""
|
|
22
|
+
use_smilies: bool = True
|
|
23
|
+
default_category: int = 1
|
|
24
|
+
default_post_format: str = ""
|
|
25
|
+
posts_per_page: int = 10
|
|
26
|
+
default_ping_status: str = "open"
|
|
27
|
+
default_comment_status: str = "open"
|
|
28
|
+
show_on_front: str = "posts"
|
|
29
|
+
page_on_front: int = 0
|
|
30
|
+
page_for_posts: int = 0
|
|
31
|
+
site_logo: int | None = None
|
|
32
|
+
site_icon: int | None = None
|
wp_python/models/tag.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Tag models."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from .base import WordPressModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Tag(WordPressModel):
|
|
11
|
+
"""WordPress Tag object."""
|
|
12
|
+
|
|
13
|
+
id: int
|
|
14
|
+
count: int = 0
|
|
15
|
+
description: str = ""
|
|
16
|
+
link: str = ""
|
|
17
|
+
name: str = ""
|
|
18
|
+
slug: str = ""
|
|
19
|
+
taxonomy: str = "post_tag"
|
|
20
|
+
meta: dict[str, Any] = Field(default_factory=dict)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TagCreate(WordPressModel):
|
|
24
|
+
"""Data for creating a new tag."""
|
|
25
|
+
|
|
26
|
+
name: str
|
|
27
|
+
description: str | None = None
|
|
28
|
+
slug: str | None = None
|
|
29
|
+
meta: dict[str, Any] | None = None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class TagUpdate(WordPressModel):
|
|
33
|
+
"""Data for updating a tag."""
|
|
34
|
+
|
|
35
|
+
name: str | None = None
|
|
36
|
+
description: str | None = None
|
|
37
|
+
slug: str | None = None
|
|
38
|
+
meta: dict[str, Any] | None = None
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Taxonomy models."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from .base import WordPressModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TaxonomyLabels(WordPressModel):
|
|
11
|
+
"""Labels for a taxonomy."""
|
|
12
|
+
|
|
13
|
+
name: str = ""
|
|
14
|
+
singular_name: str = ""
|
|
15
|
+
search_items: str = ""
|
|
16
|
+
popular_items: str | None = None
|
|
17
|
+
all_items: str = ""
|
|
18
|
+
parent_item: str | None = None
|
|
19
|
+
parent_item_colon: str | None = None
|
|
20
|
+
edit_item: str = ""
|
|
21
|
+
view_item: str = ""
|
|
22
|
+
update_item: str = ""
|
|
23
|
+
add_new_item: str = ""
|
|
24
|
+
new_item_name: str = ""
|
|
25
|
+
separate_items_with_commas: str | None = None
|
|
26
|
+
add_or_remove_items: str | None = None
|
|
27
|
+
choose_from_most_used: str | None = None
|
|
28
|
+
not_found: str = ""
|
|
29
|
+
no_terms: str = ""
|
|
30
|
+
items_list_navigation: str = ""
|
|
31
|
+
items_list: str = ""
|
|
32
|
+
most_used: str = ""
|
|
33
|
+
back_to_items: str = ""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Taxonomy(WordPressModel):
|
|
37
|
+
"""WordPress Taxonomy object."""
|
|
38
|
+
|
|
39
|
+
name: str = ""
|
|
40
|
+
slug: str = ""
|
|
41
|
+
description: str = ""
|
|
42
|
+
types: list[str] = Field(default_factory=list)
|
|
43
|
+
hierarchical: bool = False
|
|
44
|
+
rest_base: str = ""
|
|
45
|
+
rest_namespace: str = "wp/v2"
|
|
46
|
+
labels: TaxonomyLabels | None = None
|
|
47
|
+
show_cloud: bool = False
|
|
48
|
+
visibility: dict[str, bool] = Field(default_factory=dict)
|
|
49
|
+
capabilities: dict[str, str] = Field(default_factory=dict)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Theme models."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from .base import WordPressModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ThemeSupports(WordPressModel):
|
|
11
|
+
"""Theme feature support."""
|
|
12
|
+
|
|
13
|
+
align_wide: bool = False
|
|
14
|
+
automatic_feed_links: bool = True
|
|
15
|
+
custom_background: bool | dict = False
|
|
16
|
+
custom_header: bool | dict = False
|
|
17
|
+
custom_logo: bool | dict = False
|
|
18
|
+
customize_selective_refresh_widgets: bool = False
|
|
19
|
+
dark_editor_style: bool = False
|
|
20
|
+
editor_color_palette: bool | list = False
|
|
21
|
+
editor_font_sizes: bool | list = False
|
|
22
|
+
editor_gradient_presets: bool | list = False
|
|
23
|
+
editor_styles: bool = False
|
|
24
|
+
html5: bool | list = False
|
|
25
|
+
formats: list[str] = Field(default_factory=list)
|
|
26
|
+
post_thumbnails: bool | list = True
|
|
27
|
+
responsive_embeds: bool = False
|
|
28
|
+
title_tag: bool = False
|
|
29
|
+
wp_block_styles: bool = False
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Theme(WordPressModel):
|
|
33
|
+
"""WordPress Theme object."""
|
|
34
|
+
|
|
35
|
+
stylesheet: str = ""
|
|
36
|
+
template: str = ""
|
|
37
|
+
author: dict[str, str] = Field(default_factory=dict)
|
|
38
|
+
author_uri: dict[str, str] = Field(default_factory=dict)
|
|
39
|
+
description: dict[str, str] = Field(default_factory=dict)
|
|
40
|
+
name: dict[str, str] = Field(default_factory=dict)
|
|
41
|
+
requires_php: str = ""
|
|
42
|
+
requires_wp: str = ""
|
|
43
|
+
screenshot: str = ""
|
|
44
|
+
tags: dict[str, list[str]] = Field(default_factory=dict)
|
|
45
|
+
textdomain: str = ""
|
|
46
|
+
theme_supports: ThemeSupports | None = None
|
|
47
|
+
theme_uri: dict[str, str] = Field(default_factory=dict)
|
|
48
|
+
version: str = ""
|
|
49
|
+
status: str = "inactive"
|
|
50
|
+
is_block_theme: bool = False
|
wp_python/models/user.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""User models."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from pydantic import Field
|
|
7
|
+
|
|
8
|
+
from .base import WordPressModel
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class UserRole(str, Enum):
|
|
12
|
+
"""Default WordPress user roles."""
|
|
13
|
+
|
|
14
|
+
ADMINISTRATOR = "administrator"
|
|
15
|
+
EDITOR = "editor"
|
|
16
|
+
AUTHOR = "author"
|
|
17
|
+
CONTRIBUTOR = "contributor"
|
|
18
|
+
SUBSCRIBER = "subscriber"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class UserCapabilities(WordPressModel):
|
|
22
|
+
"""User capabilities."""
|
|
23
|
+
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class User(WordPressModel):
|
|
28
|
+
"""WordPress User object."""
|
|
29
|
+
|
|
30
|
+
id: int
|
|
31
|
+
username: str = ""
|
|
32
|
+
name: str = ""
|
|
33
|
+
first_name: str = ""
|
|
34
|
+
last_name: str = ""
|
|
35
|
+
email: str = ""
|
|
36
|
+
url: str = ""
|
|
37
|
+
description: str = ""
|
|
38
|
+
link: str = ""
|
|
39
|
+
locale: str = ""
|
|
40
|
+
nickname: str = ""
|
|
41
|
+
slug: str = ""
|
|
42
|
+
registered_date: str = ""
|
|
43
|
+
roles: list[str] = Field(default_factory=list)
|
|
44
|
+
capabilities: dict[str, bool] = Field(default_factory=dict)
|
|
45
|
+
extra_capabilities: dict[str, bool] = Field(default_factory=dict)
|
|
46
|
+
avatar_urls: dict[str, str] = Field(default_factory=dict)
|
|
47
|
+
meta: dict[str, Any] = Field(default_factory=dict)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class UserCreate(WordPressModel):
|
|
51
|
+
"""Data for creating a new user."""
|
|
52
|
+
|
|
53
|
+
username: str
|
|
54
|
+
email: str
|
|
55
|
+
password: str
|
|
56
|
+
name: str | None = None
|
|
57
|
+
first_name: str | None = None
|
|
58
|
+
last_name: str | None = None
|
|
59
|
+
url: str | None = None
|
|
60
|
+
description: str | None = None
|
|
61
|
+
locale: str | None = None
|
|
62
|
+
nickname: str | None = None
|
|
63
|
+
slug: str | None = None
|
|
64
|
+
roles: list[str] | None = None
|
|
65
|
+
meta: dict[str, Any] | None = None
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class UserUpdate(WordPressModel):
|
|
69
|
+
"""Data for updating a user."""
|
|
70
|
+
|
|
71
|
+
email: str | None = None
|
|
72
|
+
password: str | None = None
|
|
73
|
+
name: str | None = None
|
|
74
|
+
first_name: str | None = None
|
|
75
|
+
last_name: str | None = None
|
|
76
|
+
url: str | None = None
|
|
77
|
+
description: str | None = None
|
|
78
|
+
locale: str | None = None
|
|
79
|
+
nickname: str | None = None
|
|
80
|
+
slug: str | None = None
|
|
81
|
+
roles: list[str] | None = None
|
|
82
|
+
meta: dict[str, Any] | None = None
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wp_python
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: A Python client for interacting with the WordPress REST API.
|
|
5
|
+
Author-email: Andrew <andrew.neher1@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.12
|
|
11
|
+
Requires-Dist: hatch>=1.16.3
|
|
12
|
+
Requires-Dist: httpx>=0.28.1
|
|
13
|
+
Requires-Dist: pydantic>=2.12.5
|
|
14
|
+
Requires-Dist: pytest-mock>=3.15.1
|
|
15
|
+
Requires-Dist: pytest>=9.0.2
|
|
16
|
+
Requires-Dist: respx>=0.22.0
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# WordPress REST API Python Client
|
|
20
|
+
|
|
21
|
+
A full-featured Python 3.12 interface to the WordPress REST API.
|
|
22
|
+
|
|
23
|
+
## Overview
|
|
24
|
+
|
|
25
|
+
This library provides a comprehensive, type-safe Python client for interacting with WordPress sites via the REST API. It supports all major WordPress endpoints including posts, pages, media, users, comments, categories, tags, settings, plugins, themes, menus, and more.
|
|
26
|
+
|
|
27
|
+
## Project Structure
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
src/wordpress_api/
|
|
31
|
+
├── __init__.py # Main exports
|
|
32
|
+
├── client.py # WordPressClient main class
|
|
33
|
+
├── auth.py # Authentication handlers
|
|
34
|
+
├── exceptions.py # Custom exceptions
|
|
35
|
+
├── models/ # Pydantic data models
|
|
36
|
+
│ ├── post.py
|
|
37
|
+
│ ├── page.py
|
|
38
|
+
│ ├── media.py
|
|
39
|
+
│ ├── user.py
|
|
40
|
+
│ ├── comment.py
|
|
41
|
+
│ ├── category.py
|
|
42
|
+
│ ├── tag.py
|
|
43
|
+
│ └── ...
|
|
44
|
+
└── endpoints/ # API endpoint classes
|
|
45
|
+
├── posts.py
|
|
46
|
+
├── pages.py
|
|
47
|
+
├── media.py
|
|
48
|
+
├── users.py
|
|
49
|
+
├── comments.py
|
|
50
|
+
└── ...
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from wordpress_api import WordPressClient, ApplicationPasswordAuth
|
|
57
|
+
|
|
58
|
+
# Authenticate with WordPress Application Passwords
|
|
59
|
+
auth = ApplicationPasswordAuth("username", "xxxx xxxx xxxx xxxx")
|
|
60
|
+
client = WordPressClient("https://your-site.com", auth=auth)
|
|
61
|
+
|
|
62
|
+
# List posts
|
|
63
|
+
posts = client.posts.list()
|
|
64
|
+
|
|
65
|
+
# Create a post
|
|
66
|
+
from wordpress_api.models import PostCreate, PostStatus
|
|
67
|
+
post = client.posts.create(PostCreate(
|
|
68
|
+
title="Hello World",
|
|
69
|
+
content="<p>My first post!</p>",
|
|
70
|
+
status=PostStatus.PUBLISH
|
|
71
|
+
))
|
|
72
|
+
|
|
73
|
+
# Get current user
|
|
74
|
+
me = client.users.me()
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Features
|
|
78
|
+
|
|
79
|
+
- **Full CRUD Support**: Posts, Pages, Media, Users, Comments, Categories, Tags
|
|
80
|
+
- **Authentication**: Application Passwords, Basic Auth, JWT
|
|
81
|
+
- **Type Safety**: Pydantic models for all WordPress objects
|
|
82
|
+
- **Pagination**: Automatic iteration through all results
|
|
83
|
+
- **Media Upload**: Upload files from path or file objects
|
|
84
|
+
- **Custom Post Types**: Access any registered custom post type
|
|
85
|
+
- **Block Editor**: Access block types and patterns
|
|
86
|
+
- **Error Handling**: Typed exceptions for all API errors
|
|
87
|
+
|
|
88
|
+
## Dependencies
|
|
89
|
+
|
|
90
|
+
- httpx: Modern HTTP client
|
|
91
|
+
- pydantic: Data validation using Python type annotations
|
|
92
|
+
|
|
93
|
+
## Authentication Setup
|
|
94
|
+
|
|
95
|
+
1. Go to your WordPress site
|
|
96
|
+
2. Navigate to Users → Your Profile
|
|
97
|
+
3. Scroll to "Application Passwords"
|
|
98
|
+
4. Create a new application password
|
|
99
|
+
5. Use it with `ApplicationPasswordAuth`
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
wp_python/__init__.py,sha256=LhpUecDxy_WU4rSJ7UHn6s8FQE70kjCszQ1nsX_T9bI,643
|
|
2
|
+
wp_python/auth.py,sha256=s84OZbrr2-Vq9ICGMfr4CCcUQIVis3Cy_8tTh8kVKTM,5358
|
|
3
|
+
wp_python/client.py,sha256=94JKVfDIcxhKzypjvrlZ5ak4BDMPm4zWF-3T0-ljkfo,9818
|
|
4
|
+
wp_python/exceptions.py,sha256=lmRbpRT2lC1EK7u1nPCrM4xc96ZNomk7GY7mz7e_x1c,2273
|
|
5
|
+
wp_python/endpoints/__init__.py,sha256=xxDVw6j_LXgxpfRrBryIcXVcyEyq0fRzoc11oKlkxU0,1230
|
|
6
|
+
wp_python/endpoints/application_passwords.py,sha256=PrP_a6VV24D3a8zciN4KhJh1GKrXhS7hH53JNIOEvhA,7691
|
|
7
|
+
wp_python/endpoints/autosaves.py,sha256=YTeE7K6GXDeFTQsIrUm65Wk8uLqS6THt1j-iR2LSup8,3607
|
|
8
|
+
wp_python/endpoints/base.py,sha256=W0v3g5ZXn_s2N4Y45NRbZuTwFiDEiQj8Uf3JHe5IGWs,3798
|
|
9
|
+
wp_python/endpoints/blocks.py,sha256=QZ4n8teiNm8lTFGSMGKy5KPsQMC3cBqQesXC-3vF1fk,3609
|
|
10
|
+
wp_python/endpoints/categories.py,sha256=7NSx1oMu66A3ZDjDfI-Hip_Ca2BpeIDHknu_Yfw61zE,3029
|
|
11
|
+
wp_python/endpoints/comments.py,sha256=bBdVXsUiBzjceIuIFXehXt3dt8-Gn5wwQ60MXV0_sMo,4473
|
|
12
|
+
wp_python/endpoints/media.py,sha256=aFFG02eWM-IPk9NhXltgyMQj5DOEtheyc1FQlwQa10I,5456
|
|
13
|
+
wp_python/endpoints/menus.py,sha256=xFZ902x1z_1-cmNET2ZaWQnErEY0W4qjNRcuoglrVZk,4153
|
|
14
|
+
wp_python/endpoints/pages.py,sha256=UVcJBHaVQt9fpMe2zxpvpTgQJIT6ATIyOpbYGYp8q50,3666
|
|
15
|
+
wp_python/endpoints/plugins.py,sha256=W4-LSRw8nYb7soMKJ0kPdiOu22rgBIxk9C0tR6YGTZk,2661
|
|
16
|
+
wp_python/endpoints/post_types.py,sha256=3Veo1f6qBmdy_4GYq_sF3VG6yS7o9LugUTvK4T_VQ98,1901
|
|
17
|
+
wp_python/endpoints/posts.py,sha256=5p-gn9257XcQc0QBW6yMmvyTPs7oCEzDfxvEMexeN2o,4947
|
|
18
|
+
wp_python/endpoints/revisions.py,sha256=KWTf41Nct3cQ5JMHW5XPi_mcmmnYaUrAW6fsgJ7_tx4,3900
|
|
19
|
+
wp_python/endpoints/search.py,sha256=mtJIKRAoSWHsO18TWGYC4oEnweZW5PzZbhRXXhDEKE8,2540
|
|
20
|
+
wp_python/endpoints/settings.py,sha256=SSad5CuztEtdDUO3OQ9dddtPqq6BMbwyNi9fTQ5ZSXY,1577
|
|
21
|
+
wp_python/endpoints/statuses.py,sha256=l0ut-5yNhr7LljdPiyhNTOYnMSimZzPQnygEEZKhsos,1654
|
|
22
|
+
wp_python/endpoints/tags.py,sha256=MsUUZ5MmYTV3Hqs2hZcMgRE27m-w-Lre_pq3lfJvwLY,2446
|
|
23
|
+
wp_python/endpoints/taxonomies.py,sha256=tZImMsFuSJFqdOGlea7gOYX6JoFDEEEIu-HoKwuDkgc,1236
|
|
24
|
+
wp_python/endpoints/themes.py,sha256=JCfe6J_XBH9WvKmUrEa6NCSSwCcgCVZK87y2HLUpGLU,1504
|
|
25
|
+
wp_python/endpoints/users.py,sha256=ACwCfsElSz_wpjS-jhokOl_NAAV06_JQKr_C__8M0ow,4380
|
|
26
|
+
wp_python/models/__init__.py,sha256=JE4R3MQcIV-XL2MCwlwSAckfBgtS32dENBxmlMHtCDA,1165
|
|
27
|
+
wp_python/models/base.py,sha256=FTZXYGo7f7Zqi7IdyfGlkwVjasIDwbCh3-45vg_G6iw,1619
|
|
28
|
+
wp_python/models/category.py,sha256=ga1ihAfuQPVOIC3pJTj7igJg46A-7wOnj6nrlytqIWg,873
|
|
29
|
+
wp_python/models/comment.py,sha256=VT9jsDrJ93_XQet7q7T85LB20tSAmjHLU2PaqNrMUFQ,1924
|
|
30
|
+
wp_python/models/media.py,sha256=TieunrwtKBDTmZv4K3TP1nN2VJvoT5ZK1lEeLzUjSgw,2797
|
|
31
|
+
wp_python/models/menu.py,sha256=1slp-RxL2wFm1IpPIoleusSg5TpSiDjbYGaR-VTgZ2c,2082
|
|
32
|
+
wp_python/models/page.py,sha256=EDGDm5yrhUmA9YaL84CIrOvzrw5nWUefeybbz1JBeOI,2294
|
|
33
|
+
wp_python/models/plugin.py,sha256=fWkvuCtq_vWCAIB7L8MW9TtWPrQfr39_PNpHbHaSQPo,730
|
|
34
|
+
wp_python/models/post.py,sha256=WDRx16YCNkhkQZsHwNloNttgXBjQtK1CHFFDbIhMJWY,3039
|
|
35
|
+
wp_python/models/settings.py,sha256=U9U_Qbcr2McYW778YYzVobD8O5QW1VIhjzxljjqVz2o,743
|
|
36
|
+
wp_python/models/tag.py,sha256=3UzYQb-fO1QEpXTA4X8vIghnKccl5aR8yooaF92gjgE,758
|
|
37
|
+
wp_python/models/taxonomy.py,sha256=tZ31mBulU8NeSjpclbUVujqlsJB2WR4jjW6bO4ipTW0,1292
|
|
38
|
+
wp_python/models/theme.py,sha256=lLxbfWkxiHE6Zn4CsiRX8cSCtWmwxJwvgEvD2-KBzec,1552
|
|
39
|
+
wp_python/models/user.py,sha256=50xMTH8_2g5xLlnNhjXLGf9xrRg3IbkES1nVMblVmHk,1969
|
|
40
|
+
wp_python-0.1.3.dist-info/METADATA,sha256=XXP1No_qwZH2ZAO7G1oZJ6Wk1e_jnDUe_0pCEK-VxSg,3036
|
|
41
|
+
wp_python-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
42
|
+
wp_python-0.1.3.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
43
|
+
wp_python-0.1.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|