...

Source file src/github.com/xanzy/go-gitlab/appearance.go

Documentation: github.com/xanzy/go-gitlab

     1  //
     2  // Copyright 2023, 徐晓伟 <xuxiaowei@xuxiaowei.com.cn>
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  //
    16  
    17  package gitlab
    18  
    19  import "net/http"
    20  
    21  // AppearanceService handles communication with appearance of the Gitlab API.
    22  //
    23  // Gitlab API docs : https://docs.gitlab.com/ee/api/appearance.html
    24  type AppearanceService struct {
    25  	client *Client
    26  }
    27  
    28  // Appearance represents a GitLab appearance.
    29  //
    30  // Gitlab API docs : https://docs.gitlab.com/ee/api/appearance.html
    31  type Appearance struct {
    32  	Title                       string `json:"title"`
    33  	Description                 string `json:"description"`
    34  	PWAName                     string `json:"pwa_name"`
    35  	PWAShortName                string `json:"pwa_short_name"`
    36  	PWADescription              string `json:"pwa_description"`
    37  	PWAIcon                     string `json:"pwa_icon"`
    38  	Logo                        string `json:"logo"`
    39  	HeaderLogo                  string `json:"header_logo"`
    40  	Favicon                     string `json:"favicon"`
    41  	NewProjectGuidelines        string `json:"new_project_guidelines"`
    42  	ProfileImageGuidelines      string `json:"profile_image_guidelines"`
    43  	HeaderMessage               string `json:"header_message"`
    44  	FooterMessage               string `json:"footer_message"`
    45  	MessageBackgroundColor      string `json:"message_background_color"`
    46  	MessageFontColor            string `json:"message_font_color"`
    47  	EmailHeaderAndFooterEnabled bool   `json:"email_header_and_footer_enabled"`
    48  }
    49  
    50  // GetAppearance gets the current appearance configuration of the GitLab instance.
    51  //
    52  // Gitlab API docs:
    53  // https://docs.gitlab.com/ee/api/appearance.html#get-current-appearance-configuration
    54  func (s *AppearanceService) GetAppearance(options ...RequestOptionFunc) (*Appearance, *Response, error) {
    55  	req, err := s.client.NewRequest(http.MethodGet, "application/appearance", nil, options)
    56  	if err != nil {
    57  		return nil, nil, err
    58  	}
    59  
    60  	as := new(Appearance)
    61  	resp, err := s.client.Do(req, as)
    62  	if err != nil {
    63  		return nil, resp, err
    64  	}
    65  
    66  	return as, resp, nil
    67  }
    68  
    69  // ChangeAppearanceOptions represents the available ChangeAppearance() options.
    70  //
    71  // GitLab API docs:
    72  // https://docs.gitlab.com/ee/api/appearance.html#change-appearance-configuration
    73  type ChangeAppearanceOptions struct {
    74  	Title                       *string `url:"title,omitempty" json:"title,omitempty"`
    75  	Description                 *string `url:"description,omitempty" json:"description,omitempty"`
    76  	PWAName                     *string `url:"pwa_name,omitempty" json:"pwa_name,omitempty"`
    77  	PWAShortName                *string `url:"pwa_short_name,omitempty" json:"pwa_short_name,omitempty"`
    78  	PWADescription              *string `url:"pwa_description,omitempty" json:"pwa_description,omitempty"`
    79  	PWAIcon                     *string `url:"pwa_icon,omitempty" json:"pwa_icon,omitempty"`
    80  	Logo                        *string `url:"logo,omitempty" json:"logo,omitempty"`
    81  	HeaderLogo                  *string `url:"header_logo,omitempty" json:"header_logo,omitempty"`
    82  	Favicon                     *string `url:"favicon,omitempty" json:"favicon,omitempty"`
    83  	NewProjectGuidelines        *string `url:"new_project_guidelines,omitempty" json:"new_project_guidelines,omitempty"`
    84  	ProfileImageGuidelines      *string `url:"profile_image_guidelines,omitempty" json:"profile_image_guidelines,omitempty"`
    85  	HeaderMessage               *string `url:"header_message,omitempty" json:"header_message,omitempty"`
    86  	FooterMessage               *string `url:"footer_message,omitempty" json:"footer_message,omitempty"`
    87  	MessageBackgroundColor      *string `url:"message_background_color,omitempty" json:"message_background_color,omitempty"`
    88  	MessageFontColor            *string `url:"message_font_color,omitempty" json:"message_font_color,omitempty"`
    89  	EmailHeaderAndFooterEnabled *bool   `url:"email_header_and_footer_enabled,omitempty" json:"email_header_and_footer_enabled,omitempty"`
    90  	URL                         *string `url:"url,omitempty" json:"url,omitempty"`
    91  }
    92  
    93  // ChangeAppearance changes the appearance configuration.
    94  //
    95  // Gitlab API docs:
    96  // https://docs.gitlab.com/ee/api/appearance.html#change-appearance-configuration
    97  func (s *AppearanceService) ChangeAppearance(opt *ChangeAppearanceOptions, options ...RequestOptionFunc) (*Appearance, *Response, error) {
    98  	req, err := s.client.NewRequest(http.MethodPut, "application/appearance", opt, options)
    99  	if err != nil {
   100  		return nil, nil, err
   101  	}
   102  
   103  	as := new(Appearance)
   104  	resp, err := s.client.Do(req, as)
   105  	if err != nil {
   106  		return nil, resp, err
   107  	}
   108  
   109  	return as, resp, nil
   110  }
   111  

View as plain text