Loading docs/gl_objects/pagesdomains.rst +36 −7 Original line number Diff line number Diff line ############# Pages domains ############# ####################### Pages and Pages domains ####################### Admin ===== Project pages ============= References ---------- * v4 API: + :class:`gitlab.v4.objects.ProjectPages` + :class:`gitlab.v4.objects.ProjectPagesManager` + :attr:`gitlab.v4.objects.Project.pages` * GitLab API: https://docs.gitlab.com/ee/api/pages.html Examples -------- Get Pages settings for a project:: pages = project.pages.get() Update Pages settings for a project:: project.pages.update(new_data={'pages_https_only': True}) Delete (unpublish) Pages for a project (admin only):: project.pages.delete() Pages domains (admin only) ========================== References ---------- Loading @@ -23,8 +52,8 @@ List all the existing domains (admin only):: domains = gl.pagesdomains.list() Project pages domain ==================== Project Pages domains ===================== References ---------- Loading gitlab/v4/objects/pages.py +30 −1 Original line number Diff line number Diff line from typing import Any, cast, Union from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin from gitlab.mixins import ( CRUDMixin, DeleteMixin, GetWithoutIdMixin, ListMixin, ObjectDeleteMixin, RefreshMixin, SaveMixin, UpdateMethod, UpdateMixin, ) from gitlab.types import RequiredOptional __all__ = [ Loading @@ -9,6 +19,8 @@ __all__ = [ "PagesDomainManager", "ProjectPagesDomain", "ProjectPagesDomainManager", "ProjectPages", "ProjectPagesManager", ] Loading Loading @@ -38,3 +50,20 @@ class ProjectPagesDomainManager(CRUDMixin, RESTManager): self, id: Union[str, int], lazy: bool = False, **kwargs: Any ) -> ProjectPagesDomain: return cast(ProjectPagesDomain, super().get(id=id, lazy=lazy, **kwargs)) class ProjectPages(ObjectDeleteMixin, RefreshMixin, RESTObject): _id_attr = None class ProjectPagesManager(DeleteMixin, UpdateMixin, GetWithoutIdMixin, RESTManager): _path = "/projects/{project_id}/pages" _obj_cls = ProjectPages _from_parent_attrs = {"project_id": "id"} _update_attrs = RequiredOptional( optional=("pages_unique_domain_enabled", "pages_https_only") ) _update_method: UpdateMethod = UpdateMethod.PATCH def get(self, **kwargs: Any) -> ProjectPages: return cast(ProjectPages, super().get(**kwargs)) gitlab/v4/objects/projects.py +2 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ from .notes import ProjectNoteManager # noqa: F401 from .notification_settings import ProjectNotificationSettingsManager # noqa: F401 from .package_protection_rules import ProjectPackageProtectionRuleManager from .packages import GenericPackageManager, ProjectPackageManager # noqa: F401 from .pages import ProjectPagesDomainManager # noqa: F401 from .pages import ProjectPagesDomainManager, ProjectPagesManager # noqa: F401 from .pipelines import ( # noqa: F401 ProjectPipeline, ProjectPipelineManager, Loading Loading @@ -216,6 +216,7 @@ class Project( notificationsettings: ProjectNotificationSettingsManager packages: ProjectPackageManager package_protection_rules: ProjectPackageProtectionRuleManager pages: ProjectPagesManager pagesdomains: ProjectPagesDomainManager pipelines: ProjectPipelineManager pipelineschedules: ProjectPipelineScheduleManager Loading tests/functional/api/test_projects.py +12 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,18 @@ def test_project_milestone_promotion(gl, group): ) def test_project_pages(project): pages = project.pages.get() assert pages.is_unique_domain_enabled is True project.pages.update(new_data={"pages_unique_domain_enabled": False}) pages.refresh() assert pages.is_unique_domain_enabled is False project.pages.delete() def test_project_pages_domains(gl, project): domain = project.pagesdomains.create({"domain": "foo.domain.com"}) assert domain in project.pagesdomains.list() Loading Loading
docs/gl_objects/pagesdomains.rst +36 −7 Original line number Diff line number Diff line ############# Pages domains ############# ####################### Pages and Pages domains ####################### Admin ===== Project pages ============= References ---------- * v4 API: + :class:`gitlab.v4.objects.ProjectPages` + :class:`gitlab.v4.objects.ProjectPagesManager` + :attr:`gitlab.v4.objects.Project.pages` * GitLab API: https://docs.gitlab.com/ee/api/pages.html Examples -------- Get Pages settings for a project:: pages = project.pages.get() Update Pages settings for a project:: project.pages.update(new_data={'pages_https_only': True}) Delete (unpublish) Pages for a project (admin only):: project.pages.delete() Pages domains (admin only) ========================== References ---------- Loading @@ -23,8 +52,8 @@ List all the existing domains (admin only):: domains = gl.pagesdomains.list() Project pages domain ==================== Project Pages domains ===================== References ---------- Loading
gitlab/v4/objects/pages.py +30 −1 Original line number Diff line number Diff line from typing import Any, cast, Union from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin from gitlab.mixins import ( CRUDMixin, DeleteMixin, GetWithoutIdMixin, ListMixin, ObjectDeleteMixin, RefreshMixin, SaveMixin, UpdateMethod, UpdateMixin, ) from gitlab.types import RequiredOptional __all__ = [ Loading @@ -9,6 +19,8 @@ __all__ = [ "PagesDomainManager", "ProjectPagesDomain", "ProjectPagesDomainManager", "ProjectPages", "ProjectPagesManager", ] Loading Loading @@ -38,3 +50,20 @@ class ProjectPagesDomainManager(CRUDMixin, RESTManager): self, id: Union[str, int], lazy: bool = False, **kwargs: Any ) -> ProjectPagesDomain: return cast(ProjectPagesDomain, super().get(id=id, lazy=lazy, **kwargs)) class ProjectPages(ObjectDeleteMixin, RefreshMixin, RESTObject): _id_attr = None class ProjectPagesManager(DeleteMixin, UpdateMixin, GetWithoutIdMixin, RESTManager): _path = "/projects/{project_id}/pages" _obj_cls = ProjectPages _from_parent_attrs = {"project_id": "id"} _update_attrs = RequiredOptional( optional=("pages_unique_domain_enabled", "pages_https_only") ) _update_method: UpdateMethod = UpdateMethod.PATCH def get(self, **kwargs: Any) -> ProjectPages: return cast(ProjectPages, super().get(**kwargs))
gitlab/v4/objects/projects.py +2 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ from .notes import ProjectNoteManager # noqa: F401 from .notification_settings import ProjectNotificationSettingsManager # noqa: F401 from .package_protection_rules import ProjectPackageProtectionRuleManager from .packages import GenericPackageManager, ProjectPackageManager # noqa: F401 from .pages import ProjectPagesDomainManager # noqa: F401 from .pages import ProjectPagesDomainManager, ProjectPagesManager # noqa: F401 from .pipelines import ( # noqa: F401 ProjectPipeline, ProjectPipelineManager, Loading Loading @@ -216,6 +216,7 @@ class Project( notificationsettings: ProjectNotificationSettingsManager packages: ProjectPackageManager package_protection_rules: ProjectPackageProtectionRuleManager pages: ProjectPagesManager pagesdomains: ProjectPagesDomainManager pipelines: ProjectPipelineManager pipelineschedules: ProjectPipelineScheduleManager Loading
tests/functional/api/test_projects.py +12 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,18 @@ def test_project_milestone_promotion(gl, group): ) def test_project_pages(project): pages = project.pages.get() assert pages.is_unique_domain_enabled is True project.pages.update(new_data={"pages_unique_domain_enabled": False}) pages.refresh() assert pages.is_unique_domain_enabled is False project.pages.delete() def test_project_pages_domains(gl, project): domain = project.pagesdomains.create({"domain": "foo.domain.com"}) assert domain in project.pagesdomains.list() Loading