-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d2b6b0
commit 419294a
Showing
7 changed files
with
311 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package openpipeline | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api" | ||
openpipeline "github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/openpipeline/settings" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/rest" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/settings" | ||
"github.com/dynatrace/dynatrace-configuration-as-code-core/clients" | ||
caclib "github.com/dynatrace/dynatrace-configuration-as-code-core/clients/openpipeline" | ||
"golang.org/x/oauth2/clientcredentials" | ||
) | ||
|
||
func BusinessEventsService(credentials *settings.Credentials) settings.CRUDService[*openpipeline.Configuration] { | ||
return &businessEventsService{credentials} | ||
} | ||
|
||
type businessEventsService struct { | ||
credentials *settings.Credentials | ||
} | ||
|
||
func (s *businessEventsService) client() *caclib.Client { | ||
factory := clients.Factory(). | ||
WithUserAgent("Dynatrace Terraform Provider"). | ||
WithPlatformURL(s.credentials.Automation.EnvironmentURL). | ||
WithOAuthCredentials(clientcredentials.Config{ | ||
ClientID: s.credentials.Automation.ClientID, | ||
ClientSecret: s.credentials.Automation.ClientSecret, | ||
TokenURL: s.credentials.Automation.TokenURL, | ||
}) | ||
|
||
openPipelineClient, _ := factory.OpenPipelineClient() | ||
return openPipelineClient | ||
|
||
} | ||
|
||
func (s businessEventsService) List(ctx context.Context) (api.Stubs, error) { | ||
//TODO implement me | ||
return api.Stubs{}, nil | ||
} | ||
|
||
func (s businessEventsService) Get(ctx context.Context, id string, v *openpipeline.Configuration) error { | ||
response, err := s.client().Get(ctx, id) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !response.IsSuccess() { | ||
return rest.Envelope(response.Data, s.credentials.Automation.EnvironmentURL, "GET") | ||
} | ||
|
||
return json.Unmarshal(response.Data, &v) | ||
} | ||
|
||
func (s businessEventsService) SchemaID() string { | ||
return "platform:openpipeline.events.business" | ||
} | ||
|
||
func (s businessEventsService) Create(_ context.Context, v *openpipeline.Configuration) (*api.Stub, error) { | ||
return &api.Stub{ID: v.Kind}, nil | ||
} | ||
|
||
func (s businessEventsService) Update(_ context.Context, id string, v *openpipeline.Configuration) error { | ||
return nil | ||
} | ||
|
||
func (s businessEventsService) Delete(_ context.Context, id string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package openpipeline | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api" | ||
openpipeline "github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/openpipeline/settings" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/rest" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/settings" | ||
"github.com/dynatrace/dynatrace-configuration-as-code-core/clients" | ||
caclib "github.com/dynatrace/dynatrace-configuration-as-code-core/clients/openpipeline" | ||
"golang.org/x/oauth2/clientcredentials" | ||
) | ||
|
||
func EventsService(credentials *settings.Credentials) settings.CRUDService[*openpipeline.Configuration] { | ||
return &eventsService{credentials} | ||
} | ||
|
||
type eventsService struct { | ||
credentials *settings.Credentials | ||
} | ||
|
||
func (s *eventsService) client() *caclib.Client { | ||
factory := clients.Factory(). | ||
WithUserAgent("Dynatrace Terraform Provider"). | ||
WithPlatformURL(s.credentials.Automation.EnvironmentURL). | ||
WithOAuthCredentials(clientcredentials.Config{ | ||
ClientID: s.credentials.Automation.ClientID, | ||
ClientSecret: s.credentials.Automation.ClientSecret, | ||
TokenURL: s.credentials.Automation.TokenURL, | ||
}) | ||
|
||
openPipelineClient, _ := factory.OpenPipelineClient() | ||
return openPipelineClient | ||
|
||
} | ||
|
||
func (s eventsService) List(ctx context.Context) (api.Stubs, error) { | ||
//TODO implement me | ||
return api.Stubs{}, nil | ||
} | ||
|
||
func (s eventsService) Get(ctx context.Context, id string, v *openpipeline.Configuration) error { | ||
response, err := s.client().Get(ctx, id) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !response.IsSuccess() { | ||
return rest.Envelope(response.Data, s.credentials.Automation.EnvironmentURL, "GET") | ||
} | ||
|
||
return json.Unmarshal(response.Data, &v) | ||
} | ||
|
||
func (s eventsService) SchemaID() string { | ||
return "platform:openpipeline.events" | ||
} | ||
|
||
func (s eventsService) Create(_ context.Context, v *openpipeline.Configuration) (*api.Stub, error) { | ||
return &api.Stub{ID: v.Kind}, nil | ||
} | ||
|
||
func (s eventsService) Update(_ context.Context, id string, v *openpipeline.Configuration) error { | ||
return nil | ||
} | ||
|
||
func (s eventsService) Delete(_ context.Context, id string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package openpipeline | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api" | ||
openpipeline "github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/openpipeline/settings" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/rest" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/settings" | ||
"github.com/dynatrace/dynatrace-configuration-as-code-core/clients" | ||
caclib "github.com/dynatrace/dynatrace-configuration-as-code-core/clients/openpipeline" | ||
"golang.org/x/oauth2/clientcredentials" | ||
) | ||
|
||
func SDLCEventsService(credentials *settings.Credentials) settings.CRUDService[*openpipeline.Configuration] { | ||
return &sdlcEventsService{credentials} | ||
} | ||
|
||
type sdlcEventsService struct { | ||
credentials *settings.Credentials | ||
} | ||
|
||
func (s *sdlcEventsService) client() *caclib.Client { | ||
factory := clients.Factory(). | ||
WithUserAgent("Dynatrace Terraform Provider"). | ||
WithPlatformURL(s.credentials.Automation.EnvironmentURL). | ||
WithOAuthCredentials(clientcredentials.Config{ | ||
ClientID: s.credentials.Automation.ClientID, | ||
ClientSecret: s.credentials.Automation.ClientSecret, | ||
TokenURL: s.credentials.Automation.TokenURL, | ||
}) | ||
|
||
openPipelineClient, _ := factory.OpenPipelineClient() | ||
return openPipelineClient | ||
|
||
} | ||
|
||
func (s sdlcEventsService) List(ctx context.Context) (api.Stubs, error) { | ||
//TODO implement me | ||
return api.Stubs{}, nil | ||
} | ||
|
||
func (s sdlcEventsService) Get(ctx context.Context, id string, v *openpipeline.Configuration) error { | ||
response, err := s.client().Get(ctx, id) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !response.IsSuccess() { | ||
return rest.Envelope(response.Data, s.credentials.Automation.EnvironmentURL, "GET") | ||
} | ||
|
||
return json.Unmarshal(response.Data, &v) | ||
} | ||
|
||
func (s sdlcEventsService) SchemaID() string { | ||
return "platform:openpipeline.events.sdlc" | ||
} | ||
|
||
func (s sdlcEventsService) Create(_ context.Context, v *openpipeline.Configuration) (*api.Stub, error) { | ||
return &api.Stub{ID: v.Kind}, nil | ||
} | ||
|
||
func (s sdlcEventsService) Update(_ context.Context, id string, v *openpipeline.Configuration) error { | ||
return nil | ||
} | ||
|
||
func (s sdlcEventsService) Delete(_ context.Context, id string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package openpipeline | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api" | ||
openpipeline "github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/openpipeline/settings" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/rest" | ||
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/settings" | ||
"github.com/dynatrace/dynatrace-configuration-as-code-core/clients" | ||
caclib "github.com/dynatrace/dynatrace-configuration-as-code-core/clients/openpipeline" | ||
"golang.org/x/oauth2/clientcredentials" | ||
) | ||
|
||
func SecurityEventsService(credentials *settings.Credentials) settings.CRUDService[*openpipeline.Configuration] { | ||
return &securityEventsService{credentials} | ||
} | ||
|
||
type securityEventsService struct { | ||
credentials *settings.Credentials | ||
} | ||
|
||
func (s *securityEventsService) client() *caclib.Client { | ||
factory := clients.Factory(). | ||
WithUserAgent("Dynatrace Terraform Provider"). | ||
WithPlatformURL(s.credentials.Automation.EnvironmentURL). | ||
WithOAuthCredentials(clientcredentials.Config{ | ||
ClientID: s.credentials.Automation.ClientID, | ||
ClientSecret: s.credentials.Automation.ClientSecret, | ||
TokenURL: s.credentials.Automation.TokenURL, | ||
}) | ||
|
||
openPipelineClient, _ := factory.OpenPipelineClient() | ||
return openPipelineClient | ||
|
||
} | ||
|
||
func (s securityEventsService) List(ctx context.Context) (api.Stubs, error) { | ||
//TODO implement me | ||
return api.Stubs{}, nil | ||
} | ||
|
||
func (s securityEventsService) Get(ctx context.Context, id string, v *openpipeline.Configuration) error { | ||
response, err := s.client().Get(ctx, id) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !response.IsSuccess() { | ||
return rest.Envelope(response.Data, s.credentials.Automation.EnvironmentURL, "GET") | ||
} | ||
|
||
return json.Unmarshal(response.Data, &v) | ||
} | ||
|
||
func (s securityEventsService) SchemaID() string { | ||
return "platform:openpipeline.events.security" | ||
} | ||
|
||
func (s securityEventsService) Create(_ context.Context, v *openpipeline.Configuration) (*api.Stub, error) { | ||
return &api.Stub{ID: v.Kind}, nil | ||
} | ||
|
||
func (s securityEventsService) Update(_ context.Context, id string, v *openpipeline.Configuration) error { | ||
return nil | ||
} | ||
|
||
func (s securityEventsService) Delete(_ context.Context, id string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters