|
| 1 | +from gitlab.base import * # noqa |
| 2 | +from gitlab.exceptions import * # noqa |
| 3 | +from gitlab.mixins import * # noqa |
| 4 | +from gitlab import types |
| 5 | +from gitlab import utils |
| 6 | + |
| 7 | + |
| 8 | +class ApplicationAppearance(SaveMixin, RESTObject): |
| 9 | + _id_attr = None |
| 10 | + |
| 11 | + |
| 12 | +class ApplicationAppearanceManager(GetWithoutIdMixin, UpdateMixin, RESTManager): |
| 13 | + _path = "/application/appearance" |
| 14 | + _obj_cls = ApplicationAppearance |
| 15 | + _update_attrs = ( |
| 16 | + tuple(), |
| 17 | + ( |
| 18 | + "title", |
| 19 | + "description", |
| 20 | + "logo", |
| 21 | + "header_logo", |
| 22 | + "favicon", |
| 23 | + "new_project_guidelines", |
| 24 | + "header_message", |
| 25 | + "footer_message", |
| 26 | + "message_background_color", |
| 27 | + "message_font_color", |
| 28 | + "email_header_and_footer_enabled", |
| 29 | + ), |
| 30 | + ) |
| 31 | + |
| 32 | + @exc.on_http_error(exc.GitlabUpdateError) |
| 33 | + def update(self, id=None, new_data=None, **kwargs): |
| 34 | + """Update an object on the server. |
| 35 | +
|
| 36 | + Args: |
| 37 | + id: ID of the object to update (can be None if not required) |
| 38 | + new_data: the update data for the object |
| 39 | + **kwargs: Extra options to send to the server (e.g. sudo) |
| 40 | +
|
| 41 | + Returns: |
| 42 | + dict: The new object data (*not* a RESTObject) |
| 43 | +
|
| 44 | + Raises: |
| 45 | + GitlabAuthenticationError: If authentication is not correct |
| 46 | + GitlabUpdateError: If the server cannot perform the request |
| 47 | + """ |
| 48 | + new_data = new_data or {} |
| 49 | + data = new_data.copy() |
| 50 | + super(ApplicationAppearanceManager, self).update(id, data, **kwargs) |
| 51 | + |
| 52 | + |
| 53 | +class ApplicationSettings(SaveMixin, RESTObject): |
| 54 | + _id_attr = None |
| 55 | + |
| 56 | + |
| 57 | +class ApplicationSettingsManager(GetWithoutIdMixin, UpdateMixin, RESTManager): |
| 58 | + _path = "/application/settings" |
| 59 | + _obj_cls = ApplicationSettings |
| 60 | + _update_attrs = ( |
| 61 | + tuple(), |
| 62 | + ( |
| 63 | + "id", |
| 64 | + "default_projects_limit", |
| 65 | + "signup_enabled", |
| 66 | + "password_authentication_enabled_for_web", |
| 67 | + "gravatar_enabled", |
| 68 | + "sign_in_text", |
| 69 | + "created_at", |
| 70 | + "updated_at", |
| 71 | + "home_page_url", |
| 72 | + "default_branch_protection", |
| 73 | + "restricted_visibility_levels", |
| 74 | + "max_attachment_size", |
| 75 | + "session_expire_delay", |
| 76 | + "default_project_visibility", |
| 77 | + "default_snippet_visibility", |
| 78 | + "default_group_visibility", |
| 79 | + "outbound_local_requests_whitelist", |
| 80 | + "domain_whitelist", |
| 81 | + "domain_blacklist_enabled", |
| 82 | + "domain_blacklist", |
| 83 | + "external_authorization_service_enabled", |
| 84 | + "external_authorization_service_url", |
| 85 | + "external_authorization_service_default_label", |
| 86 | + "external_authorization_service_timeout", |
| 87 | + "user_oauth_applications", |
| 88 | + "after_sign_out_path", |
| 89 | + "container_registry_token_expire_delay", |
| 90 | + "repository_storages", |
| 91 | + "plantuml_enabled", |
| 92 | + "plantuml_url", |
| 93 | + "terminal_max_session_time", |
| 94 | + "polling_interval_multiplier", |
| 95 | + "rsa_key_restriction", |
| 96 | + "dsa_key_restriction", |
| 97 | + "ecdsa_key_restriction", |
| 98 | + "ed25519_key_restriction", |
| 99 | + "first_day_of_week", |
| 100 | + "enforce_terms", |
| 101 | + "terms", |
| 102 | + "performance_bar_allowed_group_id", |
| 103 | + "instance_statistics_visibility_private", |
| 104 | + "user_show_add_ssh_key_message", |
| 105 | + "file_template_project_id", |
| 106 | + "local_markdown_version", |
| 107 | + "asset_proxy_enabled", |
| 108 | + "asset_proxy_url", |
| 109 | + "asset_proxy_whitelist", |
| 110 | + "geo_node_allowed_ips", |
| 111 | + "allow_local_requests_from_hooks_and_services", |
| 112 | + "allow_local_requests_from_web_hooks_and_services", |
| 113 | + "allow_local_requests_from_system_hooks", |
| 114 | + ), |
| 115 | + ) |
| 116 | + |
| 117 | + @exc.on_http_error(exc.GitlabUpdateError) |
| 118 | + def update(self, id=None, new_data=None, **kwargs): |
| 119 | + """Update an object on the server. |
| 120 | +
|
| 121 | + Args: |
| 122 | + id: ID of the object to update (can be None if not required) |
| 123 | + new_data: the update data for the object |
| 124 | + **kwargs: Extra options to send to the server (e.g. sudo) |
| 125 | +
|
| 126 | + Returns: |
| 127 | + dict: The new object data (*not* a RESTObject) |
| 128 | +
|
| 129 | + Raises: |
| 130 | + GitlabAuthenticationError: If authentication is not correct |
| 131 | + GitlabUpdateError: If the server cannot perform the request |
| 132 | + """ |
| 133 | + new_data = new_data or {} |
| 134 | + data = new_data.copy() |
| 135 | + if "domain_whitelist" in data and data["domain_whitelist"] is None: |
| 136 | + data.pop("domain_whitelist") |
| 137 | + super(ApplicationSettingsManager, self).update(id, data, **kwargs) |
0 commit comments