{"id":22751882,"url":"https://github.com/stackguardian/sg-sdk-go","last_synced_at":"2025-03-30T06:43:13.251Z","repository":{"id":257881495,"uuid":"829929948","full_name":"StackGuardian/sg-sdk-go","owner":"StackGuardian","description":"Go SDK for StackGuardian APIs","archived":false,"fork":false,"pushed_at":"2025-03-07T06:12:23.000Z","size":229,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T07:23:38.458Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StackGuardian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-17T09:17:48.000Z","updated_at":"2025-01-24T14:54:48.000Z","dependencies_parsed_at":"2025-02-05T08:45:27.721Z","dependency_job_id":"2701bdc2-1590-4d3e-a1ec-d3dd938b95a5","html_url":"https://github.com/StackGuardian/sg-sdk-go","commit_stats":null,"previous_names":["stackguardian/sg-sdk-go"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StackGuardian%2Fsg-sdk-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StackGuardian%2Fsg-sdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StackGuardian%2Fsg-sdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StackGuardian%2Fsg-sdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StackGuardian","download_url":"https://codeload.github.com/StackGuardian/sg-sdk-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246285667,"owners_count":20752953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-11T05:07:46.488Z","updated_at":"2025-03-30T06:43:13.227Z","avatar_url":"https://github.com/StackGuardian.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.stackguardian.io/\"\u003e\n    \u003cimg src=\".github/stackguardian_logo.svg\" alt=\"StackGuardian logo\" title=\"StackGuardian\" align=\"right\" height=\"40\" /\u003e\n\u003c/a\u003e\n\n# StackGuardian SDK For Go (sg-sdk-go)\n`sg-sdk-go` is the StackGuardian SDK for the Go Programming language.\n\nThe SG SDK requires a minimum version of `Go 1.19`.\n\nCheck out the notes in the release for information about the latest bug fixes, updates and features added to the SDK.\n\n### Getting started\n\nIt's recommended to store your API token and base URL in environment variables:\n```\nSG_BASE_URL (default: https://api.app.stackguardian.io)\nSG_API_TOKEN\n```\n\nInstall the SDK:\nTo get started working with the SDK, setup your project for Go modules and retrieve the SDK dependencies using `go get`.\n```\ngo get github.com/StackGuardian/sg-sdk-go@v1.0.0\n```\n\n### Sample Usage\n\n```go\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"os\"\n\n\tsggosdk \"github.com/StackGuardian/sg-sdk-go\"\n\tclient \"github.com/StackGuardian/sg-sdk-go/client\"\n\toption \"github.com/StackGuardian/sg-sdk-go/option\"\n)\n\nfunc main() {\n\n\t// Define the API key, base URL, org and workflow details\n\tAPI_KEY := \"apikey \" + os.Getenv(\"SG_API_TOKEN\")\n\tSG_ORG := \"demo-org\"\n\tSG_WF_GROUP := \"sg-sdk-go-test\"\n\tSG_WF := \"2aumphefkejtj3bv4q3wo\"\n\tSG_BASE_URL := os.Getenv(\"SG_BASE_URL\")\n\n\t// Create a new client using the API key and base URL\n\tc := client.NewClient(\n\t\toption.WithApiKey(API_KEY),\n\t\toption.WithBaseURL(SG_BASE_URL),\n\t)\n\n\t// Create a new WorkflowRun request\n\tcreateWorkflowRunRequest := sggosdk.WorkflowRun{\n\t\tDeploymentPlatformConfig: []*sggosdk.DeploymentPlatformConfig{{\n\t\t\tKind: sggosdk.DeploymentPlatformConfigKindEnumAwsRbac,\n\t\t\tConfig: map[string]interface{}{\n\t\t\t\t\"profileName\":   \"testAWSConnector\",\n\t\t\t\t\"integrationId\": \"/integrations/testAWSConnector\"}}},\n\t\tWfType: sggosdk.WfTypeEnumTerraform.Ptr(),\n\t\tEnvironmentVariables: []*sggosdk.EnvVars{{Kind: sggosdk.EnvVarsKindEnumPlainText,\n\t\t\tConfig: \u0026sggosdk.EnvVarConfig{VarName: \"test\", TextValue: sggosdk.String(\"testValue\")}}},\n\t\tVcsConfig: \u0026sggosdk.VcsConfig{\n\t\t\tIacVcsConfig: \u0026sggosdk.IacvcsConfig{\n\t\t\t\tIacTemplateId:          sggosdk.String(\"/stackguardian/aws-s3-demo-website:16\"),\n\t\t\t\tUseMarketplaceTemplate: true,\n\t\t\t},\n\t\t\tIacInputData: \u0026sggosdk.IacInputData{\n\t\t\t\tSchemaType: sggosdk.IacInputDataSchemaTypeEnumFormJsonschema,\n\t\t\t\tData: map[string]interface{}{\n\t\t\t\t\t\"bucket_region\": \"eu-central-1\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tUserJobCpu:    sggosdk.Int(512),\n\t\tUserJobMemory: sggosdk.Int(1024),\n\t\tRunnerConstraints: \u0026sggosdk.RunnerConstraints{\n\t\t\tType: \"shared\",\n\t\t},\n\t}\n\n\t// Create a new WorkflowRun using the client and request from above\n\tresponse, err := c.WorkflowRuns.CreateWorkflowRun(context.Background(),\n\t\tSG_ORG, SG_WF, SG_WF_GROUP, \u0026createWorkflowRunRequest)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\t// Get the resource name of the newly created WF run from the response\n\tvar wfRunResourceName string = response.Data.GetExtraProperties()[\"ResourceName\"].(string)\n\n\t// Get the status of the newly created WF run\n\twfRunResponse, err := c.WorkflowRuns.ReadWorkflowRun(context.Background(), SG_ORG, SG_WF, SG_WF_GROUP, wfRunResourceName)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tfmt.Println(wfRunResponse.Msg.Statuses[\"pre_0_step\"][0].Name)\n\n}\n```\n\n\n### Reporting bugs\nIf you encounter a bug with the SG SDK for Go we would like to hear about it. Please search the [existing issues](https://github.com/StackGuardian/sg-sdk-go/issues) and see if others are experiencing the same issue before opening a new one. \n\nPlease include the version of the SG SDK for Go, the Go version and the OS you are using along with steps to replicate the issue when appropriate.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackguardian%2Fsg-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackguardian%2Fsg-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackguardian%2Fsg-sdk-go/lists"}