...

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

Documentation: github.com/xanzy/go-gitlab

     1  //
     2  // Copyright 2021, Sander van Harmelen
     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 (
    20  	"encoding/json"
    21  	"fmt"
    22  	"strconv"
    23  	"time"
    24  )
    25  
    26  // StateID identifies the state of an issue or merge request.
    27  //
    28  // There are no GitLab API docs on the subject, but the mappings can be found in
    29  // GitLab's codebase:
    30  // https://gitlab.com/gitlab-org/gitlab-foss/-/blob/ba5be4989e/app/models/concerns/issuable.rb#L39-42
    31  type StateID int
    32  
    33  const (
    34  	StateIDNone   StateID = 0
    35  	StateIDOpen   StateID = 1
    36  	StateIDClosed StateID = 2
    37  	StateIDMerged StateID = 3
    38  	StateIDLocked StateID = 4
    39  )
    40  
    41  // BuildEvent represents a build event.
    42  //
    43  // GitLab API docs:
    44  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#job-events
    45  type BuildEvent struct {
    46  	ObjectKind        string     `json:"object_kind"`
    47  	Ref               string     `json:"ref"`
    48  	Tag               bool       `json:"tag"`
    49  	BeforeSHA         string     `json:"before_sha"`
    50  	SHA               string     `json:"sha"`
    51  	BuildID           int        `json:"build_id"`
    52  	BuildName         string     `json:"build_name"`
    53  	BuildStage        string     `json:"build_stage"`
    54  	BuildStatus       string     `json:"build_status"`
    55  	BuildCreatedAt    string     `json:"build_created_at"`
    56  	BuildStartedAt    string     `json:"build_started_at"`
    57  	BuildFinishedAt   string     `json:"build_finished_at"`
    58  	BuildDuration     float64    `json:"build_duration"`
    59  	BuildAllowFailure bool       `json:"build_allow_failure"`
    60  	ProjectID         int        `json:"project_id"`
    61  	ProjectName       string     `json:"project_name"`
    62  	User              *EventUser `json:"user"`
    63  	Commit            struct {
    64  		ID          int    `json:"id"`
    65  		SHA         string `json:"sha"`
    66  		Message     string `json:"message"`
    67  		AuthorName  string `json:"author_name"`
    68  		AuthorEmail string `json:"author_email"`
    69  		Status      string `json:"status"`
    70  		Duration    int    `json:"duration"`
    71  		StartedAt   string `json:"started_at"`
    72  		FinishedAt  string `json:"finished_at"`
    73  	} `json:"commit"`
    74  	Repository *Repository `json:"repository"`
    75  }
    76  
    77  // CommitCommentEvent represents a comment on a commit event.
    78  //
    79  // GitLab API docs:
    80  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-on-a-commit
    81  type CommitCommentEvent struct {
    82  	ObjectKind string `json:"object_kind"`
    83  	EventType  string `json:"event_type"`
    84  	User       *User  `json:"user"`
    85  	ProjectID  int    `json:"project_id"`
    86  	Project    struct {
    87  		ID                int             `json:"id"`
    88  		Name              string          `json:"name"`
    89  		Description       string          `json:"description"`
    90  		AvatarURL         string          `json:"avatar_url"`
    91  		GitSSHURL         string          `json:"git_ssh_url"`
    92  		GitHTTPURL        string          `json:"git_http_url"`
    93  		Namespace         string          `json:"namespace"`
    94  		PathWithNamespace string          `json:"path_with_namespace"`
    95  		DefaultBranch     string          `json:"default_branch"`
    96  		Homepage          string          `json:"homepage"`
    97  		URL               string          `json:"url"`
    98  		SSHURL            string          `json:"ssh_url"`
    99  		HTTPURL           string          `json:"http_url"`
   100  		WebURL            string          `json:"web_url"`
   101  		Visibility        VisibilityValue `json:"visibility"`
   102  	} `json:"project"`
   103  	Repository       *Repository `json:"repository"`
   104  	ObjectAttributes struct {
   105  		ID           int    `json:"id"`
   106  		Note         string `json:"note"`
   107  		NoteableType string `json:"noteable_type"`
   108  		AuthorID     int    `json:"author_id"`
   109  		CreatedAt    string `json:"created_at"`
   110  		UpdatedAt    string `json:"updated_at"`
   111  		ProjectID    int    `json:"project_id"`
   112  		Attachment   string `json:"attachment"`
   113  		LineCode     string `json:"line_code"`
   114  		CommitID     string `json:"commit_id"`
   115  		NoteableID   int    `json:"noteable_id"`
   116  		System       bool   `json:"system"`
   117  		StDiff       *Diff  `json:"st_diff"`
   118  		Description  string `json:"description"`
   119  		URL          string `json:"url"`
   120  	} `json:"object_attributes"`
   121  	Commit *struct {
   122  		ID        string     `json:"id"`
   123  		Title     string     `json:"title"`
   124  		Message   string     `json:"message"`
   125  		Timestamp *time.Time `json:"timestamp"`
   126  		URL       string     `json:"url"`
   127  		Author    struct {
   128  			Name  string `json:"name"`
   129  			Email string `json:"email"`
   130  		} `json:"author"`
   131  	} `json:"commit"`
   132  }
   133  
   134  // DeploymentEvent represents a deployment event
   135  //
   136  // GitLab API docs:
   137  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#deployment-events
   138  type DeploymentEvent struct {
   139  	ObjectKind             string `json:"object_kind"`
   140  	Status                 string `json:"status"`
   141  	StatusChangedAt        string `json:"status_changed_at"`
   142  	DeploymentID           int    `json:"deployment_id"`
   143  	DeployableID           int    `json:"deployable_id"`
   144  	DeployableURL          string `json:"deployable_url"`
   145  	Environment            string `json:"environment"`
   146  	EnvironmentSlug        string `json:"environment_slug"`
   147  	EnvironmentExternalURL string `json:"environment_external_url"`
   148  	Project                struct {
   149  		ID                int     `json:"id"`
   150  		Name              string  `json:"name"`
   151  		Description       string  `json:"description"`
   152  		WebURL            string  `json:"web_url"`
   153  		AvatarURL         *string `json:"avatar_url"`
   154  		GitSSHURL         string  `json:"git_ssh_url"`
   155  		GitHTTPURL        string  `json:"git_http_url"`
   156  		Namespace         string  `json:"namespace"`
   157  		VisibilityLevel   int     `json:"visibility_level"`
   158  		PathWithNamespace string  `json:"path_with_namespace"`
   159  		DefaultBranch     string  `json:"default_branch"`
   160  		CIConfigPath      string  `json:"ci_config_path"`
   161  		Homepage          string  `json:"homepage"`
   162  		URL               string  `json:"url"`
   163  		SSHURL            string  `json:"ssh_url"`
   164  		HTTPURL           string  `json:"http_url"`
   165  	} `json:"project"`
   166  	Ref         string     `json:"ref"`
   167  	ShortSHA    string     `json:"short_sha"`
   168  	User        *EventUser `json:"user"`
   169  	UserURL     string     `json:"user_url"`
   170  	CommitURL   string     `json:"commit_url"`
   171  	CommitTitle string     `json:"commit_title"`
   172  }
   173  
   174  // FeatureFlagEvent represents a feature flag event
   175  //
   176  // GitLab API docs:
   177  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#feature-flag-events
   178  type FeatureFlagEvent struct {
   179  	ObjectKind string `json:"object_kind"`
   180  	Project    struct {
   181  		ID                int     `json:"id"`
   182  		Name              string  `json:"name"`
   183  		Description       string  `json:"description"`
   184  		WebURL            string  `json:"web_url"`
   185  		AvatarURL         *string `json:"avatar_url"`
   186  		GitSSHURL         string  `json:"git_ssh_url"`
   187  		GitHTTPURL        string  `json:"git_http_url"`
   188  		Namespace         string  `json:"namespace"`
   189  		VisibilityLevel   int     `json:"visibility_level"`
   190  		PathWithNamespace string  `json:"path_with_namespace"`
   191  		DefaultBranch     string  `json:"default_branch"`
   192  		CIConfigPath      string  `json:"ci_config_path"`
   193  		Homepage          string  `json:"homepage"`
   194  		URL               string  `json:"url"`
   195  		SSHURL            string  `json:"ssh_url"`
   196  		HTTPURL           string  `json:"http_url"`
   197  	} `json:"project"`
   198  	User             *EventUser `json:"user"`
   199  	UserURL          string     `json:"user_url"`
   200  	ObjectAttributes struct {
   201  		ID          int    `json:"id"`
   202  		Name        string `json:"name"`
   203  		Description string `json:"description"`
   204  		Active      bool   `json:"active"`
   205  	} `json:"object_attributes"`
   206  }
   207  
   208  // IssueCommentEvent represents a comment on an issue event.
   209  //
   210  // GitLab API docs:
   211  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-on-an-issue
   212  type IssueCommentEvent struct {
   213  	ObjectKind string `json:"object_kind"`
   214  	EventType  string `json:"event_type"`
   215  	User       *User  `json:"user"`
   216  	ProjectID  int    `json:"project_id"`
   217  	Project    struct {
   218  		Name              string          `json:"name"`
   219  		Description       string          `json:"description"`
   220  		AvatarURL         string          `json:"avatar_url"`
   221  		GitSSHURL         string          `json:"git_ssh_url"`
   222  		GitHTTPURL        string          `json:"git_http_url"`
   223  		Namespace         string          `json:"namespace"`
   224  		PathWithNamespace string          `json:"path_with_namespace"`
   225  		DefaultBranch     string          `json:"default_branch"`
   226  		Homepage          string          `json:"homepage"`
   227  		URL               string          `json:"url"`
   228  		SSHURL            string          `json:"ssh_url"`
   229  		HTTPURL           string          `json:"http_url"`
   230  		WebURL            string          `json:"web_url"`
   231  		Visibility        VisibilityValue `json:"visibility"`
   232  	} `json:"project"`
   233  	Repository       *Repository `json:"repository"`
   234  	ObjectAttributes struct {
   235  		ID           int     `json:"id"`
   236  		Note         string  `json:"note"`
   237  		NoteableType string  `json:"noteable_type"`
   238  		AuthorID     int     `json:"author_id"`
   239  		CreatedAt    string  `json:"created_at"`
   240  		UpdatedAt    string  `json:"updated_at"`
   241  		ProjectID    int     `json:"project_id"`
   242  		Attachment   string  `json:"attachment"`
   243  		LineCode     string  `json:"line_code"`
   244  		CommitID     string  `json:"commit_id"`
   245  		DiscussionID string  `json:"discussion_id"`
   246  		NoteableID   int     `json:"noteable_id"`
   247  		System       bool    `json:"system"`
   248  		StDiff       []*Diff `json:"st_diff"`
   249  		Description  string  `json:"description"`
   250  		URL          string  `json:"url"`
   251  	} `json:"object_attributes"`
   252  	Issue struct {
   253  		ID                  int           `json:"id"`
   254  		IID                 int           `json:"iid"`
   255  		ProjectID           int           `json:"project_id"`
   256  		MilestoneID         int           `json:"milestone_id"`
   257  		AuthorID            int           `json:"author_id"`
   258  		Position            int           `json:"position"`
   259  		BranchName          string        `json:"branch_name"`
   260  		Description         string        `json:"description"`
   261  		State               string        `json:"state"`
   262  		Title               string        `json:"title"`
   263  		Labels              []*EventLabel `json:"labels"`
   264  		LastEditedAt        string        `json:"last_edit_at"`
   265  		LastEditedByID      int           `json:"last_edited_by_id"`
   266  		UpdatedAt           string        `json:"updated_at"`
   267  		UpdatedByID         int           `json:"updated_by_id"`
   268  		CreatedAt           string        `json:"created_at"`
   269  		ClosedAt            string        `json:"closed_at"`
   270  		DueDate             *ISOTime      `json:"due_date"`
   271  		URL                 string        `json:"url"`
   272  		TimeEstimate        int           `json:"time_estimate"`
   273  		Confidential        bool          `json:"confidential"`
   274  		TotalTimeSpent      int           `json:"total_time_spent"`
   275  		HumanTotalTimeSpent string        `json:"human_total_time_spent"`
   276  		HumanTimeEstimate   string        `json:"human_time_estimate"`
   277  		AssigneeIDs         []int         `json:"assignee_ids"`
   278  		AssigneeID          int           `json:"assignee_id"`
   279  	} `json:"issue"`
   280  }
   281  
   282  // IssueEvent represents a issue event.
   283  //
   284  // GitLab API docs:
   285  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#issue-events
   286  type IssueEvent struct {
   287  	ObjectKind string     `json:"object_kind"`
   288  	EventType  string     `json:"event_type"`
   289  	User       *EventUser `json:"user"`
   290  	Project    struct {
   291  		ID                int             `json:"id"`
   292  		Name              string          `json:"name"`
   293  		Description       string          `json:"description"`
   294  		AvatarURL         string          `json:"avatar_url"`
   295  		GitSSHURL         string          `json:"git_ssh_url"`
   296  		GitHTTPURL        string          `json:"git_http_url"`
   297  		Namespace         string          `json:"namespace"`
   298  		PathWithNamespace string          `json:"path_with_namespace"`
   299  		DefaultBranch     string          `json:"default_branch"`
   300  		Homepage          string          `json:"homepage"`
   301  		URL               string          `json:"url"`
   302  		SSHURL            string          `json:"ssh_url"`
   303  		HTTPURL           string          `json:"http_url"`
   304  		WebURL            string          `json:"web_url"`
   305  		Visibility        VisibilityValue `json:"visibility"`
   306  	} `json:"project"`
   307  	Repository       *Repository `json:"repository"`
   308  	ObjectAttributes struct {
   309  		ID                  int      `json:"id"`
   310  		Title               string   `json:"title"`
   311  		AssigneeIDs         []int    `json:"assignee_ids"`
   312  		AssigneeID          int      `json:"assignee_id"`
   313  		AuthorID            int      `json:"author_id"`
   314  		ProjectID           int      `json:"project_id"`
   315  		CreatedAt           string   `json:"created_at"` // Should be *time.Time (see Gitlab issue #21468)
   316  		UpdatedAt           string   `json:"updated_at"` // Should be *time.Time (see Gitlab issue #21468)
   317  		UpdatedByID         int      `json:"updated_by_id"`
   318  		LastEditedAt        string   `json:"last_edited_at"`
   319  		LastEditedByID      int      `json:"last_edited_by_id"`
   320  		RelativePosition    int      `json:"relative_position"`
   321  		BranchName          string   `json:"branch_name"`
   322  		Description         string   `json:"description"`
   323  		MilestoneID         int      `json:"milestone_id"`
   324  		StateID             StateID  `json:"state_id"`
   325  		Confidential        bool     `json:"confidential"`
   326  		DiscussionLocked    bool     `json:"discussion_locked"`
   327  		DueDate             *ISOTime `json:"due_date"`
   328  		MovedToID           int      `json:"moved_to_id"`
   329  		DuplicatedToID      int      `json:"duplicated_to_id"`
   330  		TimeEstimate        int      `json:"time_estimate"`
   331  		TotalTimeSpent      int      `json:"total_time_spent"`
   332  		TimeChange          int      `json:"time_change"`
   333  		HumanTotalTimeSpent string   `json:"human_total_time_spent"`
   334  		HumanTimeEstimate   string   `json:"human_time_estimate"`
   335  		HumanTimeChange     string   `json:"human_time_change"`
   336  		Weight              int      `json:"weight"`
   337  		IID                 int      `json:"iid"`
   338  		URL                 string   `json:"url"`
   339  		State               string   `json:"state"`
   340  		Action              string   `json:"action"`
   341  		Severity            string   `json:"severity"`
   342  		EscalationStatus    string   `json:"escalation_status"`
   343  		EscalationPolicy    struct {
   344  			ID   int    `json:"id"`
   345  			Name string `json:"name"`
   346  		} `json:"escalation_policy"`
   347  		Labels []*EventLabel `json:"labels"`
   348  	} `json:"object_attributes"`
   349  	Assignee  *EventUser    `json:"assignee"`
   350  	Assignees *[]EventUser  `json:"assignees"`
   351  	Labels    []*EventLabel `json:"labels"`
   352  	Changes   struct {
   353  		Assignees struct {
   354  			Previous []*EventUser `json:"previous"`
   355  			Current  []*EventUser `json:"current"`
   356  		} `json:"assignees"`
   357  		Description struct {
   358  			Previous string `json:"previous"`
   359  			Current  string `json:"current"`
   360  		} `json:"description"`
   361  		Labels struct {
   362  			Previous []*EventLabel `json:"previous"`
   363  			Current  []*EventLabel `json:"current"`
   364  		} `json:"labels"`
   365  		Title struct {
   366  			Previous string `json:"previous"`
   367  			Current  string `json:"current"`
   368  		} `json:"title"`
   369  		ClosedAt struct {
   370  			Previous string `json:"previous"`
   371  			Current  string `json:"current"`
   372  		} `json:"closed_at"`
   373  		StateID struct {
   374  			Previous StateID `json:"previous"`
   375  			Current  StateID `json:"current"`
   376  		} `json:"state_id"`
   377  		UpdatedAt struct {
   378  			Previous string `json:"previous"`
   379  			Current  string `json:"current"`
   380  		} `json:"updated_at"`
   381  		UpdatedByID struct {
   382  			Previous int `json:"previous"`
   383  			Current  int `json:"current"`
   384  		} `json:"updated_by_id"`
   385  		TotalTimeSpent struct {
   386  			Previous int `json:"previous"`
   387  			Current  int `json:"current"`
   388  		} `json:"total_time_spent"`
   389  	} `json:"changes"`
   390  }
   391  
   392  // JobEvent represents a job event.
   393  //
   394  // GitLab API docs:
   395  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#job-events
   396  type JobEvent struct {
   397  	ObjectKind          string     `json:"object_kind"`
   398  	Ref                 string     `json:"ref"`
   399  	Tag                 bool       `json:"tag"`
   400  	BeforeSHA           string     `json:"before_sha"`
   401  	SHA                 string     `json:"sha"`
   402  	BuildID             int        `json:"build_id"`
   403  	BuildName           string     `json:"build_name"`
   404  	BuildStage          string     `json:"build_stage"`
   405  	BuildStatus         string     `json:"build_status"`
   406  	BuildCreatedAt      string     `json:"build_created_at"`
   407  	BuildStartedAt      string     `json:"build_started_at"`
   408  	BuildFinishedAt     string     `json:"build_finished_at"`
   409  	BuildDuration       float64    `json:"build_duration"`
   410  	BuildQueuedDuration float64    `json:"build_queued_duration"`
   411  	BuildAllowFailure   bool       `json:"build_allow_failure"`
   412  	BuildFailureReason  string     `json:"build_failure_reason"`
   413  	RetriesCount        int        `json:"retries_count"`
   414  	PipelineID          int        `json:"pipeline_id"`
   415  	ProjectID           int        `json:"project_id"`
   416  	ProjectName         string     `json:"project_name"`
   417  	User                *EventUser `json:"user"`
   418  	Commit              struct {
   419  		ID          int    `json:"id"`
   420  		Name        string `json:"name"`
   421  		SHA         string `json:"sha"`
   422  		Message     string `json:"message"`
   423  		AuthorName  string `json:"author_name"`
   424  		AuthorEmail string `json:"author_email"`
   425  		AuthorURL   string `json:"author_url"`
   426  		Status      string `json:"status"`
   427  		Duration    int    `json:"duration"`
   428  		StartedAt   string `json:"started_at"`
   429  		FinishedAt  string `json:"finished_at"`
   430  	} `json:"commit"`
   431  	Repository *Repository `json:"repository"`
   432  	Runner     struct {
   433  		ID          int      `json:"id"`
   434  		Active      bool     `json:"active"`
   435  		RunnerType  string   `json:"runner_type"`
   436  		IsShared    bool     `json:"is_shared"`
   437  		Description string   `json:"description"`
   438  		Tags        []string `json:"tags"`
   439  	} `json:"runner"`
   440  	Environment struct {
   441  		Name           string `json:"name"`
   442  		Action         string `json:"action"`
   443  		DeploymentTier string `json:"deployment_tier"`
   444  	} `json:"environment"`
   445  }
   446  
   447  // MemberEvent represents a member event.
   448  //
   449  // GitLab API docs:
   450  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#group-member-events
   451  type MemberEvent struct {
   452  	CreatedAt    *time.Time `json:"created_at"`
   453  	UpdatedAt    *time.Time `json:"updated_at"`
   454  	GroupName    string     `json:"group_name"`
   455  	GroupPath    string     `json:"group_path"`
   456  	GroupID      int        `json:"group_id"`
   457  	UserUsername string     `json:"user_username"`
   458  	UserName     string     `json:"user_name"`
   459  	UserEmail    string     `json:"user_email"`
   460  	UserID       int        `json:"user_id"`
   461  	GroupAccess  string     `json:"group_access"`
   462  	GroupPlan    string     `json:"group_plan"`
   463  	ExpiresAt    *time.Time `json:"expires_at"`
   464  	EventName    string     `json:"event_name"`
   465  }
   466  
   467  // MergeCommentEvent represents a comment on a merge event.
   468  //
   469  // GitLab API docs:
   470  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-on-a-merge-request
   471  type MergeCommentEvent struct {
   472  	ObjectKind string     `json:"object_kind"`
   473  	EventType  string     `json:"event_type"`
   474  	User       *EventUser `json:"user"`
   475  	ProjectID  int        `json:"project_id"`
   476  	Project    struct {
   477  		ID                int             `json:"id"`
   478  		Name              string          `json:"name"`
   479  		Description       string          `json:"description"`
   480  		AvatarURL         string          `json:"avatar_url"`
   481  		GitSSHURL         string          `json:"git_ssh_url"`
   482  		GitHTTPURL        string          `json:"git_http_url"`
   483  		Namespace         string          `json:"namespace"`
   484  		PathWithNamespace string          `json:"path_with_namespace"`
   485  		DefaultBranch     string          `json:"default_branch"`
   486  		Homepage          string          `json:"homepage"`
   487  		URL               string          `json:"url"`
   488  		SSHURL            string          `json:"ssh_url"`
   489  		HTTPURL           string          `json:"http_url"`
   490  		WebURL            string          `json:"web_url"`
   491  		Visibility        VisibilityValue `json:"visibility"`
   492  	} `json:"project"`
   493  	ObjectAttributes struct {
   494  		Attachment       string        `json:"attachment"`
   495  		AuthorID         int           `json:"author_id"`
   496  		ChangePosition   *NotePosition `json:"change_position"`
   497  		CommitID         string        `json:"commit_id"`
   498  		CreatedAt        string        `json:"created_at"`
   499  		DiscussionID     string        `json:"discussion_id"`
   500  		ID               int           `json:"id"`
   501  		LineCode         string        `json:"line_code"`
   502  		Note             string        `json:"note"`
   503  		NoteableID       int           `json:"noteable_id"`
   504  		NoteableType     string        `json:"noteable_type"`
   505  		OriginalPosition *NotePosition `json:"original_position"`
   506  		Position         *NotePosition `json:"position"`
   507  		ProjectID        int           `json:"project_id"`
   508  		ResolvedAt       string        `json:"resolved_at"`
   509  		ResolvedByID     int           `json:"resolved_by_id"`
   510  		ResolvedByPush   bool          `json:"resolved_by_push"`
   511  		StDiff           *Diff         `json:"st_diff"`
   512  		System           bool          `json:"system"`
   513  		Type             string        `json:"type"`
   514  		UpdatedAt        string        `json:"updated_at"`
   515  		UpdatedByID      int           `json:"updated_by_id"`
   516  		Description      string        `json:"description"`
   517  		URL              string        `json:"url"`
   518  	} `json:"object_attributes"`
   519  	Repository   *Repository `json:"repository"`
   520  	MergeRequest struct {
   521  		ID                        int           `json:"id"`
   522  		TargetBranch              string        `json:"target_branch"`
   523  		SourceBranch              string        `json:"source_branch"`
   524  		SourceProjectID           int           `json:"source_project_id"`
   525  		AuthorID                  int           `json:"author_id"`
   526  		AssigneeID                int           `json:"assignee_id"`
   527  		AssigneeIDs               []int         `json:"assignee_ids"`
   528  		Title                     string        `json:"title"`
   529  		CreatedAt                 string        `json:"created_at"`
   530  		UpdatedAt                 string        `json:"updated_at"`
   531  		MilestoneID               int           `json:"milestone_id"`
   532  		State                     string        `json:"state"`
   533  		MergeStatus               string        `json:"merge_status"`
   534  		TargetProjectID           int           `json:"target_project_id"`
   535  		IID                       int           `json:"iid"`
   536  		Description               string        `json:"description"`
   537  		Position                  int           `json:"position"`
   538  		Labels                    []*EventLabel `json:"labels"`
   539  		LockedAt                  string        `json:"locked_at"`
   540  		UpdatedByID               int           `json:"updated_by_id"`
   541  		MergeError                string        `json:"merge_error"`
   542  		MergeParams               *MergeParams  `json:"merge_params"`
   543  		MergeWhenPipelineSucceeds bool          `json:"merge_when_pipeline_succeeds"`
   544  		MergeUserID               int           `json:"merge_user_id"`
   545  		MergeCommitSHA            string        `json:"merge_commit_sha"`
   546  		DeletedAt                 string        `json:"deleted_at"`
   547  		InProgressMergeCommitSHA  string        `json:"in_progress_merge_commit_sha"`
   548  		LockVersion               int           `json:"lock_version"`
   549  		ApprovalsBeforeMerge      string        `json:"approvals_before_merge"`
   550  		RebaseCommitSHA           string        `json:"rebase_commit_sha"`
   551  		TimeEstimate              int           `json:"time_estimate"`
   552  		Squash                    bool          `json:"squash"`
   553  		LastEditedAt              string        `json:"last_edited_at"`
   554  		LastEditedByID            int           `json:"last_edited_by_id"`
   555  		Source                    *Repository   `json:"source"`
   556  		Target                    *Repository   `json:"target"`
   557  		LastCommit                struct {
   558  			ID        string     `json:"id"`
   559  			Title     string     `json:"title"`
   560  			Message   string     `json:"message"`
   561  			Timestamp *time.Time `json:"timestamp"`
   562  			URL       string     `json:"url"`
   563  			Author    struct {
   564  				Name  string `json:"name"`
   565  				Email string `json:"email"`
   566  			} `json:"author"`
   567  		} `json:"last_commit"`
   568  		WorkInProgress      bool       `json:"work_in_progress"`
   569  		TotalTimeSpent      int        `json:"total_time_spent"`
   570  		HeadPipelineID      int        `json:"head_pipeline_id"`
   571  		Assignee            *EventUser `json:"assignee"`
   572  		DetailedMergeStatus string     `json:"detailed_merge_status"`
   573  	} `json:"merge_request"`
   574  }
   575  
   576  // MergeEvent represents a merge event.
   577  //
   578  // GitLab API docs:
   579  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#merge-request-events
   580  type MergeEvent struct {
   581  	ObjectKind string     `json:"object_kind"`
   582  	EventType  string     `json:"event_type"`
   583  	User       *EventUser `json:"user"`
   584  	Project    struct {
   585  		ID                int             `json:"id"`
   586  		Name              string          `json:"name"`
   587  		Description       string          `json:"description"`
   588  		AvatarURL         string          `json:"avatar_url"`
   589  		GitSSHURL         string          `json:"git_ssh_url"`
   590  		GitHTTPURL        string          `json:"git_http_url"`
   591  		Namespace         string          `json:"namespace"`
   592  		PathWithNamespace string          `json:"path_with_namespace"`
   593  		DefaultBranch     string          `json:"default_branch"`
   594  		CIConfigPath      string          `json:"ci_config_path"`
   595  		Homepage          string          `json:"homepage"`
   596  		URL               string          `json:"url"`
   597  		SSHURL            string          `json:"ssh_url"`
   598  		HTTPURL           string          `json:"http_url"`
   599  		WebURL            string          `json:"web_url"`
   600  		Visibility        VisibilityValue `json:"visibility"`
   601  	} `json:"project"`
   602  	ObjectAttributes struct {
   603  		ID                       int          `json:"id"`
   604  		TargetBranch             string       `json:"target_branch"`
   605  		SourceBranch             string       `json:"source_branch"`
   606  		SourceProjectID          int          `json:"source_project_id"`
   607  		AuthorID                 int          `json:"author_id"`
   608  		AssigneeID               int          `json:"assignee_id"`
   609  		AssigneeIDs              []int        `json:"assignee_ids"`
   610  		ReviewerIDs              []int        `json:"reviewer_ids"`
   611  		Title                    string       `json:"title"`
   612  		CreatedAt                string       `json:"created_at"` // Should be *time.Time (see Gitlab issue #21468)
   613  		UpdatedAt                string       `json:"updated_at"` // Should be *time.Time (see Gitlab issue #21468)
   614  		StCommits                []*Commit    `json:"st_commits"`
   615  		StDiffs                  []*Diff      `json:"st_diffs"`
   616  		LastEditedAt             string       `json:"last_edited_at"`
   617  		LastEditedByID           int          `json:"last_edited_by_id"`
   618  		MilestoneID              int          `json:"milestone_id"`
   619  		StateID                  StateID      `json:"state_id"`
   620  		State                    string       `json:"state"`
   621  		MergeStatus              string       `json:"merge_status"`
   622  		TargetProjectID          int          `json:"target_project_id"`
   623  		IID                      int          `json:"iid"`
   624  		Description              string       `json:"description"`
   625  		Position                 int          `json:"position"`
   626  		LockedAt                 string       `json:"locked_at"`
   627  		UpdatedByID              int          `json:"updated_by_id"`
   628  		MergeError               string       `json:"merge_error"`
   629  		MergeParams              *MergeParams `json:"merge_params"`
   630  		MergeWhenBuildSucceeds   bool         `json:"merge_when_build_succeeds"`
   631  		MergeUserID              int          `json:"merge_user_id"`
   632  		MergeCommitSHA           string       `json:"merge_commit_sha"`
   633  		DeletedAt                string       `json:"deleted_at"`
   634  		ApprovalsBeforeMerge     string       `json:"approvals_before_merge"`
   635  		RebaseCommitSHA          string       `json:"rebase_commit_sha"`
   636  		InProgressMergeCommitSHA string       `json:"in_progress_merge_commit_sha"`
   637  		LockVersion              int          `json:"lock_version"`
   638  		TimeEstimate             int          `json:"time_estimate"`
   639  		Source                   *Repository  `json:"source"`
   640  		Target                   *Repository  `json:"target"`
   641  		HeadPipelineID           *int         `json:"head_pipeline_id"`
   642  		LastCommit               struct {
   643  			ID        string     `json:"id"`
   644  			Message   string     `json:"message"`
   645  			Title     string     `json:"title"`
   646  			Timestamp *time.Time `json:"timestamp"`
   647  			URL       string     `json:"url"`
   648  			Author    struct {
   649  				Name  string `json:"name"`
   650  				Email string `json:"email"`
   651  			} `json:"author"`
   652  		} `json:"last_commit"`
   653  		BlockingDiscussionsResolved bool          `json:"blocking_discussions_resolved"`
   654  		WorkInProgress              bool          `json:"work_in_progress"`
   655  		Draft                       bool          `json:"draft"`
   656  		TotalTimeSpent              int           `json:"total_time_spent"`
   657  		TimeChange                  int           `json:"time_change"`
   658  		HumanTotalTimeSpent         string        `json:"human_total_time_spent"`
   659  		HumanTimeChange             string        `json:"human_time_change"`
   660  		HumanTimeEstimate           string        `json:"human_time_estimate"`
   661  		FirstContribution           bool          `json:"first_contribution"`
   662  		URL                         string        `json:"url"`
   663  		Labels                      []*EventLabel `json:"labels"`
   664  		Action                      string        `json:"action"`
   665  		DetailedMergeStatus         string        `json:"detailed_merge_status"`
   666  		OldRev                      string        `json:"oldrev"`
   667  	} `json:"object_attributes"`
   668  	Repository *Repository   `json:"repository"`
   669  	Labels     []*EventLabel `json:"labels"`
   670  	Changes    struct {
   671  		Assignees struct {
   672  			Previous []*EventUser `json:"previous"`
   673  			Current  []*EventUser `json:"current"`
   674  		} `json:"assignees"`
   675  		Reviewers struct {
   676  			Previous []*EventUser `json:"previous"`
   677  			Current  []*EventUser `json:"current"`
   678  		} `json:"reviewers"`
   679  		Description struct {
   680  			Previous string `json:"previous"`
   681  			Current  string `json:"current"`
   682  		} `json:"description"`
   683  		Draft struct {
   684  			Previous bool `json:"previous"`
   685  			Current  bool `json:"current"`
   686  		} `json:"draft"`
   687  		Labels struct {
   688  			Previous []*EventLabel `json:"previous"`
   689  			Current  []*EventLabel `json:"current"`
   690  		} `json:"labels"`
   691  		LastEditedAt struct {
   692  			Previous string `json:"previous"`
   693  			Current  string `json:"current"`
   694  		} `json:"last_edited_at"`
   695  		LastEditedByID struct {
   696  			Previous int `json:"previous"`
   697  			Current  int `json:"current"`
   698  		} `json:"last_edited_by_id"`
   699  		MilestoneID struct {
   700  			Previous int `json:"previous"`
   701  			Current  int `json:"current"`
   702  		} `json:"milestone_id"`
   703  		SourceBranch struct {
   704  			Previous string `json:"previous"`
   705  			Current  string `json:"current"`
   706  		} `json:"source_branch"`
   707  		SourceProjectID struct {
   708  			Previous int `json:"previous"`
   709  			Current  int `json:"current"`
   710  		} `json:"source_project_id"`
   711  		StateID struct {
   712  			Previous StateID `json:"previous"`
   713  			Current  StateID `json:"current"`
   714  		} `json:"state_id"`
   715  		TargetBranch struct {
   716  			Previous string `json:"previous"`
   717  			Current  string `json:"current"`
   718  		} `json:"target_branch"`
   719  		TargetProjectID struct {
   720  			Previous int `json:"previous"`
   721  			Current  int `json:"current"`
   722  		} `json:"target_project_id"`
   723  		Title struct {
   724  			Previous string `json:"previous"`
   725  			Current  string `json:"current"`
   726  		} `json:"title"`
   727  		UpdatedAt struct {
   728  			Previous string `json:"previous"`
   729  			Current  string `json:"current"`
   730  		} `json:"updated_at"`
   731  		UpdatedByID struct {
   732  			Previous int `json:"previous"`
   733  			Current  int `json:"current"`
   734  		} `json:"updated_by_id"`
   735  	} `json:"changes"`
   736  	Assignees []*EventUser `json:"assignees"`
   737  	Reviewers []*EventUser `json:"reviewers"`
   738  }
   739  
   740  // EventUser represents a user record in an event and is used as an even initiator or a merge assignee.
   741  type EventUser struct {
   742  	ID        int    `json:"id"`
   743  	Name      string `json:"name"`
   744  	Username  string `json:"username"`
   745  	AvatarURL string `json:"avatar_url"`
   746  	Email     string `json:"email"`
   747  }
   748  
   749  // MergeParams represents the merge params.
   750  type MergeParams struct {
   751  	ForceRemoveSourceBranch bool `json:"force_remove_source_branch"`
   752  }
   753  
   754  // UnmarshalJSON decodes the merge parameters
   755  //
   756  // This allows support of ForceRemoveSourceBranch for both type bool (>11.9) and string (<11.9)
   757  func (p *MergeParams) UnmarshalJSON(b []byte) error {
   758  	type Alias MergeParams
   759  	raw := struct {
   760  		*Alias
   761  		ForceRemoveSourceBranch interface{} `json:"force_remove_source_branch"`
   762  	}{
   763  		Alias: (*Alias)(p),
   764  	}
   765  
   766  	err := json.Unmarshal(b, &raw)
   767  	if err != nil {
   768  		return err
   769  	}
   770  
   771  	switch v := raw.ForceRemoveSourceBranch.(type) {
   772  	case nil:
   773  		// No action needed.
   774  	case bool:
   775  		p.ForceRemoveSourceBranch = v
   776  	case string:
   777  		p.ForceRemoveSourceBranch, err = strconv.ParseBool(v)
   778  		if err != nil {
   779  			return err
   780  		}
   781  	default:
   782  		return fmt.Errorf("failed to unmarshal ForceRemoveSourceBranch of type: %T", v)
   783  	}
   784  
   785  	return nil
   786  }
   787  
   788  // PipelineEvent represents a pipeline event.
   789  //
   790  // GitLab API docs:
   791  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#pipeline-events
   792  type PipelineEvent struct {
   793  	ObjectKind       string `json:"object_kind"`
   794  	ObjectAttributes struct {
   795  		ID             int      `json:"id"`
   796  		IID            int      `json:"iid"`
   797  		Name           string   `json:"name"`
   798  		Ref            string   `json:"ref"`
   799  		Tag            bool     `json:"tag"`
   800  		SHA            string   `json:"sha"`
   801  		BeforeSHA      string   `json:"before_sha"`
   802  		Source         string   `json:"source"`
   803  		Status         string   `json:"status"`
   804  		DetailedStatus string   `json:"detailed_status"`
   805  		Stages         []string `json:"stages"`
   806  		CreatedAt      string   `json:"created_at"`
   807  		FinishedAt     string   `json:"finished_at"`
   808  		Duration       int      `json:"duration"`
   809  		QueuedDuration int      `json:"queued_duration"`
   810  		URL            string   `json:"url"`
   811  		Variables      []struct {
   812  			Key   string `json:"key"`
   813  			Value string `json:"value"`
   814  		} `json:"variables"`
   815  	} `json:"object_attributes"`
   816  	MergeRequest struct {
   817  		ID                  int    `json:"id"`
   818  		IID                 int    `json:"iid"`
   819  		Title               string `json:"title"`
   820  		SourceBranch        string `json:"source_branch"`
   821  		SourceProjectID     int    `json:"source_project_id"`
   822  		TargetBranch        string `json:"target_branch"`
   823  		TargetProjectID     int    `json:"target_project_id"`
   824  		State               string `json:"state"`
   825  		MergeRequestStatus  string `json:"merge_status"`
   826  		DetailedMergeStatus string `json:"detailed_merge_status"`
   827  		URL                 string `json:"url"`
   828  	} `json:"merge_request"`
   829  	User    *EventUser `json:"user"`
   830  	Project struct {
   831  		ID                int             `json:"id"`
   832  		Name              string          `json:"name"`
   833  		Description       string          `json:"description"`
   834  		AvatarURL         string          `json:"avatar_url"`
   835  		GitSSHURL         string          `json:"git_ssh_url"`
   836  		GitHTTPURL        string          `json:"git_http_url"`
   837  		Namespace         string          `json:"namespace"`
   838  		PathWithNamespace string          `json:"path_with_namespace"`
   839  		DefaultBranch     string          `json:"default_branch"`
   840  		Homepage          string          `json:"homepage"`
   841  		URL               string          `json:"url"`
   842  		SSHURL            string          `json:"ssh_url"`
   843  		HTTPURL           string          `json:"http_url"`
   844  		WebURL            string          `json:"web_url"`
   845  		Visibility        VisibilityValue `json:"visibility"`
   846  	} `json:"project"`
   847  	Commit struct {
   848  		ID        string     `json:"id"`
   849  		Message   string     `json:"message"`
   850  		Title     string     `json:"title"`
   851  		Timestamp *time.Time `json:"timestamp"`
   852  		URL       string     `json:"url"`
   853  		Author    struct {
   854  			Name  string `json:"name"`
   855  			Email string `json:"email"`
   856  		} `json:"author"`
   857  	} `json:"commit"`
   858  	SourcePipline struct {
   859  		Project struct {
   860  			ID                int    `json:"id"`
   861  			WebURL            string `json:"web_url"`
   862  			PathWithNamespace string `json:"path_with_namespace"`
   863  		} `json:"project"`
   864  		PipelineID int `json:"pipeline_id"`
   865  		JobID      int `json:"job_id"`
   866  	} `json:"source_pipeline"`
   867  	Builds []struct {
   868  		ID             int        `json:"id"`
   869  		Stage          string     `json:"stage"`
   870  		Name           string     `json:"name"`
   871  		Status         string     `json:"status"`
   872  		CreatedAt      string     `json:"created_at"`
   873  		StartedAt      string     `json:"started_at"`
   874  		FinishedAt     string     `json:"finished_at"`
   875  		Duration       float64    `json:"duration"`
   876  		QueuedDuration float64    `json:"queued_duration"`
   877  		FailureReason  string     `json:"failure_reason"`
   878  		When           string     `json:"when"`
   879  		Manual         bool       `json:"manual"`
   880  		AllowFailure   bool       `json:"allow_failure"`
   881  		User           *EventUser `json:"user"`
   882  		Runner         struct {
   883  			ID          int      `json:"id"`
   884  			Description string   `json:"description"`
   885  			Active      bool     `json:"active"`
   886  			IsShared    bool     `json:"is_shared"`
   887  			RunnerType  string   `json:"runner_type"`
   888  			Tags        []string `json:"tags"`
   889  		} `json:"runner"`
   890  		ArtifactsFile struct {
   891  			Filename string `json:"filename"`
   892  			Size     int    `json:"size"`
   893  		} `json:"artifacts_file"`
   894  		Environment struct {
   895  			Name           string `json:"name"`
   896  			Action         string `json:"action"`
   897  			DeploymentTier string `json:"deployment_tier"`
   898  		} `json:"environment"`
   899  	} `json:"builds"`
   900  }
   901  
   902  // PushEvent represents a push event.
   903  //
   904  // GitLab API docs:
   905  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#push-events
   906  type PushEvent struct {
   907  	ObjectKind   string `json:"object_kind"`
   908  	EventName    string `json:"event_name"`
   909  	Before       string `json:"before"`
   910  	After        string `json:"after"`
   911  	Ref          string `json:"ref"`
   912  	CheckoutSHA  string `json:"checkout_sha"`
   913  	UserID       int    `json:"user_id"`
   914  	UserName     string `json:"user_name"`
   915  	UserUsername string `json:"user_username"`
   916  	UserEmail    string `json:"user_email"`
   917  	UserAvatar   string `json:"user_avatar"`
   918  	ProjectID    int    `json:"project_id"`
   919  	Project      struct {
   920  		ID                int             `json:"id"`
   921  		Name              string          `json:"name"`
   922  		Description       string          `json:"description"`
   923  		AvatarURL         string          `json:"avatar_url"`
   924  		GitSSHURL         string          `json:"git_ssh_url"`
   925  		GitHTTPURL        string          `json:"git_http_url"`
   926  		Namespace         string          `json:"namespace"`
   927  		PathWithNamespace string          `json:"path_with_namespace"`
   928  		DefaultBranch     string          `json:"default_branch"`
   929  		Homepage          string          `json:"homepage"`
   930  		URL               string          `json:"url"`
   931  		SSHURL            string          `json:"ssh_url"`
   932  		HTTPURL           string          `json:"http_url"`
   933  		WebURL            string          `json:"web_url"`
   934  		Visibility        VisibilityValue `json:"visibility"`
   935  	} `json:"project"`
   936  	Repository *Repository `json:"repository"`
   937  	Commits    []*struct {
   938  		ID        string     `json:"id"`
   939  		Message   string     `json:"message"`
   940  		Title     string     `json:"title"`
   941  		Timestamp *time.Time `json:"timestamp"`
   942  		URL       string     `json:"url"`
   943  		Author    struct {
   944  			Name  string `json:"name"`
   945  			Email string `json:"email"`
   946  		} `json:"author"`
   947  		Added    []string `json:"added"`
   948  		Modified []string `json:"modified"`
   949  		Removed  []string `json:"removed"`
   950  	} `json:"commits"`
   951  	TotalCommitsCount int `json:"total_commits_count"`
   952  }
   953  
   954  // ReleaseEvent represents a release event
   955  //
   956  // GitLab API docs:
   957  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#release-events
   958  type ReleaseEvent struct {
   959  	ID          int    `json:"id"`
   960  	CreatedAt   string `json:"created_at"` // Should be *time.Time (see Gitlab issue #21468)
   961  	Description string `json:"description"`
   962  	Name        string `json:"name"`
   963  	Tag         string `json:"tag"`
   964  	ReleasedAt  string `json:"released_at"` // Should be *time.Time (see Gitlab issue #21468)
   965  	ObjectKind  string `json:"object_kind"`
   966  	Project     struct {
   967  		ID                int     `json:"id"`
   968  		Name              string  `json:"name"`
   969  		Description       string  `json:"description"`
   970  		WebURL            string  `json:"web_url"`
   971  		AvatarURL         *string `json:"avatar_url"`
   972  		GitSSHURL         string  `json:"git_ssh_url"`
   973  		GitHTTPURL        string  `json:"git_http_url"`
   974  		Namespace         string  `json:"namespace"`
   975  		VisibilityLevel   int     `json:"visibility_level"`
   976  		PathWithNamespace string  `json:"path_with_namespace"`
   977  		DefaultBranch     string  `json:"default_branch"`
   978  		CIConfigPath      string  `json:"ci_config_path"`
   979  		Homepage          string  `json:"homepage"`
   980  		URL               string  `json:"url"`
   981  		SSHURL            string  `json:"ssh_url"`
   982  		HTTPURL           string  `json:"http_url"`
   983  	} `json:"project"`
   984  	URL    string `json:"url"`
   985  	Action string `json:"action"`
   986  	Assets struct {
   987  		Count int `json:"count"`
   988  		Links []struct {
   989  			ID       int    `json:"id"`
   990  			External bool   `json:"external"`
   991  			LinkType string `json:"link_type"`
   992  			Name     string `json:"name"`
   993  			URL      string `json:"url"`
   994  		} `json:"links"`
   995  		Sources []struct {
   996  			Format string `json:"format"`
   997  			URL    string `json:"url"`
   998  		} `json:"sources"`
   999  	} `json:"assets"`
  1000  	Commit struct {
  1001  		ID        string `json:"id"`
  1002  		Message   string `json:"message"`
  1003  		Title     string `json:"title"`
  1004  		Timestamp string `json:"timestamp"` // Should be *time.Time (see Gitlab issue #21468)
  1005  		URL       string `json:"url"`
  1006  		Author    struct {
  1007  			Name  string `json:"name"`
  1008  			Email string `json:"email"`
  1009  		} `json:"author"`
  1010  	} `json:"commit"`
  1011  }
  1012  
  1013  // SnippetCommentEvent represents a comment on a snippet event.
  1014  //
  1015  // GitLab API docs:
  1016  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-on-a-code-snippet
  1017  type SnippetCommentEvent struct {
  1018  	ObjectKind string     `json:"object_kind"`
  1019  	EventType  string     `json:"event_type"`
  1020  	User       *EventUser `json:"user"`
  1021  	ProjectID  int        `json:"project_id"`
  1022  	Project    struct {
  1023  		Name              string          `json:"name"`
  1024  		Description       string          `json:"description"`
  1025  		AvatarURL         string          `json:"avatar_url"`
  1026  		GitSSHURL         string          `json:"git_ssh_url"`
  1027  		GitHTTPURL        string          `json:"git_http_url"`
  1028  		Namespace         string          `json:"namespace"`
  1029  		PathWithNamespace string          `json:"path_with_namespace"`
  1030  		DefaultBranch     string          `json:"default_branch"`
  1031  		Homepage          string          `json:"homepage"`
  1032  		URL               string          `json:"url"`
  1033  		SSHURL            string          `json:"ssh_url"`
  1034  		HTTPURL           string          `json:"http_url"`
  1035  		WebURL            string          `json:"web_url"`
  1036  		Visibility        VisibilityValue `json:"visibility"`
  1037  	} `json:"project"`
  1038  	Repository       *Repository `json:"repository"`
  1039  	ObjectAttributes struct {
  1040  		ID           int    `json:"id"`
  1041  		Note         string `json:"note"`
  1042  		NoteableType string `json:"noteable_type"`
  1043  		AuthorID     int    `json:"author_id"`
  1044  		CreatedAt    string `json:"created_at"`
  1045  		UpdatedAt    string `json:"updated_at"`
  1046  		ProjectID    int    `json:"project_id"`
  1047  		Attachment   string `json:"attachment"`
  1048  		LineCode     string `json:"line_code"`
  1049  		CommitID     string `json:"commit_id"`
  1050  		NoteableID   int    `json:"noteable_id"`
  1051  		System       bool   `json:"system"`
  1052  		StDiff       *Diff  `json:"st_diff"`
  1053  		Description  string `json:"description"`
  1054  		URL          string `json:"url"`
  1055  	} `json:"object_attributes"`
  1056  	Snippet *struct {
  1057  		ID                 int    `json:"id"`
  1058  		Title              string `json:"title"`
  1059  		Content            string `json:"content"`
  1060  		AuthorID           int    `json:"author_id"`
  1061  		ProjectID          int    `json:"project_id"`
  1062  		CreatedAt          string `json:"created_at"`
  1063  		UpdatedAt          string `json:"updated_at"`
  1064  		Filename           string `json:"file_name"`
  1065  		ExpiresAt          string `json:"expires_at"`
  1066  		Type               string `json:"type"`
  1067  		VisibilityLevel    int    `json:"visibility_level"`
  1068  		Description        string `json:"description"`
  1069  		Secret             bool   `json:"secret"`
  1070  		RepositoryReadOnly bool   `json:"repository_read_only"`
  1071  	} `json:"snippet"`
  1072  }
  1073  
  1074  // SubGroupEvent represents a subgroup event.
  1075  //
  1076  // GitLab API docs:
  1077  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#subgroup-events
  1078  type SubGroupEvent struct {
  1079  	CreatedAt      *time.Time `json:"created_at"`
  1080  	UpdatedAt      *time.Time `json:"updated_at"`
  1081  	EventName      string     `json:"event_name"`
  1082  	Name           string     `json:"name"`
  1083  	Path           string     `json:"path"`
  1084  	FullPath       string     `json:"full_path"`
  1085  	GroupID        int        `json:"group_id"`
  1086  	ParentGroupID  int        `json:"parent_group_id"`
  1087  	ParentName     string     `json:"parent_name"`
  1088  	ParentPath     string     `json:"parent_path"`
  1089  	ParentFullPath string     `json:"parent_full_path"`
  1090  }
  1091  
  1092  // TagEvent represents a tag event.
  1093  //
  1094  // GitLab API docs:
  1095  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#tag-events
  1096  type TagEvent struct {
  1097  	ObjectKind   string `json:"object_kind"`
  1098  	EventName    string `json:"event_name"`
  1099  	Before       string `json:"before"`
  1100  	After        string `json:"after"`
  1101  	Ref          string `json:"ref"`
  1102  	CheckoutSHA  string `json:"checkout_sha"`
  1103  	UserID       int    `json:"user_id"`
  1104  	UserName     string `json:"user_name"`
  1105  	UserUsername string `json:"user_username"`
  1106  	UserAvatar   string `json:"user_avatar"`
  1107  	UserEmail    string `json:"user_email"`
  1108  	ProjectID    int    `json:"project_id"`
  1109  	Message      string `json:"message"`
  1110  	Project      struct {
  1111  		ID                int             `json:"id"`
  1112  		Name              string          `json:"name"`
  1113  		Description       string          `json:"description"`
  1114  		AvatarURL         string          `json:"avatar_url"`
  1115  		GitSSHURL         string          `json:"git_ssh_url"`
  1116  		GitHTTPURL        string          `json:"git_http_url"`
  1117  		Namespace         string          `json:"namespace"`
  1118  		PathWithNamespace string          `json:"path_with_namespace"`
  1119  		DefaultBranch     string          `json:"default_branch"`
  1120  		Homepage          string          `json:"homepage"`
  1121  		URL               string          `json:"url"`
  1122  		SSHURL            string          `json:"ssh_url"`
  1123  		HTTPURL           string          `json:"http_url"`
  1124  		WebURL            string          `json:"web_url"`
  1125  		Visibility        VisibilityValue `json:"visibility"`
  1126  	} `json:"project"`
  1127  	Repository *Repository `json:"repository"`
  1128  	Commits    []*struct {
  1129  		ID        string     `json:"id"`
  1130  		Message   string     `json:"message"`
  1131  		Title     string     `json:"title"`
  1132  		Timestamp *time.Time `json:"timestamp"`
  1133  		URL       string     `json:"url"`
  1134  		Author    struct {
  1135  			Name  string `json:"name"`
  1136  			Email string `json:"email"`
  1137  		} `json:"author"`
  1138  		Added    []string `json:"added"`
  1139  		Modified []string `json:"modified"`
  1140  		Removed  []string `json:"removed"`
  1141  	} `json:"commits"`
  1142  	TotalCommitsCount int `json:"total_commits_count"`
  1143  }
  1144  
  1145  // WikiPageEvent represents a wiki page event.
  1146  //
  1147  // GitLab API docs:
  1148  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#wiki-page-events
  1149  type WikiPageEvent struct {
  1150  	ObjectKind string     `json:"object_kind"`
  1151  	User       *EventUser `json:"user"`
  1152  	Project    struct {
  1153  		Name              string          `json:"name"`
  1154  		Description       string          `json:"description"`
  1155  		AvatarURL         string          `json:"avatar_url"`
  1156  		GitSSHURL         string          `json:"git_ssh_url"`
  1157  		GitHTTPURL        string          `json:"git_http_url"`
  1158  		Namespace         string          `json:"namespace"`
  1159  		PathWithNamespace string          `json:"path_with_namespace"`
  1160  		DefaultBranch     string          `json:"default_branch"`
  1161  		Homepage          string          `json:"homepage"`
  1162  		URL               string          `json:"url"`
  1163  		SSHURL            string          `json:"ssh_url"`
  1164  		HTTPURL           string          `json:"http_url"`
  1165  		WebURL            string          `json:"web_url"`
  1166  		Visibility        VisibilityValue `json:"visibility"`
  1167  	} `json:"project"`
  1168  	Wiki struct {
  1169  		WebURL            string `json:"web_url"`
  1170  		GitSSHURL         string `json:"git_ssh_url"`
  1171  		GitHTTPURL        string `json:"git_http_url"`
  1172  		PathWithNamespace string `json:"path_with_namespace"`
  1173  		DefaultBranch     string `json:"default_branch"`
  1174  	} `json:"wiki"`
  1175  	ObjectAttributes struct {
  1176  		Title   string `json:"title"`
  1177  		Content string `json:"content"`
  1178  		Format  string `json:"format"`
  1179  		Message string `json:"message"`
  1180  		Slug    string `json:"slug"`
  1181  		URL     string `json:"url"`
  1182  		Action  string `json:"action"`
  1183  		DiffURL string `json:"diff_url"`
  1184  	} `json:"object_attributes"`
  1185  }
  1186  
  1187  // EventLabel represents a label inside a webhook event.
  1188  //
  1189  // GitLab API docs:
  1190  // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#issue-events
  1191  type EventLabel struct {
  1192  	ID          int    `json:"id"`
  1193  	Title       string `json:"title"`
  1194  	Color       string `json:"color"`
  1195  	ProjectID   int    `json:"project_id"`
  1196  	CreatedAt   string `json:"created_at"`
  1197  	UpdatedAt   string `json:"updated_at"`
  1198  	Template    bool   `json:"template"`
  1199  	Description string `json:"description"`
  1200  	Type        string `json:"type"`
  1201  	GroupID     int    `json:"group_id"`
  1202  }
  1203  

View as plain text