mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
* Importing the OpsGenie SDK * Adding the goreq dependency * Initial commit of the OpsGenie / User provider * Refactoring to return a single client * Adding an import test / fixing a copy/paste error * Adding support for OpsGenie docs * Scaffolding the user documentation for OpsGenie * Adding a TODO * Adding the User data source * Documentation for OpsGenie * Adding OpsGenie to the internal plugin list * Adding support for Teams * Documentation for OpsGenie Team's * Validation for Teams * Removing Description for now * Optional fields for a User: Locale/Timezone * Removing an implemented TODO * Running makefmt * Downloading about half the internet Someone witty might simply sign this commit with "npm install" * Adding validation to the user object * Fixing the docs * Adding a test creating multple users * Prompting for the API Key if it's not specified * Added a test for multiple users / requested changes * Fixing the linting
47 lines
839 B
Go
47 lines
839 B
Go
package opsgenie
|
|
|
|
import (
|
|
"log"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
"github.com/opsgenie/opsgenie-go-sdk/client"
|
|
)
|
|
|
|
type OpsGenieClient struct {
|
|
apiKey string
|
|
|
|
StopContext context.Context
|
|
|
|
teams client.OpsGenieTeamClient
|
|
users client.OpsGenieUserClient
|
|
}
|
|
|
|
// Config defines the configuration options for the OpsGenie client
|
|
type Config struct {
|
|
ApiKey string
|
|
}
|
|
|
|
// Client returns a new OpsGenie client
|
|
func (c *Config) Client() (*OpsGenieClient, error) {
|
|
opsGenie := new(client.OpsGenieClient)
|
|
opsGenie.SetAPIKey(c.ApiKey)
|
|
client := OpsGenieClient{}
|
|
|
|
log.Printf("[INFO] OpsGenie client configured")
|
|
|
|
teamsClient, err := opsGenie.Team()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
client.teams = *teamsClient
|
|
|
|
usersClient, err := opsGenie.User()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
client.users = *usersClient
|
|
|
|
return &client, nil
|
|
}
|