Skip to content

Commit

Permalink
Implement support for CAP guestsOrExternalUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
agileknight committed Oct 23, 2023
1 parent 5e507f0 commit 6e32cd4
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 13 deletions.
80 changes: 67 additions & 13 deletions msgraph/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type AccessPackageCatalog struct {
DisplayName *string `json:"displayName,omitempty"`
IsExternallyVisible *bool `json:"isExternallyVisible,omitempty"`
ModifiedDateTime *time.Time `json:"modifiedDateTime,omitempty"`
//Beta
// Beta
CatalogStatus AccessPackageCatalogStatus `json:"catalogStatus,omitempty"`
CreatedBy *string `json:"createdBy,omitempty"`
ModifiedBy *string `json:"modifiedBy,omitempty"`
Expand Down Expand Up @@ -547,10 +547,10 @@ type AppRoleAssignment struct {
type ApprovalSettings struct {
IsApprovalRequiredForAdd *bool `json:"isApprovalRequiredForAdd,omitempty"`
IsApprovalRequiredForUpdate *bool `json:"isApprovalRequiredForUpdate,omitempty"`
IsApprovalRequired *bool `json:"isApprovalRequired,omitempty"` //beta property
IsApprovalRequiredForExtension *bool `json:"isApprovalRequiredForExtension,omitempty"` //beta property
IsRequestorJustificationRequired *bool `json:"isRequestorJustificationRequired,omitempty"` //beta property
ApprovalMode ApprovalMode `json:"approvalMode,omitempty"` //beta property
IsApprovalRequired *bool `json:"isApprovalRequired,omitempty"` // beta property
IsApprovalRequiredForExtension *bool `json:"isApprovalRequiredForExtension,omitempty"` // beta property
IsRequestorJustificationRequired *bool `json:"isRequestorJustificationRequired,omitempty"` // beta property
ApprovalMode ApprovalMode `json:"approvalMode,omitempty"` // beta property
ApprovalStages *[]ApprovalStage `json:"approvalStages,omitempty"`
}

Expand Down Expand Up @@ -693,12 +693,66 @@ type ConditionalAccessSessionControls struct {
}

type ConditionalAccessUsers struct {
IncludeUsers *[]string `json:"includeUsers,omitempty"`
ExcludeUsers *[]string `json:"excludeUsers,omitempty"`
IncludeGroups *[]string `json:"includeGroups,omitempty"`
ExcludeGroups *[]string `json:"excludeGroups,omitempty"`
IncludeRoles *[]string `json:"includeRoles,omitempty"`
ExcludeRoles *[]string `json:"excludeRoles,omitempty"`
IncludeUsers *[]string `json:"includeUsers,omitempty"`
ExcludeUsers *[]string `json:"excludeUsers,omitempty"`
IncludeGroups *[]string `json:"includeGroups,omitempty"`
ExcludeGroups *[]string `json:"excludeGroups,omitempty"`
IncludeRoles *[]string `json:"includeRoles,omitempty"`
ExcludeRoles *[]string `json:"excludeRoles,omitempty"`
IncludeGuestsOrExternalUsers *ConditionalAccessGuestsOrExternalUsers `json:"includeGuestsOrExternalUsers,omitempty"`
ExcludeGuestsOrExternalUsers *ConditionalAccessGuestsOrExternalUsers `json:"excludeGuestsOrExternalUsers,omitempty"`
}

type ConditionalAccessGuestsOrExternalUsers struct {
GuestOrExternalUserTypes *[]ConditionalAccessGuestOrExternalUserType `json:"guestOrExternalUserTypes,omitempty"`
ExternalTenants *ConditionalAccessExternalTenants `json:"externalTenants,omitempty"`
}

type ConditionalAccessExternalTenants struct {
MembershipKind *string `json:"membershipKind,omitempty"`
Members *[]string `json:"members,omitempty"`
}

func (c ConditionalAccessGuestsOrExternalUsers) MarshalJSON() ([]byte, error) {
var val *StringNullWhenEmpty
if c.GuestOrExternalUserTypes != nil {
theTypes := StringNullWhenEmpty(strings.Join(*c.GuestOrExternalUserTypes, ","))
val = &theTypes
}

// Local type needed to avoid recursive MarshalJSON calls
type conditionalAccessGuestsOrExternalUsers ConditionalAccessGuestsOrExternalUsers
guestOrExternalUsers := struct {
GuestOrExternalUserTypes *StringNullWhenEmpty `json:"guestOrExternalUserTypes,omitempty"`
*conditionalAccessGuestsOrExternalUsers
}{
GuestOrExternalUserTypes: val,
conditionalAccessGuestsOrExternalUsers: (*conditionalAccessGuestsOrExternalUsers)(&c),
}
buf, err := json.Marshal(&guestOrExternalUsers)
return buf, err
}

func (c *ConditionalAccessGuestsOrExternalUsers) UnmarshalJSON(data []byte) error {
// Local type needed to avoid recursive UnmarshalJSON calls
type conditionalAccessGuestsOrExternalUsers ConditionalAccessGuestsOrExternalUsers
guestOrExternalUsers := struct {
GuestOrExternalUserTypes *string `json:"guestOrExternalUserTypes"`
*conditionalAccessGuestsOrExternalUsers
}{
conditionalAccessGuestsOrExternalUsers: (*conditionalAccessGuestsOrExternalUsers)(c),
}
if err := json.Unmarshal(data, &guestOrExternalUsers); err != nil {
return err
}
if guestOrExternalUsers.GuestOrExternalUserTypes != nil {
var types []string
for _, s := range strings.Split(*guestOrExternalUsers.GuestOrExternalUserTypes, ",") {
types = append(types, strings.TrimSpace(s))
}
c.GuestOrExternalUserTypes = &types
}
return nil
}

type ConnectionInfo struct {
Expand Down Expand Up @@ -1645,7 +1699,7 @@ type TermsOfUseAgreement struct {
UserReacceptRequiredFrequency *string `json:"userReacceptRequiredFrequency,omitempty"`
IsViewingBeforeAcceptanceRequired *bool `json:"isViewingBeforeAcceptanceRequired,omitempty"`
IsPerDeviceAcceptanceRequired *bool `json:"isPerDeviceAcceptanceRequired,omitempty"`
TermsExpiration *TermsOfUseAgreementExpiration `json:"termsExpiration,omitempty"` //For some reason this exports the Frequency both here and above AcceptanceExpirationFrequency Request separates them but response groups them. Anticipate this in Tests
TermsExpiration *TermsOfUseAgreementExpiration `json:"termsExpiration,omitempty"` // For some reason this exports the Frequency both here and above AcceptanceExpirationFrequency Request separates them but response groups them. Anticipate this in Tests
Files *[]TermsOfUseAgreementFile `json:"files,omitempty"`
File *TermsOfUseAgreementFile `json:"file,omitempty"`
}
Expand All @@ -1656,7 +1710,7 @@ type TermsOfUseAgreementExpiration struct {
}

type TermsOfUseAgreementFileData struct {
//Data is within its own object for some reason
// Data is within its own object for some reason
Data *[]byte `json:"data,omitempty"`
}

Expand Down
21 changes: 21 additions & 0 deletions msgraph/valuetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,27 @@ const (
ConditionalAccessRiskLevelUnknownFutureValue ConditionalAccessRiskLevel = "unknownFutureValue"
)

type ConditionalAccessGuestOrExternalUserType = string

const (
ConditionalAccessGuestOrExternalUserTypeNone ConditionalAccessGuestOrExternalUserType = "none"
ConditionalAccessGuestOrExternalUserTypeInternalGuest ConditionalAccessGuestOrExternalUserType = "internalGuest"
ConditionalAccessGuestOrExternalUserTypeB2bCollaborationGuest ConditionalAccessGuestOrExternalUserType = "b2bCollaborationGuest"
ConditionalAccessGuestOrExternalUserTypeB2bCollaborationMember ConditionalAccessGuestOrExternalUserType = "b2bCollaborationMember"
ConditionalAccessGuestOrExternalUserTypeB2bDirectConnectUser ConditionalAccessGuestOrExternalUserType = "b2bDirectConnectUser"
ConditionalAccessGuestOrExternalUserTypeOtherExternalUser ConditionalAccessGuestOrExternalUserType = "otherExternalUser"
ConditionalAccessGuestOrExternalUserTypeServiceProvider ConditionalAccessGuestOrExternalUserType = "serviceProvider"
ConditionalAccessGuestOrExternalUserTypeUnknownFutureValue ConditionalAccessGuestOrExternalUserType = "unknownFutureValue"
)

type ConditionalAccessExternalTenantsMembershipKind = string

const (
ConditionalAccessExternalTenantsMembershipKindAll ConditionalAccessExternalTenantsMembershipKind = "all"
ConditionalAccessExternalTenantsMembershipKindEnumerated ConditionalAccessExternalTenantsMembershipKind = "enumerated"
ConditionalAccessExternalTenantsMembershipKindUnknownFutureValue ConditionalAccessExternalTenantsMembershipKind = "unknownFutureValue"
)

type ConnectedOrganizationState = string

const (
Expand Down

0 comments on commit 6e32cd4

Please sign in to comment.