diff --git a/management/actions.go b/management/actions.go new file mode 100644 index 0000000..0d59f9e --- /dev/null +++ b/management/actions.go @@ -0,0 +1,279 @@ +package management + +import ( + "net/http" + "time" +) + +const ( + ActionTriggerPostLogin string = "post-login" + ActionTriggerClientCredentials string = "client-credentials" +) + +type ActionTrigger struct { + ID *string `json:"id"` + Version *string `json:"version"` + Status *string `json:"status,omitempty"` +} + +type ActionTriggerList struct { + Triggers []*ActionTrigger `json:"triggers"` +} + +type ActionDependency struct { + Name *string `json:"name"` + Version *string `json:"version,omitempty"` + RegistryURL *string `json:"registry_url,omitempty"` +} + +type ActionSecret struct { + Name *string `json:"name"` + Value *string `json:"value,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} + +type ActionVersionError struct { + ID *string `json:"id"` + Message *string `json:"msg"` + Url *string `json:"url"` +} + +const ( + ActionStatusPending string = "pending" + ActionStatusBuilding string = "building" + ActionStatusPackaged string = "packaged" + ActionStatusBuilt string = "built" + ActionStatusRetrying string = "retrying" + ActionStatusFailed string = "failed" +) + +type Action struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name"` + Code *string `json:"code,omitempty"` // nil in embedded Action in ActionVersion + + SupportedTriggers []ActionTrigger `json:"supported_triggers"` + Dependencies []ActionDependency `json:"dependencies,omitempty"` + Secrets []ActionSecret `json:"secrets,omitempty"` + + DeployedVersion *ActionVersion `json:"deployed_version,omitempty"` + Status *string `json:"status,omitempty"` + AllChangesDeployed bool `json:"all_changes_deployed,omitempty"` + + BuiltAt *time.Time `json:"built_at,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} + +type ActionList struct { + List + Actions []*Action `json:"actions"` +} + +type ActionVersion struct { + ID *string `json:"id,omitempty"` + Code *string `json:"code"` + Dependencies []ActionDependency `json:"dependencies,omitempty"` + Deployed bool `json:"deployed"` + Status *string `json:"status,omitempty"` + Number int `json:"number,omitempty"` + + Errors []ActionVersionError `json:"errors,omitempty"` + Action *Action `json:"action,omitempty"` + + BuiltAt *time.Time `json:"built_at,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} + +type ActionVersionList struct { + List + Versions []*ActionVersion `json:"versions"` +} + +const ( + ActionBindingReferenceByName string = "action_name" + ActionBindingReferenceById string = "action_id" +) + +type ActionBindingReference struct { + Type *string `json:"type"` + Value *string `json:"value"` +} + +type ActionBinding struct { + ID *string `json:"id,omitempty"` + TriggerID *string `json:"trigger_id,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + + Ref *ActionBindingReference `json:"ref,omitempty"` + Action *Action `json:"action,omitempty"` + Secrets []ActionSecret `json:"secrets,omitempty"` + + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} + +type ActionBindingList struct { + List + Bindings []*ActionBinding `json:"bindings"` +} + +type actionBindingsPerTrigger struct { + Bindings []*ActionBinding `json:"bindings"` +} + +type ActionTestPayload map[string]interface{} + +type ActionTestRequest struct { + Payload *ActionTestPayload `json:"payload"` +} + +type ActionExecutionResult struct { + ActionName *string `json:"action_name,omitempty"` + Error *map[string]string `json:"error,omitempty"` + + StartedAt *time.Time `json:"started_at,omitempty"` + EndedAt *time.Time `json:"ended_at,omitempty"` +} + +type ActionExecution struct { + ID *string `json:"id"` + TriggerID *string `json:"trigger_id"` + Status *string `json:"status"` + Results []*ActionExecutionResult `json:"results"` + + CreatedAt *time.Time `json:"created_at"` + UpdatedAt *time.Time `json:"updated_at"` +} + +type ActionManager struct { + *Management +} + +func newActionManager(m *Management) *ActionManager { + return &ActionManager{m} +} + +func applyActionsListDefaults(options []RequestOption) RequestOption { + return newRequestOption(func(r *http.Request) { + PerPage(50).apply(r) + for _, option := range options { + option.apply(r) + } + }) +} + +// ListTriggers available. +// +// https://auth0.com/docs/api/management/v2/#!/Actions/get_triggers +func (m *ActionManager) ListTriggers(opts ...RequestOption) (l *ActionTriggerList, err error) { + err = m.Request("GET", m.URI("actions", "triggers"), &l, opts...) + return +} + +// Create a new action. +// +// See: https://auth0.com/docs/api/management/v2#!/Actions/post_action +func (m *ActionManager) Create(a *Action, opts ...RequestOption) error { + return m.Request("POST", m.URI("actions", "actions"), a, opts...) +} + +// Retrieve action details. +// +// See: https://auth0.com/docs/api/management/v2#!/Actions/get_action +func (m *ActionManager) Read(id string, opts ...RequestOption) (a *Action, err error) { + err = m.Request("GET", m.URI("actions", "actions", id), &a, opts...) + return +} + +// Update an existing action. +// +// See: https://auth0.com/docs/api/management/v2#!/Actions/patch_action +func (m *ActionManager) Update(id string, a *Action, opts ...RequestOption) error { + return m.Request("PATCH", m.URI("actions", "actions", id), &a, opts...) +} + +// Delete an action +// +// See: https://auth0.com/docs/api/management/v2#!/Actions/delete_action +func (m *ActionManager) Delete(id string, opts ...RequestOption) error { + return m.Request("DELETE", m.URI("actions", "actions", id), nil, opts...) +} + +// List all actions. +// +// See: https://auth0.com/docs/api/management/v2#!/Actions/get_actions +func (m *ActionManager) List(opts ...RequestOption) (l *ActionList, err error) { + err = m.Request("GET", m.URI("actions", "actions"), &l, applyActionsListDefaults(opts)) + return +} + +// ReadVersion of an action. +// +// See: https://auth0.com/docs/api/management/v2/#!/Actions/get_action_version +func (m *ActionManager) ReadVersion(id string, versionId string, opts ...RequestOption) (v *ActionVersion, err error) { + err = m.Request("GET", m.URI("actions", "actions", id, "versions", versionId), &v, opts...) + return +} + +// ListVersions of an action. +// +// See: https://auth0.com/docs/api/management/v2/#!/Actions/get_action_versions +func (m *ActionManager) ListVersions(id string, opts ...RequestOption) (c *ActionVersionList, err error) { + err = m.Request("GET", m.URI("actions", "actions", id, "versions"), &c, applyActionsListDefaults(opts)) + return +} + +// UpdateBindings of a trigger +// +// See: https://auth0.com/docs/api/management/v2/#!/Actions/patch_bindings +func (m *ActionManager) UpdateBindings(triggerID string, b []*ActionBinding, opts ...RequestOption) error { + bl := &actionBindingsPerTrigger{ + Bindings: b, + } + return m.Request("PATCH", m.URI("actions", "triggers", triggerID, "bindings"), &bl, opts...) +} + +// ListBindings of a trigger +// +// See: https://auth0.com/docs/api/management/v2/#!/Actions/get_bindings +func (m *ActionManager) ListBindings(triggerID string, opts ...RequestOption) (bl *ActionBindingList, err error) { + err = m.Request("GET", m.URI("actions", "triggers", triggerID, "bindings"), &bl, applyActionsListDefaults(opts)) + return +} + +// Deploy an action +// +// See: https://auth0.com/docs/api/management/v2/#!/Actions/post_deploy_action +func (m *ActionManager) Deploy(id string, opts ...RequestOption) (v *ActionVersion, err error) { + err = m.Request("POST", m.URI("actions", "actions", id, "deploy"), &v, opts...) + return +} + +// DeployVersion of an action +// +// See: https://auth0.com/docs/api/management/v2/#!/Actions/post_deploy_draft_version +func (m *ActionManager) DeployVersion(id string, versionId string, opts ...RequestOption) (v *ActionVersion, err error) { + err = m.Request("POST", m.URI("actions", "actions", id, "versions", versionId, "deploy"), &v, opts...) + return +} + +// Test an action +// +// See: https://auth0.com/docs/api/management/v2/#!/Actions/post_test_action +func (m *ActionManager) Test(id string, payload *ActionTestPayload, opts ...RequestOption) (err error) { + r := &ActionTestRequest{ + Payload: payload, + } + err = m.Request("POST", m.URI("actions", "actions", id, "test"), &r, opts...) + return +} + +// ReadExecution of an action +// +// See: https://auth0.com/docs/api/management/v2/#!/Actions/get_execution +func (m *ActionManager) ReadExecution(executionId string, opts ...RequestOption) (v *ActionExecution, err error) { + err = m.Request("GET", m.URI("actions", "executions", executionId), &v, opts...) + return +} diff --git a/management/actions_test.go b/management/actions_test.go new file mode 100644 index 0000000..ecf5b15 --- /dev/null +++ b/management/actions_test.go @@ -0,0 +1,217 @@ +package management + +import ( + "errors" + "gopkg.in/auth0.v5" + "testing" + "time" +) + +func ensureActionBuilt(a *Action) (err error) { + i := 1 + var r *Action + for i < 20 { + r, err = m.Action.Read(a.GetID()) + if err != nil { + return + } + if r.GetStatus() == ActionStatusBuilt { + break + } + time.Sleep(1 * time.Second) + i++ + } + if r.GetStatus() != ActionStatusBuilt { + err = errors.New("action failed to build") + } + return +} + +func TestActions(t *testing.T) { + + r := &Action{ + Name: auth0.String("test-action"), + Code: auth0.String("exports.onExecutePostLogin = async (event, api) =\u003e {}"), + SupportedTriggers: []ActionTrigger{ + {ID: auth0.String(ActionTriggerPostLogin), Version: auth0.String("v2")}, + }, + Dependencies: []ActionDependency{ + {Name: auth0.String("lodash"), Version: auth0.String("4.0.0"), RegistryURL: auth0.String("https://www.npmjs.com/package/lodash")}, + }, + Secrets: []ActionSecret{ + {Name: auth0.String("mySecretName"), Value: auth0.String("mySecretValue")}, + }, + } + + var err error + var v *ActionVersion + var vl *ActionVersionList + + t.Run("ListTriggers", func(t *testing.T) { + l, err := m.Action.ListTriggers() + if err != nil { + t.Error(err) + } + t.Logf("%v\n", l) + }) + + t.Run("Create", func(t *testing.T) { + err = m.Action.Create(r) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", r) + }) + + t.Run("Read", func(t *testing.T) { + r, err = m.Action.Read(r.GetID()) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", r) + }) + + t.Run("List", func(t *testing.T) { + r, err := m.Action.List() + if err != nil { + t.Error(err) + } + t.Logf("%v\n", r) + }) + + t.Run("Deploy", func(t *testing.T) { + err = ensureActionBuilt(r) + if err != nil { + t.Fatal(err) + } + v, err = m.Action.Deploy(r.GetID()) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", v) + }) + + t.Run("Update", func(t *testing.T) { + id := r.GetID() + + r.ID = nil // read-only + r.UpdatedAt = nil // read-only + r.CreatedAt = nil // read-only + r.Status = nil // read-only + r.Code = auth0.String("exports.onExecutePostLogin = async (event, api) => { api.user.setUserMetadata('myParam', 'foo'); };") + + err = m.Action.Update(id, r) + if err != nil { + t.Error(err) + } + t.Logf("%v\n", r) + }) + + t.Run("DeployAgain", func(t *testing.T) { + err = ensureActionBuilt(r) + if err != nil { + t.Fatal(err) + } + v, err = m.Action.Deploy(r.GetID()) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", v) + }) + + t.Run("ReadVersion", func(t *testing.T) { + v, err := m.Action.ReadVersion(r.GetID(), v.GetID()) + if err != nil { + t.Error(err) + } + t.Logf("%v\n", v) + }) + + t.Run("ListVersions", func(t *testing.T) { + vl, err = m.Action.ListVersions(r.GetID()) + if err != nil { + t.Error(err) + } + t.Logf("%v\n", vl) + }) + + t.Run("DeployVersion", func(t *testing.T) { + v, err = m.Action.DeployVersion(r.GetID(), vl.Versions[0].GetID()) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", v) + }) + + t.Run("UpdateBindings", func(t *testing.T) { + b := []*ActionBinding{ + { + Ref: &ActionBindingReference{ + Type: auth0.String(ActionBindingReferenceByName), + Value: r.Name, + }, + DisplayName: auth0.String("My test action Binding"), + }, + } + err = m.Action.UpdateBindings(ActionTriggerPostLogin, b) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", b) + }) + + t.Run("ListBindings", func(t *testing.T) { + bl, err := m.Action.ListBindings(ActionTriggerPostLogin) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", bl) + }) + + t.Run("Test", func(t *testing.T) { + p := &ActionTestPayload{ + "event": ActionTestPayload{ + "user": ActionTestPayload{ + "email": "j+smith@example.com", + "emailVerified": true, + "id": "auth0|5f7c8ec7c33c6c004bbafe82", + }, + }, + } + err = m.Action.Test(r.GetID(), p) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", p) + }) + + t.Run("ReadExecution", func(t *testing.T) { + _, err := m.Action.ReadExecution("M9IqRp9wQLaYNrSwz6YPTTIwMjEwNDA0") + if err != nil { + mgmtError, _ := err.(*managementError) + if mgmtError.StatusCode != 404 { + t.Fatal(err) + } + // Expect a 404 as we can't get execution ID via API + t.Log(err) + return + } + t.Fatal(errors.New("read execution unexpectedly succeeded")) + }) + + t.Run("ClearBindings", func(t *testing.T) { + b := make([]*ActionBinding, 0) + err = m.Action.UpdateBindings(ActionTriggerPostLogin, b) + if err != nil { + t.Fatal(err) + } + t.Logf("%v\n", b) + }) + + t.Run("Delete", func(t *testing.T) { + err = m.Action.Delete(r.GetID()) + if err != nil { + t.Fatal(err) + } + }) +} diff --git a/management/management.gen.go b/management/management.gen.go index 60b39e9..6e4092b 100644 --- a/management/management.gen.go +++ b/management/management.gen.go @@ -6,6 +6,449 @@ import ( "time" ) +// GetBuiltAt returns the BuiltAt field if it's non-nil, zero value otherwise. +func (a *Action) GetBuiltAt() time.Time { + if a == nil || a.BuiltAt == nil { + return time.Time{} + } + return *a.BuiltAt +} + +// GetCode returns the Code field if it's non-nil, zero value otherwise. +func (a *Action) GetCode() string { + if a == nil || a.Code == nil { + return "" + } + return *a.Code +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (a *Action) GetCreatedAt() time.Time { + if a == nil || a.CreatedAt == nil { + return time.Time{} + } + return *a.CreatedAt +} + +// GetDeployedVersion returns the DeployedVersion field. +func (a *Action) GetDeployedVersion() *ActionVersion { + if a == nil { + return nil + } + return a.DeployedVersion +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *Action) GetID() string { + if a == nil || a.ID == nil { + return "" + } + return *a.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (a *Action) GetName() string { + if a == nil || a.Name == nil { + return "" + } + return *a.Name +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (a *Action) GetStatus() string { + if a == nil || a.Status == nil { + return "" + } + return *a.Status +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *Action) GetUpdatedAt() time.Time { + if a == nil || a.UpdatedAt == nil { + return time.Time{} + } + return *a.UpdatedAt +} + +// String returns a string representation of Action. +func (a *Action) String() string { + return Stringify(a) +} + +// GetAction returns the Action field. +func (a *ActionBinding) GetAction() *Action { + if a == nil { + return nil + } + return a.Action +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (a *ActionBinding) GetCreatedAt() time.Time { + if a == nil || a.CreatedAt == nil { + return time.Time{} + } + return *a.CreatedAt +} + +// GetDisplayName returns the DisplayName field if it's non-nil, zero value otherwise. +func (a *ActionBinding) GetDisplayName() string { + if a == nil || a.DisplayName == nil { + return "" + } + return *a.DisplayName +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *ActionBinding) GetID() string { + if a == nil || a.ID == nil { + return "" + } + return *a.ID +} + +// GetRef returns the Ref field. +func (a *ActionBinding) GetRef() *ActionBindingReference { + if a == nil { + return nil + } + return a.Ref +} + +// GetTriggerID returns the TriggerID field if it's non-nil, zero value otherwise. +func (a *ActionBinding) GetTriggerID() string { + if a == nil || a.TriggerID == nil { + return "" + } + return *a.TriggerID +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *ActionBinding) GetUpdatedAt() time.Time { + if a == nil || a.UpdatedAt == nil { + return time.Time{} + } + return *a.UpdatedAt +} + +// String returns a string representation of ActionBinding. +func (a *ActionBinding) String() string { + return Stringify(a) +} + +// String returns a string representation of ActionBindingList. +func (a *ActionBindingList) String() string { + return Stringify(a) +} + +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (a *ActionBindingReference) GetType() string { + if a == nil || a.Type == nil { + return "" + } + return *a.Type +} + +// GetValue returns the Value field if it's non-nil, zero value otherwise. +func (a *ActionBindingReference) GetValue() string { + if a == nil || a.Value == nil { + return "" + } + return *a.Value +} + +// String returns a string representation of ActionBindingReference. +func (a *ActionBindingReference) String() string { + return Stringify(a) +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (a *ActionDependency) GetName() string { + if a == nil || a.Name == nil { + return "" + } + return *a.Name +} + +// GetRegistryURL returns the RegistryURL field if it's non-nil, zero value otherwise. +func (a *ActionDependency) GetRegistryURL() string { + if a == nil || a.RegistryURL == nil { + return "" + } + return *a.RegistryURL +} + +// GetVersion returns the Version field if it's non-nil, zero value otherwise. +func (a *ActionDependency) GetVersion() string { + if a == nil || a.Version == nil { + return "" + } + return *a.Version +} + +// String returns a string representation of ActionDependency. +func (a *ActionDependency) String() string { + return Stringify(a) +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (a *ActionExecution) GetCreatedAt() time.Time { + if a == nil || a.CreatedAt == nil { + return time.Time{} + } + return *a.CreatedAt +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *ActionExecution) GetID() string { + if a == nil || a.ID == nil { + return "" + } + return *a.ID +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (a *ActionExecution) GetStatus() string { + if a == nil || a.Status == nil { + return "" + } + return *a.Status +} + +// GetTriggerID returns the TriggerID field if it's non-nil, zero value otherwise. +func (a *ActionExecution) GetTriggerID() string { + if a == nil || a.TriggerID == nil { + return "" + } + return *a.TriggerID +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *ActionExecution) GetUpdatedAt() time.Time { + if a == nil || a.UpdatedAt == nil { + return time.Time{} + } + return *a.UpdatedAt +} + +// String returns a string representation of ActionExecution. +func (a *ActionExecution) String() string { + return Stringify(a) +} + +// GetActionName returns the ActionName field if it's non-nil, zero value otherwise. +func (a *ActionExecutionResult) GetActionName() string { + if a == nil || a.ActionName == nil { + return "" + } + return *a.ActionName +} + +// GetEndedAt returns the EndedAt field if it's non-nil, zero value otherwise. +func (a *ActionExecutionResult) GetEndedAt() time.Time { + if a == nil || a.EndedAt == nil { + return time.Time{} + } + return *a.EndedAt +} + +// GetError returns the Error field if it's non-nil, zero value otherwise. +func (a *ActionExecutionResult) GetError() map[string]string { + if a == nil || a.Error == nil { + return map[string]string{} + } + return *a.Error +} + +// GetStartedAt returns the StartedAt field if it's non-nil, zero value otherwise. +func (a *ActionExecutionResult) GetStartedAt() time.Time { + if a == nil || a.StartedAt == nil { + return time.Time{} + } + return *a.StartedAt +} + +// String returns a string representation of ActionExecutionResult. +func (a *ActionExecutionResult) String() string { + return Stringify(a) +} + +// String returns a string representation of ActionList. +func (a *ActionList) String() string { + return Stringify(a) +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (a *ActionSecret) GetName() string { + if a == nil || a.Name == nil { + return "" + } + return *a.Name +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *ActionSecret) GetUpdatedAt() time.Time { + if a == nil || a.UpdatedAt == nil { + return time.Time{} + } + return *a.UpdatedAt +} + +// GetValue returns the Value field if it's non-nil, zero value otherwise. +func (a *ActionSecret) GetValue() string { + if a == nil || a.Value == nil { + return "" + } + return *a.Value +} + +// String returns a string representation of ActionSecret. +func (a *ActionSecret) String() string { + return Stringify(a) +} + +// GetPayload returns the Payload field. +func (a *ActionTestRequest) GetPayload() *ActionTestPayload { + if a == nil { + return nil + } + return a.Payload +} + +// String returns a string representation of ActionTestRequest. +func (a *ActionTestRequest) String() string { + return Stringify(a) +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *ActionTrigger) GetID() string { + if a == nil || a.ID == nil { + return "" + } + return *a.ID +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (a *ActionTrigger) GetStatus() string { + if a == nil || a.Status == nil { + return "" + } + return *a.Status +} + +// GetVersion returns the Version field if it's non-nil, zero value otherwise. +func (a *ActionTrigger) GetVersion() string { + if a == nil || a.Version == nil { + return "" + } + return *a.Version +} + +// String returns a string representation of ActionTrigger. +func (a *ActionTrigger) String() string { + return Stringify(a) +} + +// String returns a string representation of ActionTriggerList. +func (a *ActionTriggerList) String() string { + return Stringify(a) +} + +// GetAction returns the Action field. +func (a *ActionVersion) GetAction() *Action { + if a == nil { + return nil + } + return a.Action +} + +// GetBuiltAt returns the BuiltAt field if it's non-nil, zero value otherwise. +func (a *ActionVersion) GetBuiltAt() time.Time { + if a == nil || a.BuiltAt == nil { + return time.Time{} + } + return *a.BuiltAt +} + +// GetCode returns the Code field if it's non-nil, zero value otherwise. +func (a *ActionVersion) GetCode() string { + if a == nil || a.Code == nil { + return "" + } + return *a.Code +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (a *ActionVersion) GetCreatedAt() time.Time { + if a == nil || a.CreatedAt == nil { + return time.Time{} + } + return *a.CreatedAt +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *ActionVersion) GetID() string { + if a == nil || a.ID == nil { + return "" + } + return *a.ID +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (a *ActionVersion) GetStatus() string { + if a == nil || a.Status == nil { + return "" + } + return *a.Status +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *ActionVersion) GetUpdatedAt() time.Time { + if a == nil || a.UpdatedAt == nil { + return time.Time{} + } + return *a.UpdatedAt +} + +// String returns a string representation of ActionVersion. +func (a *ActionVersion) String() string { + return Stringify(a) +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *ActionVersionError) GetID() string { + if a == nil || a.ID == nil { + return "" + } + return *a.ID +} + +// GetMessage returns the Message field if it's non-nil, zero value otherwise. +func (a *ActionVersionError) GetMessage() string { + if a == nil || a.Message == nil { + return "" + } + return *a.Message +} + +// GetUrl returns the Url field if it's non-nil, zero value otherwise. +func (a *ActionVersionError) GetUrl() string { + if a == nil || a.Url == nil { + return "" + } + return *a.Url +} + +// String returns a string representation of ActionVersionError. +func (a *ActionVersionError) String() string { + return Stringify(a) +} + +// String returns a string representation of ActionVersionList. +func (a *ActionVersionList) String() string { + return Stringify(a) +} + // String returns a string representation of BlacklistToken. func (b *BlacklistToken) String() string { return Stringify(b) diff --git a/management/management.go b/management/management.go index b9ab96a..70c3e5c 100644 --- a/management/management.go +++ b/management/management.go @@ -159,6 +159,9 @@ type Management struct { // Anomaly manages the IP blocks Anomaly *AnomalyManager + // Actions manages Actions extensibility + Action *ActionManager + url *url.URL basePath string userAgent string @@ -227,6 +230,7 @@ func New(domain string, options ...ManagementOption) (*Management, error) { m.Blacklist = newBlacklistManager(m) m.SigningKey = newSigningKeyManager(m) m.Anomaly = newAnomalyManager(m) + m.Action = newActionManager(m) return m, nil }