...

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

Documentation: github.com/xanzy/go-gitlab

     1  //
     2  // Copyright 2021, Igor Varavko
     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  // PlanLimitsService handles communication with the repositories related
    22  // methods of the GitLab API.
    23  //
    24  // GitLab API docs: https://docs.gitlab.com/ee/api/plan_limits.html
    25  type PlanLimitsService struct {
    26  	client *Client
    27  }
    28  
    29  // PlanLimit represents a GitLab pipeline.
    30  //
    31  // GitLab API docs: https://docs.gitlab.com/ee/api/plan_limits.html
    32  type PlanLimit struct {
    33  	ConanMaxFileSize           int `json:"conan_max_file_size,omitempty"`
    34  	GenericPackagesMaxFileSize int `json:"generic_packages_max_file_size,omitempty"`
    35  	HelmMaxFileSize            int `json:"helm_max_file_size,omitempty"`
    36  	MavenMaxFileSize           int `json:"maven_max_file_size,omitempty"`
    37  	NPMMaxFileSize             int `json:"npm_max_file_size,omitempty"`
    38  	NugetMaxFileSize           int `json:"nuget_max_file_size,omitempty"`
    39  	PyPiMaxFileSize            int `json:"pypi_max_file_size,omitempty"`
    40  	TerraformModuleMaxFileSize int `json:"terraform_module_max_file_size,omitempty"`
    41  }
    42  
    43  // GetCurrentPlanLimitsOptions represents the available GetCurrentPlanLimits()
    44  // options.
    45  //
    46  // GitLab API docs:
    47  // https://docs.gitlab.com/ee/api/plan_limits.html#get-current-plan-limits
    48  type GetCurrentPlanLimitsOptions struct {
    49  	PlanName *string `url:"plan_name,omitempty" json:"plan_name,omitempty"`
    50  }
    51  
    52  // List the current limits of a plan on the GitLab instance.
    53  //
    54  // GitLab API docs:
    55  // https://docs.gitlab.com/ee/api/plan_limits.html#get-current-plan-limits
    56  func (s *PlanLimitsService) GetCurrentPlanLimits(opt *GetCurrentPlanLimitsOptions, options ...RequestOptionFunc) (*PlanLimit, *Response, error) {
    57  	req, err := s.client.NewRequest(http.MethodGet, "application/plan_limits", opt, options)
    58  	if err != nil {
    59  		return nil, nil, err
    60  	}
    61  
    62  	pl := new(PlanLimit)
    63  	resp, err := s.client.Do(req, pl)
    64  	if err != nil {
    65  		return nil, resp, err
    66  	}
    67  
    68  	return pl, resp, nil
    69  }
    70  
    71  // ChangePlanLimitOptions represents the available ChangePlanLimits() options.
    72  //
    73  // GitLab API docs:
    74  // https://docs.gitlab.com/ee/api/plan_limits.html#change-plan-limits
    75  type ChangePlanLimitOptions struct {
    76  	PlanName                   *string `url:"plan_name,omitempty" json:"plan_name,omitempty"`
    77  	ConanMaxFileSize           *int    `url:"conan_max_file_size,omitempty" json:"conan_max_file_size,omitempty"`
    78  	GenericPackagesMaxFileSize *int    `url:"generic_packages_max_file_size,omitempty" json:"generic_packages_max_file_size,omitempty"`
    79  	HelmMaxFileSize            *int    `url:"helm_max_file_size,omitempty" json:"helm_max_file_size,omitempty"`
    80  	MavenMaxFileSize           *int    `url:"maven_max_file_size,omitempty" json:"maven_max_file_size,omitempty"`
    81  	NPMMaxFileSize             *int    `url:"npm_max_file_size,omitempty" json:"npm_max_file_size,omitempty"`
    82  	NugetMaxFileSize           *int    `url:"nuget_max_file_size,omitempty" json:"nuget_max_file_size,omitempty"`
    83  	PyPiMaxFileSize            *int    `url:"pypi_max_file_size,omitempty" json:"pypi_max_file_size,omitempty"`
    84  	TerraformModuleMaxFileSize *int    `url:"terraform_module_max_file_size,omitempty" json:"terraform_module_max_file_size,omitempty"`
    85  }
    86  
    87  // ChangePlanLimits modifies the limits of a plan on the GitLab instance.
    88  //
    89  // GitLab API docs:
    90  // https://docs.gitlab.com/ee/api/plan_limits.html#change-plan-limits
    91  func (s *PlanLimitsService) ChangePlanLimits(opt *ChangePlanLimitOptions, options ...RequestOptionFunc) (*PlanLimit, *Response, error) {
    92  	req, err := s.client.NewRequest(http.MethodPut, "application/plan_limits", opt, options)
    93  	if err != nil {
    94  		return nil, nil, err
    95  	}
    96  
    97  	pl := new(PlanLimit)
    98  	resp, err := s.client.Do(req, pl)
    99  	if err != nil {
   100  		return nil, resp, err
   101  	}
   102  
   103  	return pl, resp, nil
   104  }
   105  

View as plain text