Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis committed Oct 17, 2024
1 parent 775044b commit c9e440d
Show file tree
Hide file tree
Showing 7 changed files with 839 additions and 357 deletions.
19 changes: 19 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7185,6 +7185,25 @@ message IntegrationV1 {
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "spec"
];

// Status has the current state of the integration.
IntegrationStatusV1 Status = 3 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "status"
];
}

// IntegrationStatusV1 contains the current status for a given integration.
message IntegrationStatusV1 {
// PendingUserTasksNotificationID contains the notification ID that indicates that this integration has unresolved user tasks.
string PendingUserTasksNotificationID = 1 [(gogoproto.jsontag) = "pending_usertasks_notification_id,omitempty"];
// NeedsAttentionNotificationExpires contains the expiration date for the notification.
// Used to ensure new notifications' expiration is the greater between the current notification and the new one.
google.protobuf.Timestamp PendingUserTasksNotificationExpires = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = true,
(gogoproto.jsontag) = "pending_usertasks_notification_expires,omitempty"
];
}

// IntegrationSpecV1 contains properties of all the supported integrations.
Expand Down
6 changes: 6 additions & 0 deletions api/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,12 @@ const (
// NotificationUserCreatedWarningSubKind is the subkind for a user-created warning notification.
NotificationUserCreatedWarningSubKind = "user-created-warning"

// NotificationUserTaskIntegrationSubKind is the subkind for a notification that warns the user about pending User Tasks for a given integration.
NotificationUserTaskIntegrationSubKind = "user-task-integration"
// NotificationIntegrationLabel is the label which contains the name of the integration.
// To be used with NotificationUserTaskIntegrationSubKind.
NotificationIntegrationLabel = "integration-name"

// NotificationAccessRequestPendingSubKind is the subkind for a notification for an access request pending review.
NotificationAccessRequestPendingSubKind = "access-request-pending"
// NotificationAccessRequestApprovedSubKind is the subkind for a notification for a user's access request being approved.
Expand Down
25 changes: 25 additions & 0 deletions api/types/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ type Integration interface {

// GetAzureOIDCIntegrationSpec returns the `azure-oidc` spec fields.
GetAzureOIDCIntegrationSpec() *AzureOIDCIntegrationSpecV1

// GetStatus returns the Integration Status.
GetStatus() IntegrationStatusV1
// SetStatus sets the Integration Status.
SetStatus(IntegrationStatusV1)
}

var _ ResourceWithLabels = (*IntegrationV1)(nil)
Expand Down Expand Up @@ -250,6 +255,22 @@ func (ig *IntegrationV1) GetAzureOIDCIntegrationSpec() *AzureOIDCIntegrationSpec
return ig.Spec.GetAzureOIDC()
}

// GetStatus returns the Integration Status.
func (ig *IntegrationV1) GetStatus() IntegrationStatusV1 {
if ig == nil {
return IntegrationStatusV1{}
}
return ig.Status
}

// SetStatus sets the Integration Status.
func (ig *IntegrationV1) SetStatus(s IntegrationStatusV1) {
if ig == nil {
return
}
ig.Status = s
}

// Integrations is a list of Integration resources.
type Integrations []Integration

Expand Down Expand Up @@ -302,6 +323,7 @@ func (ig *IntegrationV1) UnmarshalJSON(data []byte) error {
AWSOIDC json.RawMessage `json:"aws_oidc"`
AzureOIDC json.RawMessage `json:"azure_oidc"`
} `json:"spec"`
Status IntegrationStatusV1 `json:"status"`
}{}

err := json.Unmarshal(data, &d)
Expand All @@ -310,6 +332,7 @@ func (ig *IntegrationV1) UnmarshalJSON(data []byte) error {
}

integration.ResourceHeader = d.ResourceHeader
integration.Status = d.Status

switch integration.SubKind {
case IntegrationSubKindAWSOIDC:
Expand Down Expand Up @@ -357,9 +380,11 @@ func (ig *IntegrationV1) MarshalJSON() ([]byte, error) {
AWSOIDC AWSOIDCIntegrationSpecV1 `json:"aws_oidc,omitempty"`
AzureOIDC AzureOIDCIntegrationSpecV1 `json:"azure_oidc,omitempty"`
} `json:"spec"`
Status IntegrationStatusV1 `json:"status"`
}{}

d.ResourceHeader = ig.ResourceHeader
d.Status = ig.Status

switch ig.SubKind {
case IntegrationSubKindAWSOIDC:
Expand Down
Loading

0 comments on commit c9e440d

Please sign in to comment.