Skip to content

Commit

Permalink
events
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuskimmina committed Oct 5, 2023
1 parent de63d9f commit be777c9
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
7 changes: 7 additions & 0 deletions providers/atlassian/resources/atlassian.lr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ atlassian.admin.organization @defaults("id") {
policies() []atlassian.admin.organization.policy
// Domains
domains() []atlassian.admin.organization.domain
// Events
events() []atlassian.admin.organization.event
}

atlassian.admin.organization.policy @defaults("id") {
Expand All @@ -36,6 +38,11 @@ atlassian.admin.organization.domain @defaults("id") {
id string
}

atlassian.admin.organization.event @defaults("id") {
// Event ID
id string
}

atlassian.admin.organization.user {
// Account ID
id string
Expand Down
83 changes: 83 additions & 0 deletions providers/atlassian/resources/atlassian.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions providers/atlassian/resources/atlassian.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ resources:
atlassian.admin.organization:
fields:
domains: {}
events: {}
id: {}
policies: {}
type: {}
Expand All @@ -24,6 +25,10 @@ resources:
fields:
id: {}
min_mondoo_version: latest
atlassian.admin.organization.event:
fields:
id: {}
min_mondoo_version: latest
atlassian.admin.organization.policy:
fields:
id: {}
Expand Down
25 changes: 25 additions & 0 deletions providers/atlassian/resources/atlassian_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,28 @@ func (a *mqlAtlassianAdminOrganization) domains() ([]interface{}, error) {
}
return res, nil
}

func (a *mqlAtlassianAdminOrganization) events() ([]interface{}, error) {
conn := a.MqlRuntime.Connection.(*connection.AtlassianConnection)
admin := conn.Admin()
orgId := a.Id.Data
events, response, err := admin.Organization.Events(context.Background(), orgId, nil, "")
if err != nil {
log.Fatal().Err(err)
}
if response.Status != "200 OK" {
log.Fatal().Msgf("Received response: %s\n", response.Status)
}
res := []interface{}{}
for _, event := range events.Data {
mqlAtlassianAdminDomain, err := CreateResource(a.MqlRuntime, "atlassian.admin.organization.event",
map[string]*llx.RawData{
"id": llx.StringData(event.ID),
})
if err != nil {
log.Fatal().Err(err)
}
res = append(res, mqlAtlassianAdminDomain)
}
return res, nil
}

0 comments on commit be777c9

Please sign in to comment.