@@ -8531,3 +8531,212 @@ func GetArtifactAIModel(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydr
85318531}
85328532
85338533// ========================== END: ArtifactAIModel =============================
8534+
8535+ // ========================== START: OrganizationRole =============================
8536+
8537+ type OrganizationRole struct {
8538+ ResourceID string `json:"resource_id"`
8539+ PlatformID string `json:"platform_id"`
8540+ Description github.OrganizationRoleDescription `json:"Description"`
8541+ Metadata github.Metadata `json:"metadata"`
8542+ DescribedBy string `json:"described_by"`
8543+ ResourceType string `json:"resource_type"`
8544+ IntegrationType string `json:"integration_type"`
8545+ IntegrationID string `json:"integration_id"`
8546+ }
8547+
8548+ type OrganizationRoleHit struct {
8549+ ID string `json:"_id"`
8550+ Score float64 `json:"_score"`
8551+ Index string `json:"_index"`
8552+ Type string `json:"_type"`
8553+ Version int64 `json:"_version,omitempty"`
8554+ Source OrganizationRole `json:"_source"`
8555+ Sort []interface {} `json:"sort"`
8556+ }
8557+
8558+ type OrganizationRoleHits struct {
8559+ Total essdk.SearchTotal `json:"total"`
8560+ Hits []OrganizationRoleHit `json:"hits"`
8561+ }
8562+
8563+ type OrganizationRoleSearchResponse struct {
8564+ PitID string `json:"pit_id"`
8565+ Hits OrganizationRoleHits `json:"hits"`
8566+ }
8567+
8568+ type OrganizationRolePaginator struct {
8569+ paginator * essdk.BaseESPaginator
8570+ }
8571+
8572+ func (k Client ) NewOrganizationRolePaginator (filters []essdk.BoolFilter , limit * int64 ) (OrganizationRolePaginator , error ) {
8573+ paginator , err := essdk .NewPaginator (k .ES (), "github_organization_role" , filters , limit )
8574+ if err != nil {
8575+ return OrganizationRolePaginator {}, err
8576+ }
8577+
8578+ p := OrganizationRolePaginator {
8579+ paginator : paginator ,
8580+ }
8581+
8582+ return p , nil
8583+ }
8584+
8585+ func (p OrganizationRolePaginator ) HasNext () bool {
8586+ return ! p .paginator .Done ()
8587+ }
8588+
8589+ func (p OrganizationRolePaginator ) Close (ctx context.Context ) error {
8590+ return p .paginator .Deallocate (ctx )
8591+ }
8592+
8593+ func (p OrganizationRolePaginator ) NextPage (ctx context.Context ) ([]OrganizationRole , error ) {
8594+ var response OrganizationRoleSearchResponse
8595+ err := p .paginator .Search (ctx , & response )
8596+ if err != nil {
8597+ return nil , err
8598+ }
8599+
8600+ var values []OrganizationRole
8601+ for _ , hit := range response .Hits .Hits {
8602+ values = append (values , hit .Source )
8603+ }
8604+
8605+ hits := int64 (len (response .Hits .Hits ))
8606+ if hits > 0 {
8607+ p .paginator .UpdateState (hits , response .Hits .Hits [hits - 1 ].Sort , response .PitID )
8608+ } else {
8609+ p .paginator .UpdateState (hits , nil , "" )
8610+ }
8611+
8612+ return values , nil
8613+ }
8614+
8615+ var listOrganizationRoleFilters = map [string ]string {
8616+ "has_two_factor_enabled" : "Description.HasTwoFactorEnabled" ,
8617+ "login_id" : "Description.LoginID" ,
8618+ "organization" : "Description.Organization" ,
8619+ "role" : "Description.Role" ,
8620+ }
8621+
8622+ func ListOrganizationRole (ctx context.Context , d * plugin.QueryData , _ * plugin.HydrateData ) (interface {}, error ) {
8623+ plugin .Logger (ctx ).Trace ("ListOrganizationRole" )
8624+ runtime .GC ()
8625+
8626+ // create service
8627+ cfg := essdk .GetConfig (d .Connection )
8628+ ke , err := essdk .NewClientCached (cfg , d .ConnectionCache , ctx )
8629+ if err != nil {
8630+ plugin .Logger (ctx ).Error ("ListOrganizationRole NewClientCached" , "error" , err )
8631+ return nil , err
8632+ }
8633+ k := Client {Client : ke }
8634+
8635+ sc , err := steampipesdk .NewSelfClientCached (ctx , d .ConnectionCache )
8636+ if err != nil {
8637+ plugin .Logger (ctx ).Error ("ListOrganizationRole NewSelfClientCached" , "error" , err )
8638+ return nil , err
8639+ }
8640+ integrationId , err := sc .GetConfigTableValueOrNil (ctx , steampipesdk .OpenGovernanceConfigKeyIntegrationID )
8641+ if err != nil {
8642+ plugin .Logger (ctx ).Error ("ListOrganizationRole GetConfigTableValueOrNil for OpenGovernanceConfigKeyIntegrationID" , "error" , err )
8643+ return nil , err
8644+ }
8645+ encodedResourceCollectionFilters , err := sc .GetConfigTableValueOrNil (ctx , steampipesdk .OpenGovernanceConfigKeyResourceCollectionFilters )
8646+ if err != nil {
8647+ plugin .Logger (ctx ).Error ("ListOrganizationRole GetConfigTableValueOrNil for OpenGovernanceConfigKeyResourceCollectionFilters" , "error" , err )
8648+ return nil , err
8649+ }
8650+ clientType , err := sc .GetConfigTableValueOrNil (ctx , steampipesdk .OpenGovernanceConfigKeyClientType )
8651+ if err != nil {
8652+ plugin .Logger (ctx ).Error ("ListOrganizationRole GetConfigTableValueOrNil for OpenGovernanceConfigKeyClientType" , "error" , err )
8653+ return nil , err
8654+ }
8655+
8656+ paginator , err := k .NewOrganizationRolePaginator (essdk .BuildFilter (ctx , d .QueryContext , listOrganizationRoleFilters , integrationId , encodedResourceCollectionFilters , clientType ), d .QueryContext .Limit )
8657+ if err != nil {
8658+ plugin .Logger (ctx ).Error ("ListOrganizationRole NewOrganizationRolePaginator" , "error" , err )
8659+ return nil , err
8660+ }
8661+
8662+ for paginator .HasNext () {
8663+ page , err := paginator .NextPage (ctx )
8664+ if err != nil {
8665+ plugin .Logger (ctx ).Error ("ListOrganizationRole paginator.NextPage" , "error" , err )
8666+ return nil , err
8667+ }
8668+
8669+ for _ , v := range page {
8670+ d .StreamListItem (ctx , v )
8671+ }
8672+ }
8673+
8674+ err = paginator .Close (ctx )
8675+ if err != nil {
8676+ return nil , err
8677+ }
8678+
8679+ return nil , nil
8680+ }
8681+
8682+ var getOrganizationRoleFilters = map [string ]string {
8683+ "has_two_factor_enabled" : "Description.HasTwoFactorEnabled" ,
8684+ "login_id" : "Description.LoginID" ,
8685+ "organization" : "Description.Organization" ,
8686+ "role" : "Description.Role" ,
8687+ }
8688+
8689+ func GetOrganizationRole (ctx context.Context , d * plugin.QueryData , _ * plugin.HydrateData ) (interface {}, error ) {
8690+ plugin .Logger (ctx ).Trace ("GetOrganizationRole" )
8691+ runtime .GC ()
8692+ // create service
8693+ cfg := essdk .GetConfig (d .Connection )
8694+ ke , err := essdk .NewClientCached (cfg , d .ConnectionCache , ctx )
8695+ if err != nil {
8696+ return nil , err
8697+ }
8698+ k := Client {Client : ke }
8699+
8700+ sc , err := steampipesdk .NewSelfClientCached (ctx , d .ConnectionCache )
8701+ if err != nil {
8702+ return nil , err
8703+ }
8704+ integrationId , err := sc .GetConfigTableValueOrNil (ctx , steampipesdk .OpenGovernanceConfigKeyIntegrationID )
8705+ if err != nil {
8706+ return nil , err
8707+ }
8708+ encodedResourceCollectionFilters , err := sc .GetConfigTableValueOrNil (ctx , steampipesdk .OpenGovernanceConfigKeyResourceCollectionFilters )
8709+ if err != nil {
8710+ return nil , err
8711+ }
8712+ clientType , err := sc .GetConfigTableValueOrNil (ctx , steampipesdk .OpenGovernanceConfigKeyClientType )
8713+ if err != nil {
8714+ return nil , err
8715+ }
8716+
8717+ limit := int64 (1 )
8718+ paginator , err := k .NewOrganizationRolePaginator (essdk .BuildFilter (ctx , d .QueryContext , getOrganizationRoleFilters , integrationId , encodedResourceCollectionFilters , clientType ), & limit )
8719+ if err != nil {
8720+ return nil , err
8721+ }
8722+
8723+ for paginator .HasNext () {
8724+ page , err := paginator .NextPage (ctx )
8725+ if err != nil {
8726+ return nil , err
8727+ }
8728+
8729+ for _ , v := range page {
8730+ return v , nil
8731+ }
8732+ }
8733+
8734+ err = paginator .Close (ctx )
8735+ if err != nil {
8736+ return nil , err
8737+ }
8738+
8739+ return nil , nil
8740+ }
8741+
8742+ // ========================== END: OrganizationRole =============================
0 commit comments