Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-02 11:33:47 -08:00
parent 3fcf5e437c
commit 7dfa3363c0
17 changed files with 765 additions and 390 deletions

43
pkg/probo/get_control.go Normal file
View File

@@ -0,0 +1,43 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) GetControl(
ctx context.Context,
controlID gid.GID,
) (*coredata.Control, error) {
control := &coredata.Control{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return control.LoadByID(ctx, conn, s.scope, controlID)
},
)
if err != nil {
return nil, err
}
return control, nil
}

43
pkg/probo/get_evidence.go Normal file
View File

@@ -0,0 +1,43 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) GetEvidence(
ctx context.Context,
evidenceID gid.GID,
) (*coredata.Evidence, error) {
evidence := &coredata.Evidence{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return evidence.LoadByID(ctx, conn, s.scope, evidenceID)
},
)
if err != nil {
return nil, err
}
return evidence, nil
}

View File

@@ -0,0 +1,43 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) GetFramework(
ctx context.Context,
frameworkID gid.GID,
) (*coredata.Framework, error) {
framework := &coredata.Framework{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return framework.LoadByID(ctx, conn, s.scope, frameworkID)
},
)
if err != nil {
return nil, err
}
return framework, nil
}

View File

@@ -0,0 +1,48 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) GetOrganization(
ctx context.Context,
organizationID gid.GID,
) (*coredata.Organization, error) {
organization := &coredata.Organization{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return organization.LoadByID(
ctx,
conn,
s.scope,
organizationID,
)
},
)
if err != nil {
return nil, err
}
return organization, nil
}

43
pkg/probo/get_people.go Normal file
View File

@@ -0,0 +1,43 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) GetPeople(
ctx context.Context,
peopleID gid.GID,
) (*coredata.People, error) {
people := &coredata.People{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return people.LoadByID(ctx, conn, s.scope, peopleID)
},
)
if err != nil {
return nil, err
}
return people, nil
}

43
pkg/probo/get_task.go Normal file
View File

@@ -0,0 +1,43 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) GetTask(
ctx context.Context,
taskID gid.GID,
) (*coredata.Task, error) {
task := &coredata.Task{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return task.LoadByID(ctx, conn, s.scope, taskID)
},
)
if err != nil {
return nil, err
}
return task, nil
}

43
pkg/probo/get_vendor.go Normal file
View File

