diff --git a/github/github-accessors.go b/github/github-accessors.go index 03a8bc19eaa..968f5560bde 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1134,6 +1134,126 @@ func (a *Artifact) GetWorkflowRun() *ArtifactWorkflowRun { return a.WorkflowRun } +// GetAttestationID returns the AttestationID field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetAttestationID() int64 { + if a == nil || a.AttestationID == nil { + return 0 + } + return *a.AttestationID +} + +// GetCluster returns the Cluster field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetCluster() string { + if a == nil || a.Cluster == nil { + return "" + } + return *a.Cluster +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetCreatedAt() Timestamp { + if a == nil || a.CreatedAt == nil { + return Timestamp{} + } + return *a.CreatedAt +} + +// GetDeploymentName returns the DeploymentName field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetDeploymentName() string { + if a == nil || a.DeploymentName == nil { + return "" + } + return *a.DeploymentName +} + +// GetDigest returns the Digest field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetDigest() string { + if a == nil || a.Digest == nil { + return "" + } + return *a.Digest +} + +// GetGithubRepository returns the GithubRepository field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetGithubRepository() string { + if a == nil || a.GithubRepository == nil { + return "" + } + return *a.GithubRepository +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetID() int64 { + if a == nil || a.ID == nil { + return 0 + } + return *a.ID +} + +// GetLogicalEnvironment returns the LogicalEnvironment field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetLogicalEnvironment() string { + if a == nil || a.LogicalEnvironment == nil { + return "" + } + return *a.LogicalEnvironment +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetName() string { + if a == nil || a.Name == nil { + return "" + } + return *a.Name +} + +// GetPhysicalEnvironment returns the PhysicalEnvironment field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetPhysicalEnvironment() string { + if a == nil || a.PhysicalEnvironment == nil { + return "" + } + return *a.PhysicalEnvironment +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetStatus() string { + if a == nil || a.Status == nil { + return "" + } + return *a.Status +} + +// GetTags returns the Tags map if it's non-nil, an empty map otherwise. +func (a *ArtifactDeploymentRecord) GetTags() map[string]string { + if a == nil || a.Tags == nil { + return map[string]string{} + } + return a.Tags +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetUpdatedAt() Timestamp { + if a == nil || a.UpdatedAt == nil { + return Timestamp{} + } + return *a.UpdatedAt +} + +// GetVersion returns the Version field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentRecord) GetVersion() string { + if a == nil || a.Version == nil { + return "" + } + return *a.Version +} + +// GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. +func (a *ArtifactDeploymentResponse) GetTotalCount() int { + if a == nil || a.TotalCount == nil { + return 0 + } + return *a.TotalCount +} + // GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. func (a *ArtifactList) GetTotalCount() int64 { if a == nil || a.TotalCount == nil { @@ -1166,6 +1286,110 @@ func (a *ArtifactPeriodOpt) GetDays() int { return *a.Days } +// GetArtifactURL returns the ArtifactURL field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetArtifactURL() string { + if a == nil || a.ArtifactURL == nil { + return "" + } + return *a.ArtifactURL +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetCreatedAt() Timestamp { + if a == nil || a.CreatedAt == nil { + return Timestamp{} + } + return *a.CreatedAt +} + +// GetDigest returns the Digest field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetDigest() string { + if a == nil || a.Digest == nil { + return "" + } + return *a.Digest +} + +// GetGithubRepository returns the GithubRepository field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetGithubRepository() string { + if a == nil || a.GithubRepository == nil { + return "" + } + return *a.GithubRepository +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetID() int64 { + if a == nil || a.ID == nil { + return 0 + } + return *a.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetName() string { + if a == nil || a.Name == nil { + return "" + } + return *a.Name +} + +// GetPath returns the Path field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetPath() string { + if a == nil || a.Path == nil { + return "" + } + return *a.Path +} + +// GetRegistryURL returns the RegistryURL field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetRegistryURL() string { + if a == nil || a.RegistryURL == nil { + return "" + } + return *a.RegistryURL +} + +// GetRepository returns the Repository field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetRepository() string { + if a == nil || a.Repository == nil { + return "" + } + return *a.Repository +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetStatus() string { + if a == nil || a.Status == nil { + return "" + } + return *a.Status +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetUpdatedAt() Timestamp { + if a == nil || a.UpdatedAt == nil { + return Timestamp{} + } + return *a.UpdatedAt +} + +// GetVersion returns the Version field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageRecord) GetVersion() string { + if a == nil || a.Version == nil { + return "" + } + return *a.Version +} + +// GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. +func (a *ArtifactStorageResponse) GetTotalCount() int { + if a == nil || a.TotalCount == nil { + return 0 + } + return *a.TotalCount +} + // GetHeadBranch returns the HeadBranch field if it's non-nil, zero value otherwise. func (a *ArtifactWorkflowRun) GetHeadBranch() string { if a == nil || a.HeadBranch == nil { @@ -2966,6 +3190,22 @@ func (c *ClassroomUser) GetLogin() string { return *c.Login } +// GetLogicalEnvironment returns the LogicalEnvironment field if it's non-nil, zero value otherwise. +func (c *ClusterDeploymentRecordsRequest) GetLogicalEnvironment() string { + if c == nil || c.LogicalEnvironment == nil { + return "" + } + return *c.LogicalEnvironment +} + +// GetPhysicalEnvironment returns the PhysicalEnvironment field if it's non-nil, zero value otherwise. +func (c *ClusterDeploymentRecordsRequest) GetPhysicalEnvironment() string { + if c == nil || c.PhysicalEnvironment == nil { + return "" + } + return *c.PhysicalEnvironment +} + // GetFingerprint returns the Fingerprint field if it's non-nil, zero value otherwise. func (c *ClusterSSHKey) GetFingerprint() string { if c == nil || c.Fingerprint == nil { @@ -6390,6 +6630,158 @@ func (c *CostCenter) GetState() string { return *c.State } +// GetCluster returns the Cluster field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetCluster() string { + if c == nil || c.Cluster == nil { + return "" + } + return *c.Cluster +} + +// GetDeploymentName returns the DeploymentName field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetDeploymentName() string { + if c == nil || c.DeploymentName == nil { + return "" + } + return *c.DeploymentName +} + +// GetDigest returns the Digest field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetDigest() string { + if c == nil || c.Digest == nil { + return "" + } + return *c.Digest +} + +// GetGithubRepository returns the GithubRepository field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetGithubRepository() string { + if c == nil || c.GithubRepository == nil { + return "" + } + return *c.GithubRepository +} + +// GetLogicalEnvironment returns the LogicalEnvironment field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetLogicalEnvironment() string { + if c == nil || c.LogicalEnvironment == nil { + return "" + } + return *c.LogicalEnvironment +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + +// GetPhysicalEnvironment returns the PhysicalEnvironment field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetPhysicalEnvironment() string { + if c == nil || c.PhysicalEnvironment == nil { + return "" + } + return *c.PhysicalEnvironment +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetStatus() string { + if c == nil || c.Status == nil { + return "" + } + return *c.Status +} + +// GetTags returns the Tags map if it's non-nil, an empty map otherwise. +func (c *CreateArtifactDeploymentRequest) GetTags() map[string]string { + if c == nil || c.Tags == nil { + return map[string]string{} + } + return c.Tags +} + +// GetVersion returns the Version field if it's non-nil, zero value otherwise. +func (c *CreateArtifactDeploymentRequest) GetVersion() string { + if c == nil || c.Version == nil { + return "" + } + return *c.Version +} + +// GetArtifactURL returns the ArtifactURL field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetArtifactURL() string { + if c == nil || c.ArtifactURL == nil { + return "" + } + return *c.ArtifactURL +} + +// GetDigest returns the Digest field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetDigest() string { + if c == nil || c.Digest == nil { + return "" + } + return *c.Digest +} + +// GetGithubRepository returns the GithubRepository field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetGithubRepository() string { + if c == nil || c.GithubRepository == nil { + return "" + } + return *c.GithubRepository +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + +// GetPath returns the Path field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetPath() string { + if c == nil || c.Path == nil { + return "" + } + return *c.Path +} + +// GetRegistryURL returns the RegistryURL field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetRegistryURL() string { + if c == nil || c.RegistryURL == nil { + return "" + } + return *c.RegistryURL +} + +// GetRepository returns the Repository field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetRepository() string { + if c == nil || c.Repository == nil { + return "" + } + return *c.Repository +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetStatus() string { + if c == nil || c.Status == nil { + return "" + } + return *c.Status +} + +// GetVersion returns the Version field if it's non-nil, zero value otherwise. +func (c *CreateArtifactStorageRequest) GetVersion() string { + if c == nil || c.Version == nil { + return "" + } + return *c.Version +} + // GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise. func (c *CreateCheckRunOptions) GetCompletedAt() Timestamp { if c == nil || c.CompletedAt == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 1e8778d11c7..2cdb9cb043c 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1468,6 +1468,171 @@ func TestArtifact_GetWorkflowRun(tt *testing.T) { a.GetWorkflowRun() } +func TestArtifactDeploymentRecord_GetAttestationID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + a := &ArtifactDeploymentRecord{AttestationID: &zeroValue} + a.GetAttestationID() + a = &ArtifactDeploymentRecord{} + a.GetAttestationID() + a = nil + a.GetAttestationID() +} + +func TestArtifactDeploymentRecord_GetCluster(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{Cluster: &zeroValue} + a.GetCluster() + a = &ArtifactDeploymentRecord{} + a.GetCluster() + a = nil + a.GetCluster() +} + +func TestArtifactDeploymentRecord_GetCreatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + a := &ArtifactDeploymentRecord{CreatedAt: &zeroValue} + a.GetCreatedAt() + a = &ArtifactDeploymentRecord{} + a.GetCreatedAt() + a = nil + a.GetCreatedAt() +} + +func TestArtifactDeploymentRecord_GetDeploymentName(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{DeploymentName: &zeroValue} + a.GetDeploymentName() + a = &ArtifactDeploymentRecord{} + a.GetDeploymentName() + a = nil + a.GetDeploymentName() +} + +func TestArtifactDeploymentRecord_GetDigest(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{Digest: &zeroValue} + a.GetDigest() + a = &ArtifactDeploymentRecord{} + a.GetDigest() + a = nil + a.GetDigest() +} + +func TestArtifactDeploymentRecord_GetGithubRepository(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{GithubRepository: &zeroValue} + a.GetGithubRepository() + a = &ArtifactDeploymentRecord{} + a.GetGithubRepository() + a = nil + a.GetGithubRepository() +} + +func TestArtifactDeploymentRecord_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + a := &ArtifactDeploymentRecord{ID: &zeroValue} + a.GetID() + a = &ArtifactDeploymentRecord{} + a.GetID() + a = nil + a.GetID() +} + +func TestArtifactDeploymentRecord_GetLogicalEnvironment(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{LogicalEnvironment: &zeroValue} + a.GetLogicalEnvironment() + a = &ArtifactDeploymentRecord{} + a.GetLogicalEnvironment() + a = nil + a.GetLogicalEnvironment() +} + +func TestArtifactDeploymentRecord_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{Name: &zeroValue} + a.GetName() + a = &ArtifactDeploymentRecord{} + a.GetName() + a = nil + a.GetName() +} + +func TestArtifactDeploymentRecord_GetPhysicalEnvironment(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{PhysicalEnvironment: &zeroValue} + a.GetPhysicalEnvironment() + a = &ArtifactDeploymentRecord{} + a.GetPhysicalEnvironment() + a = nil + a.GetPhysicalEnvironment() +} + +func TestArtifactDeploymentRecord_GetStatus(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{Status: &zeroValue} + a.GetStatus() + a = &ArtifactDeploymentRecord{} + a.GetStatus() + a = nil + a.GetStatus() +} + +func TestArtifactDeploymentRecord_GetTags(tt *testing.T) { + tt.Parallel() + zeroValue := map[string]string{} + a := &ArtifactDeploymentRecord{Tags: zeroValue} + a.GetTags() + a = &ArtifactDeploymentRecord{} + a.GetTags() + a = nil + a.GetTags() +} + +func TestArtifactDeploymentRecord_GetUpdatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + a := &ArtifactDeploymentRecord{UpdatedAt: &zeroValue} + a.GetUpdatedAt() + a = &ArtifactDeploymentRecord{} + a.GetUpdatedAt() + a = nil + a.GetUpdatedAt() +} + +func TestArtifactDeploymentRecord_GetVersion(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactDeploymentRecord{Version: &zeroValue} + a.GetVersion() + a = &ArtifactDeploymentRecord{} + a.GetVersion() + a = nil + a.GetVersion() +} + +func TestArtifactDeploymentResponse_GetTotalCount(tt *testing.T) { + tt.Parallel() + var zeroValue int + a := &ArtifactDeploymentResponse{TotalCount: &zeroValue} + a.GetTotalCount() + a = &ArtifactDeploymentResponse{} + a.GetTotalCount() + a = nil + a.GetTotalCount() +} + func TestArtifactList_GetTotalCount(tt *testing.T) { tt.Parallel() var zeroValue int64 @@ -1512,6 +1677,149 @@ func TestArtifactPeriodOpt_GetDays(tt *testing.T) { a.GetDays() } +func TestArtifactStorageRecord_GetArtifactURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{ArtifactURL: &zeroValue} + a.GetArtifactURL() + a = &ArtifactStorageRecord{} + a.GetArtifactURL() + a = nil + a.GetArtifactURL() +} + +func TestArtifactStorageRecord_GetCreatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + a := &ArtifactStorageRecord{CreatedAt: &zeroValue} + a.GetCreatedAt() + a = &ArtifactStorageRecord{} + a.GetCreatedAt() + a = nil + a.GetCreatedAt() +} + +func TestArtifactStorageRecord_GetDigest(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{Digest: &zeroValue} + a.GetDigest() + a = &ArtifactStorageRecord{} + a.GetDigest() + a = nil + a.GetDigest() +} + +func TestArtifactStorageRecord_GetGithubRepository(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{GithubRepository: &zeroValue} + a.GetGithubRepository() + a = &ArtifactStorageRecord{} + a.GetGithubRepository() + a = nil + a.GetGithubRepository() +} + +func TestArtifactStorageRecord_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + a := &ArtifactStorageRecord{ID: &zeroValue} + a.GetID() + a = &ArtifactStorageRecord{} + a.GetID() + a = nil + a.GetID() +} + +func TestArtifactStorageRecord_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{Name: &zeroValue} + a.GetName() + a = &ArtifactStorageRecord{} + a.GetName() + a = nil + a.GetName() +} + +func TestArtifactStorageRecord_GetPath(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{Path: &zeroValue} + a.GetPath() + a = &ArtifactStorageRecord{} + a.GetPath() + a = nil + a.GetPath() +} + +func TestArtifactStorageRecord_GetRegistryURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{RegistryURL: &zeroValue} + a.GetRegistryURL() + a = &ArtifactStorageRecord{} + a.GetRegistryURL() + a = nil + a.GetRegistryURL() +} + +func TestArtifactStorageRecord_GetRepository(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{Repository: &zeroValue} + a.GetRepository() + a = &ArtifactStorageRecord{} + a.GetRepository() + a = nil + a.GetRepository() +} + +func TestArtifactStorageRecord_GetStatus(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{Status: &zeroValue} + a.GetStatus() + a = &ArtifactStorageRecord{} + a.GetStatus() + a = nil + a.GetStatus() +} + +func TestArtifactStorageRecord_GetUpdatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + a := &ArtifactStorageRecord{UpdatedAt: &zeroValue} + a.GetUpdatedAt() + a = &ArtifactStorageRecord{} + a.GetUpdatedAt() + a = nil + a.GetUpdatedAt() +} + +func TestArtifactStorageRecord_GetVersion(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &ArtifactStorageRecord{Version: &zeroValue} + a.GetVersion() + a = &ArtifactStorageRecord{} + a.GetVersion() + a = nil + a.GetVersion() +} + +func TestArtifactStorageResponse_GetTotalCount(tt *testing.T) { + tt.Parallel() + var zeroValue int + a := &ArtifactStorageResponse{TotalCount: &zeroValue} + a.GetTotalCount() + a = &ArtifactStorageResponse{} + a.GetTotalCount() + a = nil + a.GetTotalCount() +} + func TestArtifactWorkflowRun_GetHeadBranch(tt *testing.T) { tt.Parallel() var zeroValue string @@ -3864,6 +4172,28 @@ func TestClassroomUser_GetLogin(tt *testing.T) { c.GetLogin() } +func TestClusterDeploymentRecordsRequest_GetLogicalEnvironment(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &ClusterDeploymentRecordsRequest{LogicalEnvironment: &zeroValue} + c.GetLogicalEnvironment() + c = &ClusterDeploymentRecordsRequest{} + c.GetLogicalEnvironment() + c = nil + c.GetLogicalEnvironment() +} + +func TestClusterDeploymentRecordsRequest_GetPhysicalEnvironment(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &ClusterDeploymentRecordsRequest{PhysicalEnvironment: &zeroValue} + c.GetPhysicalEnvironment() + c = &ClusterDeploymentRecordsRequest{} + c.GetPhysicalEnvironment() + c = nil + c.GetPhysicalEnvironment() +} + func TestClusterSSHKey_GetFingerprint(tt *testing.T) { tt.Parallel() var zeroValue string @@ -8338,6 +8668,215 @@ func TestCostCenter_GetState(tt *testing.T) { c.GetState() } +func TestCreateArtifactDeploymentRequest_GetCluster(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{Cluster: &zeroValue} + c.GetCluster() + c = &CreateArtifactDeploymentRequest{} + c.GetCluster() + c = nil + c.GetCluster() +} + +func TestCreateArtifactDeploymentRequest_GetDeploymentName(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{DeploymentName: &zeroValue} + c.GetDeploymentName() + c = &CreateArtifactDeploymentRequest{} + c.GetDeploymentName() + c = nil + c.GetDeploymentName() +} + +func TestCreateArtifactDeploymentRequest_GetDigest(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{Digest: &zeroValue} + c.GetDigest() + c = &CreateArtifactDeploymentRequest{} + c.GetDigest() + c = nil + c.GetDigest() +} + +func TestCreateArtifactDeploymentRequest_GetGithubRepository(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{GithubRepository: &zeroValue} + c.GetGithubRepository() + c = &CreateArtifactDeploymentRequest{} + c.GetGithubRepository() + c = nil + c.GetGithubRepository() +} + +func TestCreateArtifactDeploymentRequest_GetLogicalEnvironment(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{LogicalEnvironment: &zeroValue} + c.GetLogicalEnvironment() + c = &CreateArtifactDeploymentRequest{} + c.GetLogicalEnvironment() + c = nil + c.GetLogicalEnvironment() +} + +func TestCreateArtifactDeploymentRequest_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{Name: &zeroValue} + c.GetName() + c = &CreateArtifactDeploymentRequest{} + c.GetName() + c = nil + c.GetName() +} + +func TestCreateArtifactDeploymentRequest_GetPhysicalEnvironment(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{PhysicalEnvironment: &zeroValue} + c.GetPhysicalEnvironment() + c = &CreateArtifactDeploymentRequest{} + c.GetPhysicalEnvironment() + c = nil + c.GetPhysicalEnvironment() +} + +func TestCreateArtifactDeploymentRequest_GetStatus(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{Status: &zeroValue} + c.GetStatus() + c = &CreateArtifactDeploymentRequest{} + c.GetStatus() + c = nil + c.GetStatus() +} + +func TestCreateArtifactDeploymentRequest_GetTags(tt *testing.T) { + tt.Parallel() + zeroValue := map[string]string{} + c := &CreateArtifactDeploymentRequest{Tags: zeroValue} + c.GetTags() + c = &CreateArtifactDeploymentRequest{} + c.GetTags() + c = nil + c.GetTags() +} + +func TestCreateArtifactDeploymentRequest_GetVersion(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactDeploymentRequest{Version: &zeroValue} + c.GetVersion() + c = &CreateArtifactDeploymentRequest{} + c.GetVersion() + c = nil + c.GetVersion() +} + +func TestCreateArtifactStorageRequest_GetArtifactURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{ArtifactURL: &zeroValue} + c.GetArtifactURL() + c = &CreateArtifactStorageRequest{} + c.GetArtifactURL() + c = nil + c.GetArtifactURL() +} + +func TestCreateArtifactStorageRequest_GetDigest(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{Digest: &zeroValue} + c.GetDigest() + c = &CreateArtifactStorageRequest{} + c.GetDigest() + c = nil + c.GetDigest() +} + +func TestCreateArtifactStorageRequest_GetGithubRepository(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{GithubRepository: &zeroValue} + c.GetGithubRepository() + c = &CreateArtifactStorageRequest{} + c.GetGithubRepository() + c = nil + c.GetGithubRepository() +} + +func TestCreateArtifactStorageRequest_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{Name: &zeroValue} + c.GetName() + c = &CreateArtifactStorageRequest{} + c.GetName() + c = nil + c.GetName() +} + +func TestCreateArtifactStorageRequest_GetPath(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{Path: &zeroValue} + c.GetPath() + c = &CreateArtifactStorageRequest{} + c.GetPath() + c = nil + c.GetPath() +} + +func TestCreateArtifactStorageRequest_GetRegistryURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{RegistryURL: &zeroValue} + c.GetRegistryURL() + c = &CreateArtifactStorageRequest{} + c.GetRegistryURL() + c = nil + c.GetRegistryURL() +} + +func TestCreateArtifactStorageRequest_GetRepository(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{Repository: &zeroValue} + c.GetRepository() + c = &CreateArtifactStorageRequest{} + c.GetRepository() + c = nil + c.GetRepository() +} + +func TestCreateArtifactStorageRequest_GetStatus(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{Status: &zeroValue} + c.GetStatus() + c = &CreateArtifactStorageRequest{} + c.GetStatus() + c = nil + c.GetStatus() +} + +func TestCreateArtifactStorageRequest_GetVersion(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateArtifactStorageRequest{Version: &zeroValue} + c.GetVersion() + c = &CreateArtifactStorageRequest{} + c.GetVersion() + c = nil + c.GetVersion() +} + func TestCreateCheckRunOptions_GetCompletedAt(tt *testing.T) { tt.Parallel() var zeroValue Timestamp diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index e7c6ed86da5..a543a51f8f1 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -115,6 +115,41 @@ func TestAdvancedSecurity_String(t *testing.T) { } } +func TestArtifactDeploymentRecord_String(t *testing.T) { + t.Parallel() + v := ArtifactDeploymentRecord{ + ID: Ptr(int64(0)), + Digest: Ptr(""), + Name: Ptr(""), + Version: Ptr(""), + Status: Ptr(""), + LogicalEnvironment: Ptr(""), + PhysicalEnvironment: Ptr(""), + Cluster: Ptr(""), + DeploymentName: Ptr(""), + RuntimeRisks: []string{""}, + GithubRepository: Ptr(""), + AttestationID: Ptr(int64(0)), + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + } + want := `github.ArtifactDeploymentRecord{ID:0, Digest:"", Name:"", Version:"", Status:"", LogicalEnvironment:"", PhysicalEnvironment:"", Cluster:"", DeploymentName:"", RuntimeRisks:[""], GithubRepository:"", AttestationID:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}` + if got := v.String(); got != want { + t.Errorf("ArtifactDeploymentRecord.String = %v, want %v", got, want) + } +} + +func TestArtifactDeploymentResponse_String(t *testing.T) { + t.Parallel() + v := ArtifactDeploymentResponse{ + TotalCount: Ptr(0), + } + want := `github.ArtifactDeploymentResponse{TotalCount:0}` + if got := v.String(); got != want { + t.Errorf("ArtifactDeploymentResponse.String = %v, want %v", got, want) + } +} + func TestArtifactPeriod_String(t *testing.T) { t.Parallel() v := ArtifactPeriod{ @@ -127,6 +162,39 @@ func TestArtifactPeriod_String(t *testing.T) { } } +func TestArtifactStorageRecord_String(t *testing.T) { + t.Parallel() + v := ArtifactStorageRecord{ + ID: Ptr(int64(0)), + Name: Ptr(""), + Digest: Ptr(""), + Version: Ptr(""), + ArtifactURL: Ptr(""), + Path: Ptr(""), + RegistryURL: Ptr(""), + Repository: Ptr(""), + Status: Ptr(""), + GithubRepository: Ptr(""), + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + } + want := `github.ArtifactStorageRecord{ID:0, Name:"", Digest:"", Version:"", ArtifactURL:"", Path:"", RegistryURL:"", Repository:"", Status:"", GithubRepository:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}` + if got := v.String(); got != want { + t.Errorf("ArtifactStorageRecord.String = %v, want %v", got, want) + } +} + +func TestArtifactStorageResponse_String(t *testing.T) { + t.Parallel() + v := ArtifactStorageResponse{ + TotalCount: Ptr(0), + } + want := `github.ArtifactStorageResponse{TotalCount:0}` + if got := v.String(); got != want { + t.Errorf("ArtifactStorageResponse.String = %v, want %v", got, want) + } +} + func TestAssignmentGrade_String(t *testing.T) { t.Parallel() v := AssignmentGrade{ @@ -326,6 +394,18 @@ func TestClassroomUser_String(t *testing.T) { } } +func TestClusterDeploymentRecordsRequest_String(t *testing.T) { + t.Parallel() + v := ClusterDeploymentRecordsRequest{ + LogicalEnvironment: Ptr(""), + PhysicalEnvironment: Ptr(""), + } + want := `github.ClusterDeploymentRecordsRequest{LogicalEnvironment:"", PhysicalEnvironment:""}` + if got := v.String(); got != want { + t.Errorf("ClusterDeploymentRecordsRequest.String = %v, want %v", got, want) + } +} + func TestCodeOfConduct_String(t *testing.T) { t.Parallel() v := CodeOfConduct{ @@ -497,6 +577,45 @@ func TestContributorStats_String(t *testing.T) { } } +func TestCreateArtifactDeploymentRequest_String(t *testing.T) { + t.Parallel() + v := CreateArtifactDeploymentRequest{ + Digest: Ptr(""), + Name: Ptr(""), + Version: Ptr(""), + Status: Ptr(""), + LogicalEnvironment: Ptr(""), + PhysicalEnvironment: Ptr(""), + Cluster: Ptr(""), + DeploymentName: Ptr(""), + RuntimeRisks: []string{""}, + GithubRepository: Ptr(""), + } + want := `github.CreateArtifactDeploymentRequest{Digest:"", Name:"", Version:"", Status:"", LogicalEnvironment:"", PhysicalEnvironment:"", Cluster:"", DeploymentName:"", RuntimeRisks:[""], GithubRepository:""}` + if got := v.String(); got != want { + t.Errorf("CreateArtifactDeploymentRequest.String = %v, want %v", got, want) + } +} + +func TestCreateArtifactStorageRequest_String(t *testing.T) { + t.Parallel() + v := CreateArtifactStorageRequest{ + Name: Ptr(""), + Digest: Ptr(""), + Version: Ptr(""), + ArtifactURL: Ptr(""), + Path: Ptr(""), + RegistryURL: Ptr(""), + Repository: Ptr(""), + Status: Ptr(""), + GithubRepository: Ptr(""), + } + want := `github.CreateArtifactStorageRequest{Name:"", Digest:"", Version:"", ArtifactURL:"", Path:"", RegistryURL:"", Repository:"", Status:"", GithubRepository:""}` + if got := v.String(); got != want { + t.Errorf("CreateArtifactStorageRequest.String = %v, want %v", got, want) + } +} + func TestDependabotSecurityUpdates_String(t *testing.T) { t.Parallel() v := DependabotSecurityUpdates{ diff --git a/github/orgs_artifacts.go b/github/orgs_artifacts.go new file mode 100644 index 00000000000..d7ba0e93e2e --- /dev/null +++ b/github/orgs_artifacts.go @@ -0,0 +1,191 @@ +// 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" +) + +// ArtifactDeploymentRecord represents a GitHub artifact deployment record. +type ArtifactDeploymentRecord struct { + ID *int64 `json:"id,omitempty"` + Digest *string `json:"digest,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` + Status *string `json:"status,omitempty"` + LogicalEnvironment *string `json:"logical_environment,omitempty"` + PhysicalEnvironment *string `json:"physical_environment,omitempty"` + Cluster *string `json:"cluster,omitempty"` + DeploymentName *string `json:"deployment_name,omitempty"` + Tags map[string]string `json:"tags,omitempty"` + RuntimeRisks []string `json:"runtime_risks,omitempty"` + GithubRepository *string `json:"github_repository,omitempty"` + AttestationID *int64 `json:"attestation_id,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` +} + +func (r ArtifactDeploymentRecord) String() string { return Stringify(r) } + +// CreateArtifactDeploymentRequest represents the request body for creating a deployment record. +type CreateArtifactDeploymentRequest struct { + Digest *string `json:"digest,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` + Status *string `json:"status,omitempty"` + LogicalEnvironment *string `json:"logical_environment,omitempty"` + PhysicalEnvironment *string `json:"physical_environment,omitempty"` + Cluster *string `json:"cluster,omitempty"` + DeploymentName *string `json:"deployment_name,omitempty"` + Tags map[string]string `json:"tags,omitempty"` + RuntimeRisks []string `json:"runtime_risks,omitempty"` + GithubRepository *string `json:"github_repository,omitempty"` +} + +func (r CreateArtifactDeploymentRequest) String() string { return Stringify(r) } + +// ArtifactDeploymentResponse represents the response for deployment records. +type ArtifactDeploymentResponse struct { + TotalCount *int `json:"total_count,omitempty"` + DeploymentRecords []*ArtifactDeploymentRecord `json:"deployment_records,omitempty"` +} + +func (r ArtifactDeploymentResponse) String() string { return Stringify(r) } + +// ClusterDeploymentRecordsRequest represents the request body for setting cluster deployment records. +type ClusterDeploymentRecordsRequest struct { + LogicalEnvironment *string `json:"logical_environment,omitempty"` + PhysicalEnvironment *string `json:"physical_environment,omitempty"` + Deployments []*CreateArtifactDeploymentRequest `json:"deployments,omitempty"` +} + +func (r ClusterDeploymentRecordsRequest) String() string { return Stringify(r) } + +// ArtifactStorageRecord represents a GitHub artifact storage record. +type ArtifactStorageRecord struct { + ID *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Digest *string `json:"digest,omitempty"` + Version *string `json:"version,omitempty"` + ArtifactURL *string `json:"artifact_url,omitempty"` + Path *string `json:"path,omitempty"` + RegistryURL *string `json:"registry_url,omitempty"` + Repository *string `json:"repository,omitempty"` + Status *string `json:"status,omitempty"` + GithubRepository *string `json:"github_repository,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` +} + +func (r ArtifactStorageRecord) String() string { return Stringify(r) } + +// CreateArtifactStorageRequest represents the request body for creating a storage record. +type CreateArtifactStorageRequest struct { + Name *string `json:"name,omitempty"` + Digest *string `json:"digest,omitempty"` + Version *string `json:"version,omitempty"` + ArtifactURL *string `json:"artifact_url,omitempty"` + Path *string `json:"path,omitempty"` + RegistryURL *string `json:"registry_url,omitempty"` + Repository *string `json:"repository,omitempty"` + Status *string `json:"status,omitempty"` + GithubRepository *string `json:"github_repository,omitempty"` +} + +func (r CreateArtifactStorageRequest) String() string { return Stringify(r) } + +// ArtifactStorageResponse represents the response for storage records. +type ArtifactStorageResponse struct { + TotalCount *int `json:"total_count,omitempty"` + StorageRecords []*ArtifactStorageRecord `json:"storage_records,omitempty"` +} + +func (r ArtifactStorageResponse) String() string { return Stringify(r) } + +// CreateArtifactDeploymentRecord creates an artifact deployment record for an organization. +// +// GitHub API docs: https://docs.github.com/rest/orgs/artifact-metadata#create-an-artifact-deployment-record +// +//meta:operation POST /orgs/{org}/artifacts/metadata/deployment-record +func (s *OrganizationsService) CreateArtifactDeploymentRecord(ctx context.Context, org string, record *CreateArtifactDeploymentRequest) (*ArtifactDeploymentResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/artifacts/metadata/deployment-record", org) + req, err := s.client.NewRequest("POST", u, record) + if err != nil { + return nil, nil, err + } + v := new(ArtifactDeploymentResponse) + resp, err := s.client.Do(ctx, req, v) + return v, resp, err +} + +// SetClusterDeploymentRecords sets deployment records for a given cluster. +// +// GitHub API docs: https://docs.github.com/rest/orgs/artifact-metadata#set-cluster-deployment-records +// +//meta:operation POST /orgs/{org}/artifacts/metadata/deployment-record/cluster/{cluster} +func (s *OrganizationsService) SetClusterDeploymentRecords(ctx context.Context, org, cluster string, request *ClusterDeploymentRecordsRequest) (*ArtifactDeploymentResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/artifacts/metadata/deployment-record/cluster/%v", org, cluster) + req, err := s.client.NewRequest("POST", u, request) + if err != nil { + return nil, nil, err + } + v := new(ArtifactDeploymentResponse) + resp, err := s.client.Do(ctx, req, v) + return v, resp, err +} + +// CreateArtifactStorageRecord creates metadata storage records for artifacts. +// +// GitHub API docs: https://docs.github.com/rest/orgs/artifact-metadata#create-artifact-metadata-storage-record +// +//meta:operation POST /orgs/{org}/artifacts/metadata/storage-record +func (s *OrganizationsService) CreateArtifactStorageRecord(ctx context.Context, org string, record *CreateArtifactStorageRequest) (*ArtifactStorageResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/artifacts/metadata/storage-record", org) + req, err := s.client.NewRequest("POST", u, record) + if err != nil { + return nil, nil, err + } + v := new(ArtifactStorageResponse) + resp, err := s.client.Do(ctx, req, v) + return v, resp, err +} + +// ListArtifactDeploymentRecords lists deployment records for an artifact metadata. +// +// GitHub API docs: https://docs.github.com/rest/orgs/artifact-metadata#list-artifact-deployment-records +// +//meta:operation GET /orgs/{org}/artifacts/{subject_digest}/metadata/deployment-records +func (s *OrganizationsService) ListArtifactDeploymentRecords(ctx context.Context, org, subjectDigest string) (*ArtifactDeploymentResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/artifacts/%v/metadata/deployment-records", org, subjectDigest) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + v := new(ArtifactDeploymentResponse) + resp, err := s.client.Do(ctx, req, v) + return v, resp, err +} + +// ListArtifactStorageRecords lists artifact storage records with a given subject digest. +// +// GitHub API docs: https://docs.github.com/rest/orgs/artifact-metadata#list-artifact-storage-records +// +//meta:operation GET /orgs/{org}/artifacts/{subject_digest}/metadata/storage-records +func (s *OrganizationsService) ListArtifactStorageRecords(ctx context.Context, org, subjectDigest string) (*ArtifactStorageResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/artifacts/%v/metadata/storage-records", org, subjectDigest) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + v := new(ArtifactStorageResponse) + resp, err := s.client.Do(ctx, req, v) + return v, resp, err +} diff --git a/github/orgs_artifacts_test.go b/github/orgs_artifacts_test.go new file mode 100644 index 00000000000..468931b02dd --- /dev/null +++ b/github/orgs_artifacts_test.go @@ -0,0 +1,188 @@ +// 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_CreateArtifactDeploymentRecord(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + input := &CreateArtifactDeploymentRequest{ + Name: Ptr("test-n"), + Digest: Ptr("sha256:123"), + Version: Ptr("v1.0.0"), + Status: Ptr("deployed"), + LogicalEnvironment: Ptr("prod"), + DeploymentName: Ptr("dep-1"), + RuntimeRisks: []string{"critical-resource", "internet-exposed"}, + GithubRepository: Ptr("octo-org/octo-repo"), + Tags: map[string]string{ + "data-access": "sensitive", + }, + } + + _ = input.String() + + mux.HandleFunc("/orgs/o/artifacts/metadata/deployment-record", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "POST") + testJSONMarshal(t, input, `{"digest":"sha256:123","name":"test-n","version":"v1.0.0","status":"deployed","logical_environment":"prod","deployment_name":"dep-1","tags":{"data-access":"sensitive"},"runtime_risks":["critical-resource","internet-exposed"],"github_repository":"octo-org/octo-repo"}`) + fmt.Fprint(w, `{"total_count":1,"deployment_records":[{"id":1}]}`) + }) + + ctx := t.Context() + got, _, err := client.Organizations.CreateArtifactDeploymentRecord(ctx, "o", input) + if err != nil { + t.Errorf("CreateArtifactDeploymentRecord returned error: %v", err) + } + + want := &ArtifactDeploymentResponse{ + TotalCount: Ptr(1), + DeploymentRecords: []*ArtifactDeploymentRecord{{ID: Ptr(int64(1))}}, + } + + _ = want.String() + _ = want.DeploymentRecords[0].String() + + if !cmp.Equal(got, want) { + t.Errorf("CreateArtifactDeploymentRecord returned %+v, want %+v", got, want) + } +} + +func TestOrganizationsService_SetClusterDeploymentRecords(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + input := &ClusterDeploymentRecordsRequest{ + LogicalEnvironment: Ptr("prod"), + PhysicalEnvironment: Ptr("pacific-east"), + Deployments: []*CreateArtifactDeploymentRequest{ + { + Name: Ptr("awesome-image"), + Version: Ptr("v2.0"), + Status: Ptr("deployed"), + }, + }, + } + + _ = input.String() + + mux.HandleFunc("/orgs/o/artifacts/metadata/deployment-record/cluster/c1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "POST") + testJSONMarshal(t, input, `{"logical_environment":"prod","physical_environment":"pacific-east","deployments":[{"name":"awesome-image","version":"v2.0","status":"deployed"}]}`) + fmt.Fprint(w, `{"total_count":1,"deployment_records":[{"id":2}]}`) + }) + + ctx := t.Context() + got, _, err := client.Organizations.SetClusterDeploymentRecords(ctx, "o", "c1", input) + if err != nil { + t.Errorf("SetClusterDeploymentRecords returned error: %v", err) + } + + want := &ArtifactDeploymentResponse{ + TotalCount: Ptr(1), + DeploymentRecords: []*ArtifactDeploymentRecord{{ID: Ptr(int64(2))}}, + } + if !cmp.Equal(got, want) { + t.Errorf("SetClusterDeploymentRecords returned %+v, want %+v", got, want) + } +} + +func TestOrganizationsService_CreateArtifactStorageRecord(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + input := &CreateArtifactStorageRequest{ + Name: Ptr("libfoo"), + Version: Ptr("v1.2.3"), + Path: Ptr("target/libs"), + GithubRepository: Ptr("org/repo"), + RegistryURL: Ptr("https://reg.example.com"), + Status: Ptr("active"), + } + + _ = input.String() + + mux.HandleFunc("/orgs/o/artifacts/metadata/storage-record", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "POST") + testJSONMarshal(t, input, `{"name":"libfoo","version":"v1.2.3","path":"target/libs","registry_url":"https://reg.example.com","status":"active","github_repository":"org/repo"}`) + fmt.Fprint(w, `{"total_count":1,"storage_records":[{"name":"libfoo"}]}`) + }) + + ctx := t.Context() + got, _, err := client.Organizations.CreateArtifactStorageRecord(ctx, "o", input) + if err != nil { + t.Errorf("CreateArtifactStorageRecord returned error: %v", err) + } + + want := &ArtifactStorageResponse{ + TotalCount: Ptr(1), + StorageRecords: []*ArtifactStorageRecord{{Name: Ptr("libfoo")}}, + } + + _ = want.String() + _ = want.StorageRecords[0].String() + + if !cmp.Equal(got, want) { + t.Errorf("CreateArtifactStorageRecord returned %+v, want %+v", got, want) + } +} + +func TestOrganizationsService_ListArtifactDeploymentRecords(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/artifacts/sha256:abc/metadata/deployment-records", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{"total_count":1,"deployment_records":[{"id":1, "runtime_risks": ["sensitive-data"]}]}`) + }) + + ctx := t.Context() + got, _, err := client.Organizations.ListArtifactDeploymentRecords(ctx, "o", "sha256:abc") + if err != nil { + t.Errorf("ListArtifactDeploymentRecords returned error: %v", err) + } + + want := &ArtifactDeploymentResponse{ + TotalCount: Ptr(1), + DeploymentRecords: []*ArtifactDeploymentRecord{ + {ID: Ptr(int64(1)), RuntimeRisks: []string{"sensitive-data"}}, + }, + } + if !cmp.Equal(got, want) { + t.Errorf("ListArtifactDeploymentRecords returned %+v, want %+v", got, want) + } +} + +func TestOrganizationsService_ListArtifactStorageRecords(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/artifacts/sha256:abc/metadata/storage-records", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{"total_count":1,"storage_records":[{"name":"libfoo"}]}`) + }) + + ctx := t.Context() + got, _, err := client.Organizations.ListArtifactStorageRecords(ctx, "o", "sha256:abc") + if err != nil { + t.Errorf("ListArtifactStorageRecords returned error: %v", err) + } + + want := &ArtifactStorageResponse{ + TotalCount: Ptr(1), + StorageRecords: []*ArtifactStorageRecord{{Name: Ptr("libfoo")}}, + } + if !cmp.Equal(got, want) { + t.Errorf("ListArtifactStorageRecords returned %+v, want %+v", got, want) + } +}