github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/pkg/model/system_auth.go (about)

     1  package model
     2  
     3  import (
     4  	"github.com/kyma-incubator/compass/components/director/internal/model"
     5  	"github.com/kyma-incubator/compass/components/director/pkg/apperrors"
     6  )
     7  
     8  // SystemAuth missing godoc
     9  type SystemAuth struct {
    10  	ID                  string
    11  	TenantID            *string
    12  	AppID               *string
    13  	RuntimeID           *string
    14  	IntegrationSystemID *string
    15  	Value               *model.Auth
    16  }
    17  
    18  // GetReferenceObjectType missing godoc
    19  func (sa SystemAuth) GetReferenceObjectType() (SystemAuthReferenceObjectType, error) {
    20  	if sa.AppID != nil {
    21  		return ApplicationReference, nil
    22  	}
    23  
    24  	if sa.RuntimeID != nil {
    25  		return RuntimeReference, nil
    26  	}
    27  
    28  	if sa.IntegrationSystemID != nil {
    29  		return IntegrationSystemReference, nil
    30  	}
    31  
    32  	return "", apperrors.NewInternalError("unknown reference object type")
    33  }
    34  
    35  // GetReferenceObjectID missing godoc
    36  func (sa SystemAuth) GetReferenceObjectID() (string, error) {
    37  	if sa.AppID != nil {
    38  		return *sa.AppID, nil
    39  	}
    40  
    41  	if sa.RuntimeID != nil {
    42  		return *sa.RuntimeID, nil
    43  	}
    44  
    45  	if sa.IntegrationSystemID != nil {
    46  		return *sa.IntegrationSystemID, nil
    47  	}
    48  
    49  	return "", apperrors.NewInternalError("unknown reference object ID")
    50  }
    51  
    52  // SystemAuthReferenceObjectType missing godoc
    53  type SystemAuthReferenceObjectType string
    54  
    55  const (
    56  	// RuntimeReference missing godoc
    57  	RuntimeReference SystemAuthReferenceObjectType = "Runtime"
    58  	// ExternalCertificateReference missing godoc
    59  	ExternalCertificateReference SystemAuthReferenceObjectType = "External Certificate"
    60  	// ApplicationReference missing godoc
    61  	ApplicationReference SystemAuthReferenceObjectType = "Application"
    62  	// IntegrationSystemReference missing godoc
    63  	IntegrationSystemReference SystemAuthReferenceObjectType = "Integration System"
    64  	// SuperAdminReference missing godoc
    65  	SuperAdminReference SystemAuthReferenceObjectType = "Super Admin"
    66  	// TechnicalClientReference missing godoc
    67  	TechnicalClientReference SystemAuthReferenceObjectType = "Technical Client"
    68  	// BusinessIntegrationReference missing godoc
    69  	BusinessIntegrationReference SystemAuthReferenceObjectType = "Business Integration"
    70  	// ManagedApplicationProviderOperatorReference missing godoc
    71  	ManagedApplicationProviderOperatorReference SystemAuthReferenceObjectType = "Managed Application Provider Operator"
    72  	// ManagedApplicationConsumerReference is a reference to the managed application consumer type
    73  	ManagedApplicationConsumerReference SystemAuthReferenceObjectType = "Managed Application Consumer"
    74  	// LandscapeResourceOperatorConsumerReference is a reference to the landscape resource operator consumer type
    75  	LandscapeResourceOperatorConsumerReference SystemAuthReferenceObjectType = "Landscape Resource Operator”"
    76  )
    77  
    78  // IsIntegrationSystemNoTenantFlow missing godoc
    79  func IsIntegrationSystemNoTenantFlow(err error, objectType SystemAuthReferenceObjectType) bool {
    80  	return apperrors.IsTenantRequired(err) && objectType == IntegrationSystemReference
    81  }