diff --git a/github/github-accessors.go b/github/github-accessors.go index 952d3d8fea0..e42217f5099 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -19446,6 +19446,14 @@ func (g *GetProvisionedSCIMGroupEnterpriseOptions) GetExcludedAttributes() strin return *g.ExcludedAttributes } +// GetIncludeMetadata returns the IncludeMetadata field. +func (g *GetRuleSuiteOptions) GetIncludeMetadata() bool { + if g == nil { + return false + } + return g.IncludeMetadata +} + // GetComments returns the Comments field if it's non-nil, zero value otherwise. func (g *Gist) GetComments() int { if g == nil || g.Comments == nil { @@ -25702,6 +25710,54 @@ func (l *ListRepositorySecurityAdvisoriesOptions) GetState() string { return l.State } +// GetActorName returns the ActorName field. +func (l *ListRuleSuitesOptions) GetActorName() string { + if l == nil { + return "" + } + return l.ActorName +} + +// GetEvaluateStatus returns the EvaluateStatus field. +func (l *ListRuleSuitesOptions) GetEvaluateStatus() string { + if l == nil { + return "" + } + return l.EvaluateStatus +} + +// GetRef returns the Ref field. +func (l *ListRuleSuitesOptions) GetRef() string { + if l == nil { + return "" + } + return l.Ref +} + +// GetRepositoryName returns the RepositoryName field. +func (l *ListRuleSuitesOptions) GetRepositoryName() string { + if l == nil { + return "" + } + return l.RepositoryName +} + +// GetRuleSuiteResult returns the RuleSuiteResult field. +func (l *ListRuleSuitesOptions) GetRuleSuiteResult() string { + if l == nil { + return "" + } + return l.RuleSuiteResult +} + +// GetTimePeriod returns the TimePeriod field. +func (l *ListRuleSuitesOptions) GetTimePeriod() string { + if l == nil { + return "" + } + return l.TimePeriod +} + // GetName returns the Name field if it's non-nil, zero value otherwise. func (l *ListRunnersOptions) GetName() string { if l == nil || l.Name == nil { @@ -40582,6 +40638,238 @@ func (r *RuleCodeScanningTool) GetTool() string { return r.Tool } +// GetDetails returns the Details field if it's non-nil, zero value otherwise. +func (r *RuleEvaluation) GetDetails() string { + if r == nil || r.Details == nil { + return "" + } + return *r.Details +} + +// GetEnforcement returns the Enforcement field if it's non-nil, zero value otherwise. +func (r *RuleEvaluation) GetEnforcement() string { + if r == nil || r.Enforcement == nil { + return "" + } + return *r.Enforcement +} + +// GetMetadata returns the Metadata field. +func (r *RuleEvaluation) GetMetadata() *RuleEvaluationMetadata { + if r == nil { + return nil + } + return r.Metadata +} + +// GetResult returns the Result field if it's non-nil, zero value otherwise. +func (r *RuleEvaluation) GetResult() string { + if r == nil || r.Result == nil { + return "" + } + return *r.Result +} + +// GetRuleSource returns the RuleSource field. +func (r *RuleEvaluation) GetRuleSource() *RuleEvaluationSource { + if r == nil { + return nil + } + return r.RuleSource +} + +// GetRuleType returns the RuleType field if it's non-nil, zero value otherwise. +func (r *RuleEvaluation) GetRuleType() string { + if r == nil || r.RuleType == nil { + return "" + } + return *r.RuleType +} + +// GetChecks returns the Checks slice if it's non-nil, nil otherwise. +func (r *RuleEvaluationMetadata) GetChecks() []*RuleEvaluationStatusCheck { + if r == nil || r.Checks == nil { + return nil + } + return r.Checks +} + +// GetPullRequest returns the PullRequest field. +func (r *RuleEvaluationMetadata) GetPullRequest() *RuleEvaluationPullRequest { + if r == nil { + return nil + } + return r.PullRequest +} + +// GetBaseSHA returns the BaseSHA field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationProofOfPresence) GetBaseSHA() string { + if r == nil || r.BaseSHA == nil { + return "" + } + return *r.BaseSHA +} + +// GetCode returns the Code field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationProofOfPresence) GetCode() string { + if r == nil || r.Code == nil { + return "" + } + return *r.Code +} + +// GetHeadSHA returns the HeadSHA field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationProofOfPresence) GetHeadSHA() string { + if r == nil || r.HeadSHA == nil { + return "" + } + return *r.HeadSHA +} + +// GetRequiredLevel returns the RequiredLevel field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationProofOfPresence) GetRequiredLevel() string { + if r == nil || r.RequiredLevel == nil { + return "" + } + return *r.RequiredLevel +} + +// GetState returns the State field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationProofOfPresence) GetState() string { + if r == nil || r.State == nil { + return "" + } + return *r.State +} + +// GetVerifiedAt returns the VerifiedAt field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationProofOfPresence) GetVerifiedAt() string { + if r == nil || r.VerifiedAt == nil { + return "" + } + return *r.VerifiedAt +} + +// GetVerifiedLevel returns the VerifiedLevel field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationProofOfPresence) GetVerifiedLevel() string { + if r == nil || r.VerifiedLevel == nil { + return "" + } + return *r.VerifiedLevel +} + +// GetVerifier returns the Verifier field. +func (r *RuleEvaluationProofOfPresence) GetVerifier() *User { + if r == nil { + return nil + } + return r.Verifier +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationPullRequest) GetID() int64 { + if r == nil || r.ID == nil { + return 0 + } + return *r.ID +} + +// GetNumber returns the Number field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationPullRequest) GetNumber() int { + if r == nil || r.Number == nil { + return 0 + } + return *r.Number +} + +// GetProofOfPresence returns the ProofOfPresence field. +func (r *RuleEvaluationPullRequest) GetProofOfPresence() *RuleEvaluationProofOfPresence { + if r == nil { + return nil + } + return r.ProofOfPresence +} + +// GetReviews returns the Reviews slice if it's non-nil, nil otherwise. +func (r *RuleEvaluationPullRequest) GetReviews() []*PullRequestReview { + if r == nil || r.Reviews == nil { + return nil + } + return r.Reviews +} + +// GetUser returns the User field. +func (r *RuleEvaluationPullRequest) GetUser() *User { + if r == nil { + return nil + } + return r.User +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationSource) GetID() int64 { + if r == nil || r.ID == nil { + return 0 + } + return *r.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationSource) GetName() string { + if r == nil || r.Name == nil { + return "" + } + return *r.Name +} + +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationSource) GetType() string { + if r == nil || r.Type == nil { + return "" + } + return *r.Type +} + +// GetApp returns the App field. +func (r *RuleEvaluationStatusCheck) GetApp() *App { + if r == nil { + return nil + } + return r.App +} + +// GetContext returns the Context field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationStatusCheck) GetContext() string { + if r == nil || r.Context == nil { + return "" + } + return *r.Context +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationStatusCheck) GetID() int64 { + if r == nil || r.ID == nil { + return 0 + } + return *r.ID +} + +// GetState returns the State field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationStatusCheck) GetState() string { + if r == nil || r.State == nil { + return "" + } + return *r.State +} + +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (r *RuleEvaluationStatusCheck) GetType() string { + if r == nil || r.Type == nil { + return "" + } + return *r.Type +} + // GetFilePatterns returns the FilePatterns slice if it's non-nil, nil otherwise. func (r *RulesetRequiredReviewer) GetFilePatterns() []string { if r == nil || r.FilePatterns == nil { @@ -40638,6 +40926,102 @@ func (r *RuleStatusCheck) GetIntegrationID() int64 { return *r.IntegrationID } +// GetActorID returns the ActorID field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetActorID() int64 { + if r == nil || r.ActorID == nil { + return 0 + } + return *r.ActorID +} + +// GetActorName returns the ActorName field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetActorName() string { + if r == nil || r.ActorName == nil { + return "" + } + return *r.ActorName +} + +// GetAfterSHA returns the AfterSHA field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetAfterSHA() string { + if r == nil || r.AfterSHA == nil { + return "" + } + return *r.AfterSHA +} + +// GetBeforeSHA returns the BeforeSHA field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetBeforeSHA() string { + if r == nil || r.BeforeSHA == nil { + return "" + } + return *r.BeforeSHA +} + +// GetEvaluationResult returns the EvaluationResult field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetEvaluationResult() string { + if r == nil || r.EvaluationResult == nil { + return "" + } + return *r.EvaluationResult +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetID() int64 { + if r == nil || r.ID == nil { + return 0 + } + return *r.ID +} + +// GetPushedAt returns the PushedAt field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetPushedAt() Timestamp { + if r == nil || r.PushedAt == nil { + return Timestamp{} + } + return *r.PushedAt +} + +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetRef() string { + if r == nil || r.Ref == nil { + return "" + } + return *r.Ref +} + +// GetRepositoryID returns the RepositoryID field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetRepositoryID() int64 { + if r == nil || r.RepositoryID == nil { + return 0 + } + return *r.RepositoryID +} + +// GetRepositoryName returns the RepositoryName field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetRepositoryName() string { + if r == nil || r.RepositoryName == nil { + return "" + } + return *r.RepositoryName +} + +// GetResult returns the Result field if it's non-nil, zero value otherwise. +func (r *RuleSuite) GetResult() string { + if r == nil || r.Result == nil { + return "" + } + return *r.Result +} + +// GetRuleEvaluations returns the RuleEvaluations slice if it's non-nil, nil otherwise. +func (r *RuleSuite) GetRuleEvaluations() []*RuleEvaluation { + if r == nil || r.RuleEvaluations == nil { + return nil + } + return r.RuleEvaluations +} + // GetPath returns the Path field. func (r *RuleWorkflow) GetPath() string { if r == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 7e9ad6671c9..9ef0eae558b 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -24310,6 +24310,14 @@ func TestGetProvisionedSCIMGroupEnterpriseOptions_GetExcludedAttributes(tt *test g.GetExcludedAttributes() } +func TestGetRuleSuiteOptions_GetIncludeMetadata(tt *testing.T) { + tt.Parallel() + g := &GetRuleSuiteOptions{} + g.GetIncludeMetadata() + g = nil + g.GetIncludeMetadata() +} + func TestGist_GetComments(tt *testing.T) { tt.Parallel() var zeroValue int @@ -32129,6 +32137,54 @@ func TestListRepositorySecurityAdvisoriesOptions_GetState(tt *testing.T) { l.GetState() } +func TestListRuleSuitesOptions_GetActorName(tt *testing.T) { + tt.Parallel() + l := &ListRuleSuitesOptions{} + l.GetActorName() + l = nil + l.GetActorName() +} + +func TestListRuleSuitesOptions_GetEvaluateStatus(tt *testing.T) { + tt.Parallel() + l := &ListRuleSuitesOptions{} + l.GetEvaluateStatus() + l = nil + l.GetEvaluateStatus() +} + +func TestListRuleSuitesOptions_GetRef(tt *testing.T) { + tt.Parallel() + l := &ListRuleSuitesOptions{} + l.GetRef() + l = nil + l.GetRef() +} + +func TestListRuleSuitesOptions_GetRepositoryName(tt *testing.T) { + tt.Parallel() + l := &ListRuleSuitesOptions{} + l.GetRepositoryName() + l = nil + l.GetRepositoryName() +} + +func TestListRuleSuitesOptions_GetRuleSuiteResult(tt *testing.T) { + tt.Parallel() + l := &ListRuleSuitesOptions{} + l.GetRuleSuiteResult() + l = nil + l.GetRuleSuiteResult() +} + +func TestListRuleSuitesOptions_GetTimePeriod(tt *testing.T) { + tt.Parallel() + l := &ListRuleSuitesOptions{} + l.GetTimePeriod() + l = nil + l.GetTimePeriod() +} + func TestListRunnersOptions_GetName(tt *testing.T) { tt.Parallel() var zeroValue string @@ -50585,6 +50641,304 @@ func TestRuleCodeScanningTool_GetTool(tt *testing.T) { r.GetTool() } +func TestRuleEvaluation_GetDetails(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluation{Details: &zeroValue} + r.GetDetails() + r = &RuleEvaluation{} + r.GetDetails() + r = nil + r.GetDetails() +} + +func TestRuleEvaluation_GetEnforcement(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluation{Enforcement: &zeroValue} + r.GetEnforcement() + r = &RuleEvaluation{} + r.GetEnforcement() + r = nil + r.GetEnforcement() +} + +func TestRuleEvaluation_GetMetadata(tt *testing.T) { + tt.Parallel() + r := &RuleEvaluation{} + r.GetMetadata() + r = nil + r.GetMetadata() +} + +func TestRuleEvaluation_GetResult(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluation{Result: &zeroValue} + r.GetResult() + r = &RuleEvaluation{} + r.GetResult() + r = nil + r.GetResult() +} + +func TestRuleEvaluation_GetRuleSource(tt *testing.T) { + tt.Parallel() + r := &RuleEvaluation{} + r.GetRuleSource() + r = nil + r.GetRuleSource() +} + +func TestRuleEvaluation_GetRuleType(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluation{RuleType: &zeroValue} + r.GetRuleType() + r = &RuleEvaluation{} + r.GetRuleType() + r = nil + r.GetRuleType() +} + +func TestRuleEvaluationMetadata_GetChecks(tt *testing.T) { + tt.Parallel() + zeroValue := []*RuleEvaluationStatusCheck{} + r := &RuleEvaluationMetadata{Checks: zeroValue} + r.GetChecks() + r = &RuleEvaluationMetadata{} + r.GetChecks() + r = nil + r.GetChecks() +} + +func TestRuleEvaluationMetadata_GetPullRequest(tt *testing.T) { + tt.Parallel() + r := &RuleEvaluationMetadata{} + r.GetPullRequest() + r = nil + r.GetPullRequest() +} + +func TestRuleEvaluationProofOfPresence_GetBaseSHA(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationProofOfPresence{BaseSHA: &zeroValue} + r.GetBaseSHA() + r = &RuleEvaluationProofOfPresence{} + r.GetBaseSHA() + r = nil + r.GetBaseSHA() +} + +func TestRuleEvaluationProofOfPresence_GetCode(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationProofOfPresence{Code: &zeroValue} + r.GetCode() + r = &RuleEvaluationProofOfPresence{} + r.GetCode() + r = nil + r.GetCode() +} + +func TestRuleEvaluationProofOfPresence_GetHeadSHA(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationProofOfPresence{HeadSHA: &zeroValue} + r.GetHeadSHA() + r = &RuleEvaluationProofOfPresence{} + r.GetHeadSHA() + r = nil + r.GetHeadSHA() +} + +func TestRuleEvaluationProofOfPresence_GetRequiredLevel(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationProofOfPresence{RequiredLevel: &zeroValue} + r.GetRequiredLevel() + r = &RuleEvaluationProofOfPresence{} + r.GetRequiredLevel() + r = nil + r.GetRequiredLevel() +} + +func TestRuleEvaluationProofOfPresence_GetState(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationProofOfPresence{State: &zeroValue} + r.GetState() + r = &RuleEvaluationProofOfPresence{} + r.GetState() + r = nil + r.GetState() +} + +func TestRuleEvaluationProofOfPresence_GetVerifiedAt(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationProofOfPresence{VerifiedAt: &zeroValue} + r.GetVerifiedAt() + r = &RuleEvaluationProofOfPresence{} + r.GetVerifiedAt() + r = nil + r.GetVerifiedAt() +} + +func TestRuleEvaluationProofOfPresence_GetVerifiedLevel(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationProofOfPresence{VerifiedLevel: &zeroValue} + r.GetVerifiedLevel() + r = &RuleEvaluationProofOfPresence{} + r.GetVerifiedLevel() + r = nil + r.GetVerifiedLevel() +} + +func TestRuleEvaluationProofOfPresence_GetVerifier(tt *testing.T) { + tt.Parallel() + r := &RuleEvaluationProofOfPresence{} + r.GetVerifier() + r = nil + r.GetVerifier() +} + +func TestRuleEvaluationPullRequest_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + r := &RuleEvaluationPullRequest{ID: &zeroValue} + r.GetID() + r = &RuleEvaluationPullRequest{} + r.GetID() + r = nil + r.GetID() +} + +func TestRuleEvaluationPullRequest_GetNumber(tt *testing.T) { + tt.Parallel() + var zeroValue int + r := &RuleEvaluationPullRequest{Number: &zeroValue} + r.GetNumber() + r = &RuleEvaluationPullRequest{} + r.GetNumber() + r = nil + r.GetNumber() +} + +func TestRuleEvaluationPullRequest_GetProofOfPresence(tt *testing.T) { + tt.Parallel() + r := &RuleEvaluationPullRequest{} + r.GetProofOfPresence() + r = nil + r.GetProofOfPresence() +} + +func TestRuleEvaluationPullRequest_GetReviews(tt *testing.T) { + tt.Parallel() + zeroValue := []*PullRequestReview{} + r := &RuleEvaluationPullRequest{Reviews: zeroValue} + r.GetReviews() + r = &RuleEvaluationPullRequest{} + r.GetReviews() + r = nil + r.GetReviews() +} + +func TestRuleEvaluationPullRequest_GetUser(tt *testing.T) { + tt.Parallel() + r := &RuleEvaluationPullRequest{} + r.GetUser() + r = nil + r.GetUser() +} + +func TestRuleEvaluationSource_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + r := &RuleEvaluationSource{ID: &zeroValue} + r.GetID() + r = &RuleEvaluationSource{} + r.GetID() + r = nil + r.GetID() +} + +func TestRuleEvaluationSource_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationSource{Name: &zeroValue} + r.GetName() + r = &RuleEvaluationSource{} + r.GetName() + r = nil + r.GetName() +} + +func TestRuleEvaluationSource_GetType(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationSource{Type: &zeroValue} + r.GetType() + r = &RuleEvaluationSource{} + r.GetType() + r = nil + r.GetType() +} + +func TestRuleEvaluationStatusCheck_GetApp(tt *testing.T) { + tt.Parallel() + r := &RuleEvaluationStatusCheck{} + r.GetApp() + r = nil + r.GetApp() +} + +func TestRuleEvaluationStatusCheck_GetContext(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationStatusCheck{Context: &zeroValue} + r.GetContext() + r = &RuleEvaluationStatusCheck{} + r.GetContext() + r = nil + r.GetContext() +} + +func TestRuleEvaluationStatusCheck_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + r := &RuleEvaluationStatusCheck{ID: &zeroValue} + r.GetID() + r = &RuleEvaluationStatusCheck{} + r.GetID() + r = nil + r.GetID() +} + +func TestRuleEvaluationStatusCheck_GetState(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationStatusCheck{State: &zeroValue} + r.GetState() + r = &RuleEvaluationStatusCheck{} + r.GetState() + r = nil + r.GetState() +} + +func TestRuleEvaluationStatusCheck_GetType(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleEvaluationStatusCheck{Type: &zeroValue} + r.GetType() + r = &RuleEvaluationStatusCheck{} + r.GetType() + r = nil + r.GetType() +} + func TestRulesetRequiredReviewer_GetFilePatterns(tt *testing.T) { tt.Parallel() zeroValue := []string{} @@ -50653,6 +51007,138 @@ func TestRuleStatusCheck_GetIntegrationID(tt *testing.T) { r.GetIntegrationID() } +func TestRuleSuite_GetActorID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + r := &RuleSuite{ActorID: &zeroValue} + r.GetActorID() + r = &RuleSuite{} + r.GetActorID() + r = nil + r.GetActorID() +} + +func TestRuleSuite_GetActorName(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleSuite{ActorName: &zeroValue} + r.GetActorName() + r = &RuleSuite{} + r.GetActorName() + r = nil + r.GetActorName() +} + +func TestRuleSuite_GetAfterSHA(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleSuite{AfterSHA: &zeroValue} + r.GetAfterSHA() + r = &RuleSuite{} + r.GetAfterSHA() + r = nil + r.GetAfterSHA() +} + +func TestRuleSuite_GetBeforeSHA(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleSuite{BeforeSHA: &zeroValue} + r.GetBeforeSHA() + r = &RuleSuite{} + r.GetBeforeSHA() + r = nil + r.GetBeforeSHA() +} + +func TestRuleSuite_GetEvaluationResult(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleSuite{EvaluationResult: &zeroValue} + r.GetEvaluationResult() + r = &RuleSuite{} + r.GetEvaluationResult() + r = nil + r.GetEvaluationResult() +} + +func TestRuleSuite_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + r := &RuleSuite{ID: &zeroValue} + r.GetID() + r = &RuleSuite{} + r.GetID() + r = nil + r.GetID() +} + +func TestRuleSuite_GetPushedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + r := &RuleSuite{PushedAt: &zeroValue} + r.GetPushedAt() + r = &RuleSuite{} + r.GetPushedAt() + r = nil + r.GetPushedAt() +} + +func TestRuleSuite_GetRef(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleSuite{Ref: &zeroValue} + r.GetRef() + r = &RuleSuite{} + r.GetRef() + r = nil + r.GetRef() +} + +func TestRuleSuite_GetRepositoryID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + r := &RuleSuite{RepositoryID: &zeroValue} + r.GetRepositoryID() + r = &RuleSuite{} + r.GetRepositoryID() + r = nil + r.GetRepositoryID() +} + +func TestRuleSuite_GetRepositoryName(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleSuite{RepositoryName: &zeroValue} + r.GetRepositoryName() + r = &RuleSuite{} + r.GetRepositoryName() + r = nil + r.GetRepositoryName() +} + +func TestRuleSuite_GetResult(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RuleSuite{Result: &zeroValue} + r.GetResult() + r = &RuleSuite{} + r.GetResult() + r = nil + r.GetResult() +} + +func TestRuleSuite_GetRuleEvaluations(tt *testing.T) { + tt.Parallel() + zeroValue := []*RuleEvaluation{} + r := &RuleSuite{RuleEvaluations: zeroValue} + r.GetRuleEvaluations() + r = &RuleSuite{} + r.GetRuleEvaluations() + r = nil + r.GetRuleEvaluations() +} + func TestRuleWorkflow_GetPath(tt *testing.T) { tt.Parallel() r := &RuleWorkflow{} diff --git a/github/github-iterators.go b/github/github-iterators.go index 3413ef22f63..e16edafcd33 100644 --- a/github/github-iterators.go +++ b/github/github-iterators.go @@ -5384,6 +5384,37 @@ func (s *OrganizationsService) ListPendingOrgInvitationsIter(ctx context.Context } } +// ListRuleSuitesIter returns an iterator that paginates through all results of ListRuleSuites. +func (s *OrganizationsService) ListRuleSuitesIter(ctx context.Context, org string, opts *ListRuleSuitesOptions) iter.Seq2[*RuleSuite, error] { + return func(yield func(*RuleSuite, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListRuleSuitesOptions{} + } else { + opts = new(*opts) + } + + for { + results, resp, err := s.ListRuleSuites(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range results { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + opts.ListOptions.Page = resp.NextPage + } + } +} + // ListTeamsAssignedToOrgRoleIter returns an iterator that paginates through all results of ListTeamsAssignedToOrgRole. func (s *OrganizationsService) ListTeamsAssignedToOrgRoleIter(ctx context.Context, org string, roleID int64, opts *ListOptions) iter.Seq2[*Team, error] { return func(yield func(*Team, error) bool) { diff --git a/github/github-iterators_test.go b/github/github-iterators_test.go index ebbf921315d..d563c878ba9 100644 --- a/github/github-iterators_test.go +++ b/github/github-iterators_test.go @@ -11751,6 +11751,78 @@ func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { } } +func TestOrganizationsService_ListRuleSuitesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListRuleSuitesIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListRuleSuitesIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListRuleSuitesOptions{} + iter = client.Organizations.ListRuleSuitesIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListRuleSuitesIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListRuleSuitesIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListRuleSuitesIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListRuleSuitesIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *RuleSuite, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListRuleSuitesIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) diff --git a/github/orgs_rule_suites.go b/github/orgs_rule_suites.go new file mode 100644 index 00000000000..1845fab48df --- /dev/null +++ b/github/orgs_rule_suites.go @@ -0,0 +1,169 @@ +// Copyright 2026 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// RuleSuite represents a rule suite: the evaluation of the rules that apply to a push. +type RuleSuite struct { + ID *int64 `json:"id,omitempty"` + ActorID *int64 `json:"actor_id,omitempty"` + ActorName *string `json:"actor_name,omitempty"` + BeforeSHA *string `json:"before_sha,omitempty"` + AfterSHA *string `json:"after_sha,omitempty"` + Ref *string `json:"ref,omitempty"` + RepositoryID *int64 `json:"repository_id,omitempty"` + RepositoryName *string `json:"repository_name,omitempty"` + PushedAt *Timestamp `json:"pushed_at,omitempty"` + Result *string `json:"result,omitempty"` + EvaluationResult *string `json:"evaluation_result,omitempty"` + RuleEvaluations []*RuleEvaluation `json:"rule_evaluations,omitempty"` +} + +// RuleEvaluation represents the result of evaluating a single rule within a rule suite. +type RuleEvaluation struct { + RuleSource *RuleEvaluationSource `json:"rule_source,omitempty"` + Enforcement *string `json:"enforcement,omitempty"` + Result *string `json:"result,omitempty"` + RuleType *string `json:"rule_type,omitempty"` + Details *string `json:"details,omitempty"` + Metadata *RuleEvaluationMetadata `json:"metadata,omitempty"` +} + +// RuleEvaluationMetadata represents additional metadata about a rule evaluation. +// PullRequest is set for pull_request rules, and Checks is set for required_status_checks rules. +type RuleEvaluationMetadata struct { + PullRequest *RuleEvaluationPullRequest `json:"pull_request,omitempty"` + Checks []*RuleEvaluationStatusCheck `json:"checks,omitempty"` +} + +// RuleEvaluationPullRequest represents the pull request associated with a rule evaluation. +type RuleEvaluationPullRequest struct { + ID *int64 `json:"id,omitempty"` + Number *int `json:"number,omitempty"` + User *User `json:"user,omitempty"` + Reviews []*PullRequestReview `json:"reviews,omitempty"` + ProofOfPresence *RuleEvaluationProofOfPresence `json:"proof_of_presence,omitempty"` +} + +// RuleEvaluationProofOfPresence represents the proof of presence evaluation for a pull request. +type RuleEvaluationProofOfPresence struct { + State *string `json:"state,omitempty"` + Code *string `json:"code,omitempty"` + BaseSHA *string `json:"base_sha,omitempty"` + HeadSHA *string `json:"head_sha,omitempty"` + RequiredLevel *string `json:"required_level,omitempty"` + VerifiedLevel *string `json:"verified_level,omitempty"` + VerifiedAt *string `json:"verified_at,omitempty"` + Verifier *User `json:"verifier,omitempty"` +} + +// RuleEvaluationStatusCheck represents a status check associated with a rule evaluation. +type RuleEvaluationStatusCheck struct { + ID *int64 `json:"id,omitempty"` + Context *string `json:"context,omitempty"` + State *string `json:"state,omitempty"` + Type *string `json:"type,omitempty"` + App *App `json:"app,omitempty"` +} + +// RuleEvaluationSource represents the source of an evaluated rule. +type RuleEvaluationSource struct { + Type *string `json:"type,omitempty"` + ID *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +// ListRuleSuitesOptions specifies the optional parameters to the +// OrganizationsService.ListRuleSuites method. +type ListRuleSuitesOptions struct { + // Ref filters rule suites by the name of the ref, which cannot contain wildcard characters. + // Prefix it with "refs/heads/" to limit to branches or "refs/tags/" to limit to tags. + Ref string `url:"ref,omitempty"` + + // RepositoryName filters rule suites by the name of the repository. + RepositoryName string `url:"repository_name,omitempty"` + + // TimePeriod filters rule suites by the time period in which they occurred. + // Can be one of: "hour", "day", "week", "month". Default: "day". + TimePeriod string `url:"time_period,omitempty"` + + // ActorName filters rule suites by the handle of the user who triggered them. + ActorName string `url:"actor_name,omitempty"` + + // RuleSuiteResult filters rule suites by their result. + // Can be one of: "pass", "fail", "bypass", "all". Default: "all". + RuleSuiteResult string `url:"rule_suite_result,omitempty"` + + // EvaluateStatus filters rule suites by the evaluate status of the rulesets that produced them. + // Can be one of: "all", "active", "evaluate". Default: "all". + EvaluateStatus string `url:"evaluate_status,omitempty"` + + ListOptions +} + +// ListRuleSuites lists the rule suites for an organization. +// +// GitHub API docs: https://docs.github.com/rest/orgs/rule-suites?apiVersion=2022-11-28#list-organization-rule-suites +// +//meta:operation GET /orgs/{org}/rulesets/rule-suites +func (s *OrganizationsService) ListRuleSuites(ctx context.Context, org string, opts *ListRuleSuitesOptions) ([]*RuleSuite, *Response, error) { + u := fmt.Sprintf("orgs/%v/rulesets/rule-suites", org) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest(ctx, "GET", u, nil) + if err != nil { + return nil, nil, err + } + + var ruleSuites []*RuleSuite + resp, err := s.client.Do(req, &ruleSuites) + if err != nil { + return nil, resp, err + } + + return ruleSuites, resp, nil +} + +// GetRuleSuiteOptions specifies the optional parameters to the +// OrganizationsService.GetRuleSuite method. +type GetRuleSuiteOptions struct { + // IncludeMetadata, when true, includes additional metadata for pull request + // and required status check rule evaluations. Default: false. + IncludeMetadata bool `url:"include_metadata,omitempty"` +} + +// GetRuleSuite gets a rule suite for an organization. +// +// GitHub API docs: https://docs.github.com/rest/orgs/rule-suites?apiVersion=2022-11-28#get-an-organization-rule-suite +// +//meta:operation GET /orgs/{org}/rulesets/rule-suites/{rule_suite_id} +func (s *OrganizationsService) GetRuleSuite(ctx context.Context, org string, ruleSuiteID int64, opts *GetRuleSuiteOptions) (*RuleSuite, *Response, error) { + u := fmt.Sprintf("orgs/%v/rulesets/rule-suites/%v", org, ruleSuiteID) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest(ctx, "GET", u, nil) + if err != nil { + return nil, nil, err + } + + var ruleSuite *RuleSuite + resp, err := s.client.Do(req, &ruleSuite) + if err != nil { + return nil, resp, err + } + + return ruleSuite, resp, nil +} diff --git a/github/orgs_rule_suites_test.go b/github/orgs_rule_suites_test.go new file mode 100644 index 00000000000..2f8751917f9 --- /dev/null +++ b/github/orgs_rule_suites_test.go @@ -0,0 +1,260 @@ +// Copyright 2026 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "fmt" + "net/http" + "testing" + + "github.com/google/go-cmp/cmp" +) + +func TestOrganizationsService_ListRuleSuites(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/rulesets/rule-suites", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{ + "ref": "refs/heads/main", + "repository_name": "r", + "time_period": "week", + "actor_name": "octocat", + "rule_suite_result": "fail", + "evaluate_status": "evaluate", + "page": "2", + "per_page": "30", + }) + fmt.Fprint(w, `[{ + "id": 21, + "actor_id": 12, + "actor_name": "octocat", + "before_sha": "893f768e172fb1bc9c5d6f3dd48557e45f14e01d", + "after_sha": "dedd88641a362b6b4ea872da4847d6131a164d01", + "ref": "refs/heads/i-see-everything", + "repository_id": 404, + "repository_name": "r", + "pushed_at": `+referenceTimeStr+`, + "result": "bypass", + "evaluation_result": "fail" + }]`) + }) + + ctx := t.Context() + opts := &ListRuleSuitesOptions{ + Ref: "refs/heads/main", + RepositoryName: "r", + TimePeriod: "week", + ActorName: "octocat", + RuleSuiteResult: "fail", + EvaluateStatus: "evaluate", + ListOptions: ListOptions{Page: 2, PerPage: 30}, + } + ruleSuites, _, err := client.Organizations.ListRuleSuites(ctx, "o", opts) + if err != nil { + t.Errorf("Organizations.ListRuleSuites returned error: %v", err) + } + + want := []*RuleSuite{{ + ID: new(int64(21)), + ActorID: new(int64(12)), + ActorName: new("octocat"), + BeforeSHA: new("893f768e172fb1bc9c5d6f3dd48557e45f14e01d"), + AfterSHA: new("dedd88641a362b6b4ea872da4847d6131a164d01"), + Ref: new("refs/heads/i-see-everything"), + RepositoryID: new(int64(404)), + RepositoryName: new("r"), + PushedAt: &referenceTimestamp, + Result: new("bypass"), + EvaluationResult: new("fail"), + }} + if !cmp.Equal(ruleSuites, want) { + t.Errorf("Organizations.ListRuleSuites returned %+v, want %+v", ruleSuites, want) + } + + const methodName = "ListRuleSuites" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Organizations.ListRuleSuites(ctx, "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Organizations.ListRuleSuites(ctx, "o", opts) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + +func TestOrganizationsService_GetRuleSuite(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/rulesets/rule-suites/21", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"include_metadata": "true"}) + fmt.Fprint(w, `{ + "id": 21, + "actor_id": 12, + "actor_name": "octocat", + "before_sha": "893f768e172fb1bc9c5d6f3dd48557e45f14e01d", + "after_sha": "dedd88641a362b6b4ea872da4847d6131a164d01", + "ref": "refs/heads/i-see-everything", + "repository_id": 404, + "repository_name": "r", + "pushed_at": `+referenceTimeStr+`, + "result": "bypass", + "evaluation_result": "fail", + "rule_evaluations": [ + { + "rule_source": { + "type": "ruleset", + "id": 2, + "name": "Author email must be a GitHub email address" + }, + "enforcement": "active", + "result": "pass", + "rule_type": "commit_author_email_pattern", + "details": "Commit author email is valid" + }, + { + "rule_source": {"type": "ruleset", "id": 3, "name": "Require reviews"}, + "enforcement": "active", + "result": "fail", + "rule_type": "pull_request", + "metadata": { + "pull_request": { + "id": 100, + "number": 7, + "user": {"id": 1, "login": "octocat", "type": "User"}, + "reviews": [{"id": 200, "user": {"id": 2, "login": "hubot", "type": "User"}, "state": "APPROVED"}], + "proof_of_presence": { + "state": "pending", + "code": "not_verified", + "base_sha": "", + "head_sha": "", + "required_level": "", + "verified_level": "", + "verified_at": "", + "verifier": null + } + } + } + }, + { + "rule_source": {"type": "ruleset", "id": 4, "name": "Require CI"}, + "enforcement": "active", + "result": "pass", + "rule_type": "required_status_checks", + "metadata": { + "checks": [{ + "id": 300, + "context": "ci/build", + "state": "success", + "type": "check_run", + "app": {"id": 15368, "slug": "github-actions", "name": "GitHub Actions"} + }] + } + } + ] + }`) + }) + + ctx := t.Context() + opts := &GetRuleSuiteOptions{IncludeMetadata: true} + ruleSuite, _, err := client.Organizations.GetRuleSuite(ctx, "o", 21, opts) + if err != nil { + t.Errorf("Organizations.GetRuleSuite returned error: %v", err) + } + + want := &RuleSuite{ + ID: new(int64(21)), + ActorID: new(int64(12)), + ActorName: new("octocat"), + BeforeSHA: new("893f768e172fb1bc9c5d6f3dd48557e45f14e01d"), + AfterSHA: new("dedd88641a362b6b4ea872da4847d6131a164d01"), + Ref: new("refs/heads/i-see-everything"), + RepositoryID: new(int64(404)), + RepositoryName: new("r"), + PushedAt: &referenceTimestamp, + Result: new("bypass"), + EvaluationResult: new("fail"), + RuleEvaluations: []*RuleEvaluation{ + { + RuleSource: &RuleEvaluationSource{ + Type: new("ruleset"), + ID: new(int64(2)), + Name: new("Author email must be a GitHub email address"), + }, + Enforcement: new("active"), + Result: new("pass"), + RuleType: new("commit_author_email_pattern"), + Details: new("Commit author email is valid"), + }, + { + RuleSource: &RuleEvaluationSource{Type: new("ruleset"), ID: new(int64(3)), Name: new("Require reviews")}, + Enforcement: new("active"), + Result: new("fail"), + RuleType: new("pull_request"), + Metadata: &RuleEvaluationMetadata{ + PullRequest: &RuleEvaluationPullRequest{ + ID: new(int64(100)), + Number: new(7), + User: &User{ID: new(int64(1)), Login: new("octocat"), Type: new("User")}, + Reviews: []*PullRequestReview{{ + ID: new(int64(200)), + User: &User{ID: new(int64(2)), Login: new("hubot"), Type: new("User")}, + State: new("APPROVED"), + }}, + ProofOfPresence: &RuleEvaluationProofOfPresence{ + State: new("pending"), + Code: new("not_verified"), + BaseSHA: new(""), + HeadSHA: new(""), + RequiredLevel: new(""), + VerifiedLevel: new(""), + VerifiedAt: new(""), + }, + }, + }, + }, + { + RuleSource: &RuleEvaluationSource{Type: new("ruleset"), ID: new(int64(4)), Name: new("Require CI")}, + Enforcement: new("active"), + Result: new("pass"), + RuleType: new("required_status_checks"), + Metadata: &RuleEvaluationMetadata{ + Checks: []*RuleEvaluationStatusCheck{{ + ID: new(int64(300)), + Context: new("ci/build"), + State: new("success"), + Type: new("check_run"), + App: &App{ID: new(int64(15368)), Slug: new("github-actions"), Name: new("GitHub Actions")}, + }}, + }, + }, + }, + } + if !cmp.Equal(ruleSuite, want) { + t.Errorf("Organizations.GetRuleSuite returned %+v, want %+v", ruleSuite, want) + } + + const methodName = "GetRuleSuite" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Organizations.GetRuleSuite(ctx, "\n", -1, opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Organizations.GetRuleSuite(ctx, "o", 21, opts) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +}