github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/scm/scm_options.go (about)

     1  package scm
     2  
     3  import "github.com/quickfeed/quickfeed/qf"
     4  
     5  // CourseOptions contain information about new course.
     6  type CourseOptions struct {
     7  	OrganizationID uint64
     8  	CourseCreator  string
     9  }
    10  
    11  func (opt CourseOptions) valid() bool {
    12  	return opt.OrganizationID > 0 && opt.CourseCreator != ""
    13  }
    14  
    15  // GroupOptions contain information about group.
    16  type GroupOptions struct {
    17  	OrganizationID uint64
    18  	RepositoryID   uint64
    19  	TeamID         uint64
    20  }
    21  
    22  func (opt *GroupOptions) valid() bool {
    23  	return opt.OrganizationID > 0 && opt.RepositoryID > 0 && opt.TeamID > 0
    24  }
    25  
    26  // UpdateEnrollmentOptions contain information about enrollment.
    27  type UpdateEnrollmentOptions struct {
    28  	Organization string
    29  	User         string
    30  	Status       qf.Enrollment_UserStatus
    31  }
    32  
    33  func (opt UpdateEnrollmentOptions) valid() bool {
    34  	return opt.Organization != "" && opt.User != ""
    35  }
    36  
    37  // RejectEnrollmentOptions contain information about enrollment.
    38  type RejectEnrollmentOptions struct {
    39  	OrganizationID uint64
    40  	RepositoryID   uint64
    41  	User           string
    42  }
    43  
    44  func (opt *RejectEnrollmentOptions) valid() bool {
    45  	return opt.OrganizationID > 0 && opt.RepositoryID > 0 && opt.User != ""
    46  }
    47  
    48  // OrganizationOptions contain information about organization.
    49  type OrganizationOptions struct {
    50  	ID   uint64
    51  	Name string
    52  	// Username field is used to filter organizations
    53  	// where the given user has a certain role.
    54  	Username  string
    55  	NewCourse bool // Get organization for a new course
    56  }
    57  
    58  func (opt OrganizationOptions) valid() bool {
    59  	return opt.ID != 0 || opt.Name != ""
    60  }
    61  
    62  // RepositoryOptions is used to fetch a single repository by ID or name.
    63  // Either ID or both Path and Owner fields must be set.
    64  type RepositoryOptions struct {
    65  	ID    uint64
    66  	Path  string
    67  	Owner string
    68  }
    69  
    70  func (opt RepositoryOptions) valid() bool {
    71  	return opt.ID > 0 || (opt.Path != "" && opt.Owner != "")
    72  }
    73  
    74  // CreateRepositoryOptions contains information on how a repository should be created.
    75  type CreateRepositoryOptions struct {
    76  	Organization string
    77  	Path         string
    78  	Private      bool
    79  	Permission   string // Default permission level for the given repo. Can be "read", "write", "admin", "none".
    80  }
    81  
    82  func (opt CreateRepositoryOptions) valid() bool {
    83  	return opt.Organization != "" && opt.Path != ""
    84  }
    85  
    86  // TeamOptions used when creating a new team
    87  type TeamOptions struct {
    88  	Organization string
    89  	TeamName     string
    90  	Users        []string
    91  }
    92  
    93  func (opt TeamOptions) valid() bool {
    94  	return opt.TeamName != "" && opt.Organization != ""
    95  }
    96  
    97  // UpdateTeamOptions used when updating team members.
    98  type UpdateTeamOptions struct {
    99  	OrganizationID uint64
   100  	TeamID         uint64
   101  	Users          []string
   102  }
   103  
   104  func (opt UpdateTeamOptions) valid() bool {
   105  	return opt.TeamID > 0 && opt.OrganizationID > 0
   106  }
   107  
   108  // IssueOptions contains information for creating or updating an Issue.
   109  type IssueOptions struct {
   110  	Organization string
   111  	Repository   string
   112  	Title        string
   113  	Body         string
   114  	State        string
   115  	Labels       *[]string
   116  	Assignee     *string
   117  	Assignees    *[]string
   118  	Number       int
   119  }
   120  
   121  func (opt *IssueOptions) valid() bool {
   122  	return opt.Organization != "" && opt.Repository != "" && opt.Title != "" && opt.Body != ""
   123  }
   124  
   125  // RequestReviewersOptions contains information on how to create or edit a pull request comment.
   126  type IssueCommentOptions struct {
   127  	Organization string
   128  	Repository   string
   129  	Body         string
   130  	Number       int
   131  	CommentID    int64
   132  }
   133  
   134  func (opt IssueCommentOptions) valid() bool {
   135  	return opt.Organization != "" && opt.Repository != "" && opt.Body != ""
   136  }
   137  
   138  // RequestReviewersOptions contains information on how to assign reviewers to a pull request.
   139  type RequestReviewersOptions struct {
   140  	Organization string
   141  	Repository   string
   142  	Number       int
   143  	Reviewers    []string // Reviewers is a slice of github usernames
   144  }
   145  
   146  func (opt RequestReviewersOptions) valid() bool {
   147  	return opt.Organization != "" && opt.Repository != "" && opt.Number > 0 && len(opt.Reviewers) != 0
   148  }