@@ -0,0 +1,43 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) GetVendor(
ctx context.Context,
vendorID gid.GID,
) (*coredata.Vendor, error) {
vendor := &coredata.Vendor{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return vendor.LoadByID(ctx, conn, s.scope, vendorID)
},
)
if err != nil {
return nil, err
}
return vendor, nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListControlStateTransitions(
ctx context.Context,
controlID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.ControlStateTransition], error) {
var controlStateTransitions coredata.ControlStateTransitions
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return controlStateTransitions.LoadByControlID(
ctx,
conn,
s.scope,
controlID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(controlStateTransitions, cursor), nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListControlTasks(
ctx context.Context,
controlID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Task], error) {
var tasks coredata.Tasks
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return tasks.LoadByControlID(
ctx,
conn,
s.scope,
controlID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(tasks, cursor), nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListEvidenceStateTransitions(
ctx context.Context,
evidenceID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.EvidenceStateTransition], error) {
var evidenceStateTransitions coredata.EvidenceStateTransitions
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return evidenceStateTransitions.LoadByEvidenceID(
ctx,
conn,
s.scope,
evidenceID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(evidenceStateTransitions, cursor), nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListFrameworkControls(
ctx context.Context,
frameworkID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Control], error) {
var controls coredata.Controls
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return controls.LoadByFrameworkID(
ctx,
conn,
s.scope,
frameworkID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(controls, cursor), nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListOrganizationFrameworks(
ctx context.Context,
organizationID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Framework], error) {
var frameworks coredata.Frameworks
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return frameworks.LoadByOrganizationID(
ctx,
conn,
s.scope,
organizationID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(frameworks, cursor), nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListOrganizationPeoples(
ctx context.Context,
organizationID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.People], error) {
var peoples coredata.Peoples
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return peoples.LoadByOrganizationID(
ctx,
conn,
s.scope,
organizationID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(peoples, cursor), nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListOrganizationVendors(
ctx context.Context,
organizationID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Vendor], error) {
var vendors coredata.Vendors
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return vendors.LoadByOrganizationID(
ctx,
conn,
s.scope,
organizationID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(vendors, cursor), nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListTaskEvidences(
ctx context.Context,
taskID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Evidence], error) {
var evidences coredata.Evidences
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return evidences.LoadByTaskID(
ctx,
conn,
s.scope,
taskID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(evidences, cursor), nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/pg"
)
func (s Service) ListTaskStateTransitions(
ctx context.Context,
taskID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.TaskStateTransition], error) {
var taskStateTransitions coredata.TaskStateTransitions
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return taskStateTransitions.LoadByTaskID(
ctx,
conn,
s.scope,
taskID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(taskStateTransitions, cursor), nil
}

View File

@@ -18,8 +18,6 @@ import (
"context"
"fmt"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/probo/coredata"
"go.gearno.de/kit/migrator"
"go.gearno.de/kit/pg"
@@ -43,391 +41,3 @@ func NewService(ctx context.Context, pgClient *pg.Client) (*Service, error) {
scope: coredata.NewScope(), // must be created from auth
}, nil
}
func (s Service) GetOrganization(
ctx context.Context,
organizationID gid.GID,
) (*coredata.Organization, error) {
organization := &coredata.Organization{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return organization.LoadByID(
ctx,
conn,
s.scope,
organizationID,
)
},
)
if err != nil {
return nil, err
}
return organization, nil
}
func (s Service) GetPeople(
ctx context.Context,
peopleID gid.GID,
) (*coredata.People, error) {
people := &coredata.People{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return people.LoadByID(ctx, conn, s.scope, peopleID)
},
)
if err != nil {
return nil, err
}
return people, nil
}
func (s Service) GetVendor(
ctx context.Context,
vendorID gid.GID,
) (*coredata.Vendor, error) {
vendor := &coredata.Vendor{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return vendor.LoadByID(ctx, conn, s.scope, vendorID)
},
)
if err != nil {
return nil, err
}
return vendor, nil
}
func (s Service) GetFramework(
ctx context.Context,
frameworkID gid.GID,
) (*coredata.Framework, error) {
framework := &coredata.Framework{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return framework.LoadByID(ctx, conn, s.scope, frameworkID)
},
)
if err != nil {
return nil, err
}
return framework, nil
}
func (s Service) GetControl(
ctx context.Context,
controlID gid.GID,
) (*coredata.Control, error) {
control := &coredata.Control{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return control.LoadByID(ctx, conn, s.scope, controlID)
},
)
if err != nil {
return nil, err
}
return control, nil
}
func (s Service) GetTask(
ctx context.Context,
taskID gid.GID,
) (*coredata.Task, error) {
task := &coredata.Task{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return task.LoadByID(ctx, conn, s.scope, taskID)
},
)
if err != nil {
return nil, err
}
return task, nil
}
func (s Service) GetEvidence(
ctx context.Context,
evidenceID gid.GID,
) (*coredata.Evidence, error) {
evidence := &coredata.Evidence{}
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return evidence.LoadByID(ctx, conn, s.scope, evidenceID)
},
)
if err != nil {
return nil, err
}
return evidence, nil
}
func (s Service) ListOrganizationFrameworks(
ctx context.Context,
organizationID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Framework], error) {
var frameworks coredata.Frameworks
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return frameworks.LoadByOrganizationID(
ctx,
conn,
s.scope,
organizationID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(frameworks, cursor), nil
}
func (s Service) ListFrameworkControls(
ctx context.Context,
frameworkID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Control], error) {
var controls coredata.Controls
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return controls.LoadByFrameworkID(
ctx,
conn,
s.scope,
frameworkID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(controls, cursor), nil
}
func (s Service) ListControlTasks(
ctx context.Context,
controlID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Task], error) {
var tasks coredata.Tasks
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return tasks.LoadByControlID(
ctx,
conn,
s.scope,
controlID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(tasks, cursor), nil
}
func (s Service) ListControlStateTransitions(
ctx context.Context,
controlID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.ControlStateTransition], error) {
var controlStateTransitions coredata.ControlStateTransitions
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return controlStateTransitions.LoadByControlID(
ctx,
conn,
s.scope,
controlID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(controlStateTransitions, cursor), nil
}
func (s Service) ListTaskEvidences(
ctx context.Context,
taskID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Evidence], error) {
var evidences coredata.Evidences
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return evidences.LoadByTaskID(
ctx,
conn,
s.scope,
taskID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(evidences, cursor), nil
}
func (s Service) ListOrganizationVendors(
ctx context.Context,
organizationID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.Vendor], error) {
var vendors coredata.Vendors
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return vendors.LoadByOrganizationID(
ctx,
conn,
s.scope,
organizationID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(vendors, cursor), nil
}
func (s Service) ListOrganizationPeoples(
ctx context.Context,
organizationID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.People], error) {
var peoples coredata.Peoples
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return peoples.LoadByOrganizationID(
ctx,
conn,
s.scope,
organizationID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(peoples, cursor), nil
}
func (s Service) ListTaskStateTransitions(
ctx context.Context,
taskID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.TaskStateTransition], error) {
var taskStateTransitions coredata.TaskStateTransitions
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return taskStateTransitions.LoadByTaskID(
ctx,
conn,
s.scope,
taskID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(taskStateTransitions, cursor), nil
}
func (s Service) ListEvidenceStateTransitions(
ctx context.Context,
evidenceID gid.GID,
cursor *page.Cursor,
) (*page.Page[*coredata.EvidenceStateTransition], error) {
var evidenceStateTransitions coredata.EvidenceStateTransitions
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return evidenceStateTransitions.LoadByEvidenceID(
ctx,
conn,
s.scope,
evidenceID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(evidenceStateTransitions, cursor), nil
}