From bcffd2b28c6939ca4eb4ba7ea39f015e01b708bf Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 11:54:22 -0400 Subject: [PATCH 01/20] GS-10 Move fabrications operation to fabricator namespace --- unimatrix/{ => fabricator}/fabrications_operation.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename unimatrix/{ => fabricator}/fabrications_operation.go (100%) diff --git a/unimatrix/fabrications_operation.go b/unimatrix/fabricator/fabrications_operation.go similarity index 100% rename from unimatrix/fabrications_operation.go rename to unimatrix/fabricator/fabrications_operation.go From e2e643cb249a2a0ed19354b9c2bbc9c121ce1b8a Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 11:57:06 -0400 Subject: [PATCH 02/20] GS-7 Move activist operations to activist namespace --- unimatrix/activist/activities_operation.go | 7 +++++++ unimatrix/activist/activities_schedules_operation.go | 7 +++++++ unimatrix/activist/tasks_operation.go | 7 +++++++ unimatrix/activities_operation.go | 5 ----- unimatrix/activities_schedules_operation.go | 5 ----- unimatrix/tasks_operation.go | 5 ----- 6 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 unimatrix/activist/activities_operation.go create mode 100644 unimatrix/activist/activities_schedules_operation.go create mode 100644 unimatrix/activist/tasks_operation.go delete mode 100644 unimatrix/activities_operation.go delete mode 100644 unimatrix/activities_schedules_operation.go delete mode 100644 unimatrix/tasks_operation.go diff --git a/unimatrix/activist/activities_operation.go b/unimatrix/activist/activities_operation.go new file mode 100644 index 0000000..3ee86c4 --- /dev/null +++ b/unimatrix/activist/activities_operation.go @@ -0,0 +1,7 @@ +package activist + +import "../../unimatrix" + +func NewActivitiesOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "activities") +} diff --git a/unimatrix/activist/activities_schedules_operation.go b/unimatrix/activist/activities_schedules_operation.go new file mode 100644 index 0000000..14f3c50 --- /dev/null +++ b/unimatrix/activist/activities_schedules_operation.go @@ -0,0 +1,7 @@ +package activist + +import "../../unimatrix" + +func NewActivitiesSchedulesOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "activities_schedules") +} diff --git a/unimatrix/activist/tasks_operation.go b/unimatrix/activist/tasks_operation.go new file mode 100644 index 0000000..6193e0a --- /dev/null +++ b/unimatrix/activist/tasks_operation.go @@ -0,0 +1,7 @@ +package activist + +import "../../unimatrix" + +func NewTasksOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "tasks") +} diff --git a/unimatrix/activities_operation.go b/unimatrix/activities_operation.go deleted file mode 100644 index 8f341cf..0000000 --- a/unimatrix/activities_operation.go +++ /dev/null @@ -1,5 +0,0 @@ -package unimatrix - -func NewActivitiesOperation(realm string) *Operation { - return NewRealmOperation(realm, "activities") -} diff --git a/unimatrix/activities_schedules_operation.go b/unimatrix/activities_schedules_operation.go deleted file mode 100644 index 1c6f355..0000000 --- a/unimatrix/activities_schedules_operation.go +++ /dev/null @@ -1,5 +0,0 @@ -package unimatrix - -func NewActivitiesSchedulesOperation(realm string) *Operation { - return NewRealmOperation(realm, "activities_schedules") -} diff --git a/unimatrix/tasks_operation.go b/unimatrix/tasks_operation.go deleted file mode 100644 index 4a3f4cc..0000000 --- a/unimatrix/tasks_operation.go +++ /dev/null @@ -1,5 +0,0 @@ -package unimatrix - -func NewTasksOperation(realm string) *Operation { - return NewRealmOperation(realm, "tasks") -} From 55373961f8374b7998077420193ef043905a8365 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 11:58:26 -0400 Subject: [PATCH 03/20] GS-3 Move archivist operations to archivist namespace --- .../artifact_artifacts_operation.go | 8 +-- .../artifact_components_operation.go | 8 +-- .../archivist/artifact_locators_operation.go | 7 +++ unimatrix/archivist/artifact_resource.go | 49 +++++++++++++++++++ unimatrix/archivist/artifacts_operation.go | 7 +++ .../blueprint_attributes_operation.go | 7 +++ unimatrix/archivist/blueprints_operation.go | 7 +++ unimatrix/artifact_locators_operation.go | 5 -- unimatrix/artifact_resource.go | 43 ---------------- unimatrix/artifacts_operation.go | 5 -- unimatrix/blueprint_attributes_operation.go | 5 -- unimatrix/blueprints_operation.go | 5 -- 12 files changed, 87 insertions(+), 69 deletions(-) rename unimatrix/{ => archivist}/artifact_artifacts_operation.go (57%) rename unimatrix/{ => archivist}/artifact_components_operation.go (57%) create mode 100644 unimatrix/archivist/artifact_locators_operation.go create mode 100644 unimatrix/archivist/artifact_resource.go create mode 100644 unimatrix/archivist/artifacts_operation.go create mode 100644 unimatrix/archivist/blueprint_attributes_operation.go create mode 100644 unimatrix/archivist/blueprints_operation.go delete mode 100644 unimatrix/artifact_locators_operation.go delete mode 100644 unimatrix/artifact_resource.go delete mode 100644 unimatrix/artifacts_operation.go delete mode 100644 unimatrix/blueprint_attributes_operation.go delete mode 100644 unimatrix/blueprints_operation.go diff --git a/unimatrix/artifact_artifacts_operation.go b/unimatrix/archivist/artifact_artifacts_operation.go similarity index 57% rename from unimatrix/artifact_artifacts_operation.go rename to unimatrix/archivist/artifact_artifacts_operation.go index 86a19f4..cdcc4bd 100644 --- a/unimatrix/artifact_artifacts_operation.go +++ b/unimatrix/archivist/artifact_artifacts_operation.go @@ -1,6 +1,8 @@ -package unimatrix +package archivist -func NewArtifactArtifactsOperation(realm, artifactUUID string) *Operation { +import "../../unimatrix" + +func NewArtifactArtifactsOperation(realm, artifactUUID string) *unimatrix.Operation { path := "/realms/" + realm + "/artifacts/" + artifactUUID + "/artifacts" - return NewOperation(path) + return unimatrix.NewOperation(path) } diff --git a/unimatrix/artifact_components_operation.go b/unimatrix/archivist/artifact_components_operation.go similarity index 57% rename from unimatrix/artifact_components_operation.go rename to unimatrix/archivist/artifact_components_operation.go index 97c92c9..e6ad434 100644 --- a/unimatrix/artifact_components_operation.go +++ b/unimatrix/archivist/artifact_components_operation.go @@ -1,6 +1,8 @@ -package unimatrix +package archivist -func NewArtifactComponentsOperation(realm, artifactUUID string) *Operation { +import "../../unimatrix" + +func NewArtifactComponentsOperation(realm, artifactUUID string) *unimatrix.Operation { path := "/realms/" + realm + "/artifacts/" + artifactUUID + "/components" - return NewOperation(path) + return unimatrix.NewOperation(path) } diff --git a/unimatrix/archivist/artifact_locators_operation.go b/unimatrix/archivist/artifact_locators_operation.go new file mode 100644 index 0000000..023c41e --- /dev/null +++ b/unimatrix/archivist/artifact_locators_operation.go @@ -0,0 +1,7 @@ +package archivist + +import "../../unimatrix" + +func NewArtifactLocatorsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "artifact_locators") +} diff --git a/unimatrix/archivist/artifact_resource.go b/unimatrix/archivist/artifact_resource.go new file mode 100644 index 0000000..77969ca --- /dev/null +++ b/unimatrix/archivist/artifact_resource.go @@ -0,0 +1,49 @@ +package archivist + +import "../../unimatrix" + +type Artifact struct { + *unimatrix.Resource +} + +func (resource *Artifact) Relationships(name string) ([]unimatrix.Resource, error) { + if resource.ResourceIndex == nil || resource.AssociationIndex == nil { + return nil, unimatrix.NewUnimatrixError("Unable to retrieve relationships") + } + + var resourceIndex = *resource.ResourceIndex + var associationIndex = *resource.AssociationIndex + var association []unimatrix.Resource + var associationsById = associationIndex["artifacts"][resource.AttributesMap["id"].(string)] + + for _, id := range associationsById["artifact_relationships"] { + relationship := resourceIndex["artifact_relationships"][id] + relationshipName, _ := relationship.AttributeAsString("name") + if relationshipName == name { + association = append(association, relationship) + } + } + return association, nil +} + +func (resource *Artifact) RelatedArtifacts(name string) ([]unimatrix.Resource, error) { + if resource.ResourceIndex == nil || resource.AssociationIndex == nil { + return nil, unimatrix.NewUnimatrixError("Unable to retrieve related artifacts") + } + + var resourceIndex = *resource.ResourceIndex + var associationIndex = *resource.AssociationIndex + var association []unimatrix.Resource + var associationsById = associationIndex["artifacts"][resource.AttributesMap["id"].(string)] + + for _, id := range associationsById["artifact_relationships"] { + relationship := resourceIndex["artifact_relationships"][id] + relationshipName, _ := relationship.AttributeAsString("name") + if relationshipName == name { + relationshipId := relationship.AttributesMap["id"].(string) + relatedId := associationIndex["artifact_relationships"][relationshipId]["artifacts"][0] + association = append(association, resourceIndex["artifacts"][relatedId]) + } + } + return association, nil +} diff --git a/unimatrix/archivist/artifacts_operation.go b/unimatrix/archivist/artifacts_operation.go new file mode 100644 index 0000000..04bcf15 --- /dev/null +++ b/unimatrix/archivist/artifacts_operation.go @@ -0,0 +1,7 @@ +package archivist + +import "../../unimatrix" + +func NewArtifactsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "artifacts") +} diff --git a/unimatrix/archivist/blueprint_attributes_operation.go b/unimatrix/archivist/blueprint_attributes_operation.go new file mode 100644 index 0000000..4508d25 --- /dev/null +++ b/unimatrix/archivist/blueprint_attributes_operation.go @@ -0,0 +1,7 @@ +package archivist + +import "../../unimatrix" + +func NewBlueprintAttributesOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "blueprint_attributes") +} diff --git a/unimatrix/archivist/blueprints_operation.go b/unimatrix/archivist/blueprints_operation.go new file mode 100644 index 0000000..c1776d8 --- /dev/null +++ b/unimatrix/archivist/blueprints_operation.go @@ -0,0 +1,7 @@ +package archivist + +import "../../unimatrix" + +func NewBlueprintsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "blueprints") +} diff --git a/unimatrix/artifact_locators_operation.go b/unimatrix/artifact_locators_operation.go deleted file mode 100644 index 6ac08f9..0000000 --- a/unimatrix/artifact_locators_operation.go +++ /dev/null @@ -1,5 +0,0 @@ -package unimatrix - -func NewArtifactLocatorsOperation(realm string) *Operation { - return NewRealmOperation(realm, "artifact_locators") -} diff --git a/unimatrix/artifact_resource.go b/unimatrix/artifact_resource.go deleted file mode 100644 index 3f7443e..0000000 --- a/unimatrix/artifact_resource.go +++ /dev/null @@ -1,43 +0,0 @@ -package unimatrix - -func (resource *Resource) Relationships(name string) ([]Resource, error) { - if resource.resourceIndex == nil || resource.associationIndex == nil { - return nil, NewUnimatrixError("Unable to retrieve relationships") - } - - var resourceIndex = *resource.resourceIndex - var associationIndex = *resource.associationIndex - var association []Resource - var associationsById = associationIndex["artifacts"][resource.attributes["id"].(string)] - - for _, id := range associationsById["artifact_relationships"] { - relationship := resourceIndex["artifact_relationships"][id] - relationshipName, _ := relationship.AttributeAsString("name") - if relationshipName == name { - association = append(association, relationship) - } - } - return association, nil -} - -func (resource *Resource) RelatedArtifacts(name string) ([]Resource, error) { - if resource.resourceIndex == nil || resource.associationIndex == nil { - return nil, NewUnimatrixError("Unable to retrieve related artifacts") - } - - var resourceIndex = *resource.resourceIndex - var associationIndex = *resource.associationIndex - var association []Resource - var associationsById = associationIndex["artifacts"][resource.attributes["id"].(string)] - - for _, id := range associationsById["artifact_relationships"] { - relationship := resourceIndex["artifact_relationships"][id] - relationshipName, _ := relationship.AttributeAsString("name") - if relationshipName == name { - relationshipId := relationship.attributes["id"].(string) - relatedId := associationIndex["artifact_relationships"][relationshipId]["artifacts"][0] - association = append(association, resourceIndex["artifacts"][relatedId]) - } - } - return association, nil -} diff --git a/unimatrix/artifacts_operation.go b/unimatrix/artifacts_operation.go deleted file mode 100644 index 44101d2..0000000 --- a/unimatrix/artifacts_operation.go +++ /dev/null @@ -1,5 +0,0 @@ -package unimatrix - -func NewArtifactsOperation(realm string) *Operation { - return NewRealmOperation(realm, "artifacts") -} diff --git a/unimatrix/blueprint_attributes_operation.go b/unimatrix/blueprint_attributes_operation.go deleted file mode 100644 index 8d87102..0000000 --- a/unimatrix/blueprint_attributes_operation.go +++ /dev/null @@ -1,5 +0,0 @@ -package unimatrix - -func NewBlueprintAttributesOperation(realm string) *Operation { - return NewRealmOperation(realm, "blueprint_attributes") -} diff --git a/unimatrix/blueprints_operation.go b/unimatrix/blueprints_operation.go deleted file mode 100644 index 03d28cc..0000000 --- a/unimatrix/blueprints_operation.go +++ /dev/null @@ -1,5 +0,0 @@ -package unimatrix - -func NewBlueprintsOperation(realm string) *Operation { - return NewRealmOperation(realm, "blueprints") -} From 8ca74fef7e7689cf026aa7475e0573296e758c62 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 11:59:46 -0400 Subject: [PATCH 04/20] GS-14 Move curator operations to curator namespace --- unimatrix/{ => curator}/sources_operation.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename unimatrix/{ => curator}/sources_operation.go (100%) diff --git a/unimatrix/sources_operation.go b/unimatrix/curator/sources_operation.go similarity index 100% rename from unimatrix/sources_operation.go rename to unimatrix/curator/sources_operation.go From 5548f561c0a5373be49d1e451e088191aed555a7 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:00:42 -0400 Subject: [PATCH 05/20] GS-8 Move distributor operations to distributor namespace --- unimatrix/{ => distributor}/destination_activities_operation.go | 0 unimatrix/{ => distributor}/destinations_operation.go | 0 unimatrix/{ => distributor}/distribution_activities_operation.go | 0 unimatrix/{ => distributor}/distributions_operation.go | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename unimatrix/{ => distributor}/destination_activities_operation.go (100%) rename unimatrix/{ => distributor}/destinations_operation.go (100%) rename unimatrix/{ => distributor}/distribution_activities_operation.go (100%) rename unimatrix/{ => distributor}/distributions_operation.go (100%) diff --git a/unimatrix/destination_activities_operation.go b/unimatrix/distributor/destination_activities_operation.go similarity index 100% rename from unimatrix/destination_activities_operation.go rename to unimatrix/distributor/destination_activities_operation.go diff --git a/unimatrix/destinations_operation.go b/unimatrix/distributor/destinations_operation.go similarity index 100% rename from unimatrix/destinations_operation.go rename to unimatrix/distributor/destinations_operation.go diff --git a/unimatrix/distribution_activities_operation.go b/unimatrix/distributor/distribution_activities_operation.go similarity index 100% rename from unimatrix/distribution_activities_operation.go rename to unimatrix/distributor/distribution_activities_operation.go diff --git a/unimatrix/distributions_operation.go b/unimatrix/distributor/distributions_operation.go similarity index 100% rename from unimatrix/distributions_operation.go rename to unimatrix/distributor/distributions_operation.go From 36ce1d58b2118a0067a5b7808f75805e206200e3 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:01:10 -0400 Subject: [PATCH 06/20] GS-11 Move historian operations to historian namespace --- unimatrix/{ => historian}/histories_operation.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename unimatrix/{ => historian}/histories_operation.go (100%) diff --git a/unimatrix/histories_operation.go b/unimatrix/historian/histories_operation.go similarity index 100% rename from unimatrix/histories_operation.go rename to unimatrix/historian/histories_operation.go From 1e3a02a525f19dc58953f106f19b4840aa7bceea Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:01:57 -0400 Subject: [PATCH 07/20] GS-13 Move portal operations to portal namespace --- unimatrix/{ => portal}/collection_operation.go | 0 unimatrix/{ => portal}/collections_operation.go | 0 unimatrix/{ => portal}/smart_collection_operation.go | 0 unimatrix/{ => portal}/smart_collections_operation.go | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename unimatrix/{ => portal}/collection_operation.go (100%) rename unimatrix/{ => portal}/collections_operation.go (100%) rename unimatrix/{ => portal}/smart_collection_operation.go (100%) rename unimatrix/{ => portal}/smart_collections_operation.go (100%) diff --git a/unimatrix/collection_operation.go b/unimatrix/portal/collection_operation.go similarity index 100% rename from unimatrix/collection_operation.go rename to unimatrix/portal/collection_operation.go diff --git a/unimatrix/collections_operation.go b/unimatrix/portal/collections_operation.go similarity index 100% rename from unimatrix/collections_operation.go rename to unimatrix/portal/collections_operation.go diff --git a/unimatrix/smart_collection_operation.go b/unimatrix/portal/smart_collection_operation.go similarity index 100% rename from unimatrix/smart_collection_operation.go rename to unimatrix/portal/smart_collection_operation.go diff --git a/unimatrix/smart_collections_operation.go b/unimatrix/portal/smart_collections_operation.go similarity index 100% rename from unimatrix/smart_collections_operation.go rename to unimatrix/portal/smart_collections_operation.go From d3d137cd772ae595c59c5a655d845677cc0b18e1 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:02:38 -0400 Subject: [PATCH 08/20] GS-9 Move quartermaster operations to quartermaster namespace --- unimatrix/{ => quartermaster}/binaries_operation.go | 0 unimatrix/{ => quartermaster}/binary_ingressors_operation.go | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename unimatrix/{ => quartermaster}/binaries_operation.go (100%) rename unimatrix/{ => quartermaster}/binary_ingressors_operation.go (100%) diff --git a/unimatrix/binaries_operation.go b/unimatrix/quartermaster/binaries_operation.go similarity index 100% rename from unimatrix/binaries_operation.go rename to unimatrix/quartermaster/binaries_operation.go diff --git a/unimatrix/binary_ingressors_operation.go b/unimatrix/quartermaster/binary_ingressors_operation.go similarity index 100% rename from unimatrix/binary_ingressors_operation.go rename to unimatrix/quartermaster/binary_ingressors_operation.go From daafd3be6e0acf6cbb75b0457e40463781113824 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:03:06 -0400 Subject: [PATCH 09/20] GS-12 Move regent operations to regent namespace --- unimatrix/{ => regent}/realms_operation.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename unimatrix/{ => regent}/realms_operation.go (100%) diff --git a/unimatrix/realms_operation.go b/unimatrix/regent/realms_operation.go similarity index 100% rename from unimatrix/realms_operation.go rename to unimatrix/regent/realms_operation.go From cd6c2b9fa1d0d055c0dbecc142460c07d1db3868 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:37:28 -0400 Subject: [PATCH 10/20] GS-8 Add package to distributor operations --- unimatrix/distributor/destination_activities_operation.go | 8 +++++--- unimatrix/distributor/destinations_operation.go | 8 +++++--- .../distributor/distribution_activities_operation.go | 8 +++++--- unimatrix/distributor/distributions_operation.go | 8 +++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/unimatrix/distributor/destination_activities_operation.go b/unimatrix/distributor/destination_activities_operation.go index c63bc5e..5bc5c5d 100644 --- a/unimatrix/distributor/destination_activities_operation.go +++ b/unimatrix/distributor/destination_activities_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package distributor -func NewDestinationActivitiesOperation(realm string) *Operation { - return NewRealmOperation(realm, "destination_activities") +import "../../unimatrix" + +func NewDestinationActivitiesOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "destination_activities") } diff --git a/unimatrix/distributor/destinations_operation.go b/unimatrix/distributor/destinations_operation.go index 9f1ff7b..b8dd216 100644 --- a/unimatrix/distributor/destinations_operation.go +++ b/unimatrix/distributor/destinations_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package distributor -func NewDestinationsOperation(realm string) *Operation { - return NewRealmOperation(realm, "destinations") +import "../../unimatrix" + +func NewDestinationsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "destinations") } diff --git a/unimatrix/distributor/distribution_activities_operation.go b/unimatrix/distributor/distribution_activities_operation.go index b9d9196..5eea482 100644 --- a/unimatrix/distributor/distribution_activities_operation.go +++ b/unimatrix/distributor/distribution_activities_operation.go @@ -1,6 +1,8 @@ -package unimatrix +package distributor -func NewDistibutionActivitiesOperation(realm, distributionUUID string) *Operation { +import "../../unimatrix" + +func NewDistibutionActivitiesOperation(realm, distributionUUID string) *unimatrix.Operation { path := "/realms/" + realm + "/distributions/" + distributionUUID + "/activities" - return NewOperation(path) + return unimatrix.NewOperation(path) } diff --git a/unimatrix/distributor/distributions_operation.go b/unimatrix/distributor/distributions_operation.go index 9db2fd3..1a7fd93 100644 --- a/unimatrix/distributor/distributions_operation.go +++ b/unimatrix/distributor/distributions_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package distributor -func NewDistributionsOperation(realm string) *Operation { - return NewRealmOperation(realm, "distributions") +import "../../unimatrix" + +func NewDistributionsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "distributions") } From 65c01f3e2cb139ebfaf647eb9cf13abfcfc3ab0d Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:38:16 -0400 Subject: [PATCH 11/20] GS-10 Add package to fabricator operation --- unimatrix/fabricator/fabrications_operation.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unimatrix/fabricator/fabrications_operation.go b/unimatrix/fabricator/fabrications_operation.go index e339bba..df1a83e 100644 --- a/unimatrix/fabricator/fabrications_operation.go +++ b/unimatrix/fabricator/fabrications_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package fabricator -func NewFabricationsOperation(realm string) *Operation { - return NewRealmOperation(realm, "fabrications") +import "../../unimatrix" + +func NewFabricationsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "fabrications") } From 43d22dd208662c1f8a7917a0f53be6ff606df999 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:39:22 -0400 Subject: [PATCH 12/20] GS-11 Add package to historian operations --- unimatrix/historian/histories_operation.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unimatrix/historian/histories_operation.go b/unimatrix/historian/histories_operation.go index 65b826f..f146e71 100644 --- a/unimatrix/historian/histories_operation.go +++ b/unimatrix/historian/histories_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package historian -func NewHistoriesOperation(realm string) *Operation { - return NewRealmOperation(realm, "histories") +import "../../unimatrix" + +func NewHistoriesOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "histories") } From d42f24833593f2f2f0c7b68820aafe5101ea4f53 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:40:52 -0400 Subject: [PATCH 13/20] GS-13 Add package to portal operations --- unimatrix/portal/collection_operation.go | 8 +++++--- unimatrix/portal/collections_operation.go | 8 +++++--- unimatrix/portal/smart_collection_operation.go | 8 +++++--- unimatrix/portal/smart_collections_operation.go | 8 +++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/unimatrix/portal/collection_operation.go b/unimatrix/portal/collection_operation.go index 75ee121..dee7aac 100644 --- a/unimatrix/portal/collection_operation.go +++ b/unimatrix/portal/collection_operation.go @@ -1,6 +1,8 @@ -package unimatrix +package portal -func NewCollectionOperation(realm, collectionID string) *Operation { +import "../../unimatrix" + +func NewCollectionOperation(realm, collectionID string) *unimatrix.Operation { path := "/realms/" + realm + "/collections/" + collectionID - return NewOperation(path) + return unimatrix.NewOperation(path) } diff --git a/unimatrix/portal/collections_operation.go b/unimatrix/portal/collections_operation.go index 02b8e69..dc7356f 100644 --- a/unimatrix/portal/collections_operation.go +++ b/unimatrix/portal/collections_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package portal -func NewCollectionsOperation(realm string) *Operation { - return NewRealmOperation(realm, "collections") +import "../../unimatrix" + +func NewCollectionsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "collections") } diff --git a/unimatrix/portal/smart_collection_operation.go b/unimatrix/portal/smart_collection_operation.go index 70063e3..9e15917 100644 --- a/unimatrix/portal/smart_collection_operation.go +++ b/unimatrix/portal/smart_collection_operation.go @@ -1,6 +1,8 @@ -package unimatrix +package portal -func NewSmartCollectionOperation(realm, smartCollectionID string) *Operation { +import "../../unimatrix" + +func NewSmartCollectionOperation(realm, smartCollectionID string) *unimatrix.Operation { path := "/realms/" + realm + "/smart_collections/" + smartCollectionID - return NewOperation(path) + return unimatrix.NewOperation(path) } diff --git a/unimatrix/portal/smart_collections_operation.go b/unimatrix/portal/smart_collections_operation.go index 778ac8b..93d5af1 100644 --- a/unimatrix/portal/smart_collections_operation.go +++ b/unimatrix/portal/smart_collections_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package portal -func NewSmartCollectionsOperation(realm string) *Operation { - return NewRealmOperation(realm, "smart_collections") +import "../../unimatrix" + +func NewSmartCollectionsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "smart_collections") } From 0bdf8f1fa3b8f8b8d9def09bcb748c9aa61372d0 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:41:33 -0400 Subject: [PATCH 14/20] GS-9 Add package to quartermaster operations --- unimatrix/quartermaster/binaries_operation.go | 8 +++++--- unimatrix/quartermaster/binary_ingressors_operation.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/unimatrix/quartermaster/binaries_operation.go b/unimatrix/quartermaster/binaries_operation.go index 9acad9f..dfee60d 100644 --- a/unimatrix/quartermaster/binaries_operation.go +++ b/unimatrix/quartermaster/binaries_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package quartermaster -func NewBinariesOperation(realm string) *Operation { - return NewRealmOperation(realm, "binaries") +import "../../unimatrix" + +func NewBinariesOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "binaries") } diff --git a/unimatrix/quartermaster/binary_ingressors_operation.go b/unimatrix/quartermaster/binary_ingressors_operation.go index 89f9876..bf4c07c 100644 --- a/unimatrix/quartermaster/binary_ingressors_operation.go +++ b/unimatrix/quartermaster/binary_ingressors_operation.go @@ -1,6 +1,8 @@ -package unimatrix +package quartermaster -func NewBinaryIngressorsOperation(realm, binaryUUID string) *Operation { +import "../../unimatrix" + +func NewBinaryIngressorsOperation(realm, binaryUUID string) *unimatrix.Operation { path := "/realms/" + realm + "/binaries/" + binaryUUID + "/ingressors" - return NewOperation(path) + return unimatrix.NewOperation(path) } From e448d1e24beaa6f6daf65c9809ff17083a355d02 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:42:09 -0400 Subject: [PATCH 15/20] GS-12 Add package to regent operation --- unimatrix/regent/realms_operation.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unimatrix/regent/realms_operation.go b/unimatrix/regent/realms_operation.go index 38d31ed..7cc7519 100644 --- a/unimatrix/regent/realms_operation.go +++ b/unimatrix/regent/realms_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package regent -func NewRealmsOperation(realm string) *Operation { - return NewRealmOperation(realm, "realms") +import "../../unimatrix" + +func NewRealmsOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "realms") } From cfcaa5f3725081750c555380c646c82af4341416 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Wed, 30 May 2018 12:42:42 -0400 Subject: [PATCH 16/20] GS-14 Add package to curator operation --- unimatrix/curator/sources_operation.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unimatrix/curator/sources_operation.go b/unimatrix/curator/sources_operation.go index 3189e7d..05ca46e 100644 --- a/unimatrix/curator/sources_operation.go +++ b/unimatrix/curator/sources_operation.go @@ -1,5 +1,7 @@ -package unimatrix +package curator -func NewSourcesOperation(realm string) *Operation { - return NewRealmOperation(realm, "sources") +import "../../unimatrix" + +func NewSourcesOperation(realm string) *unimatrix.Operation { + return unimatrix.NewRealmOperation(realm, "sources") } From 79d1cb1133ab5b81b13cfb9733300f57345dd4a3 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Thu, 31 May 2018 09:57:01 -0400 Subject: [PATCH 17/20] GS-3 Update archivist examples with artifacts operations --- examples/archivist/querying_for_artifacts/main.go | 6 ++---- examples/archivist/response_metadata/main.go | 6 ++---- examples/archivist/retrieving_artifact/main.go | 6 ++---- .../archivist/retrieving_artifact_associations/main.go | 8 +++----- examples/archivist/retrieving_artifact_errors/main.go | 6 ++---- .../archivist/writing_and_destroying_artifact/main.go | 6 ++---- .../archivist/writing_and_destroying_artifacts/main.go | 6 ++---- examples/archivist/writing_artifact_errors/main.go | 6 ++---- 8 files changed, 17 insertions(+), 33 deletions(-) diff --git a/examples/archivist/querying_for_artifacts/main.go b/examples/archivist/querying_for_artifacts/main.go index 0eb47cc..8c2d2b8 100644 --- a/examples/archivist/querying_for_artifacts/main.go +++ b/examples/archivist/querying_for_artifacts/main.go @@ -4,14 +4,12 @@ import ( "fmt" "../../../unimatrix" + "../../../unimatrix/archivist" ) func main() { unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "5cbc6bb3db90e2f1236e005f9054776c", - "artifacts", - ) + operation := archivist.NewArtifactsOperation("5cbc6bb3db90e2f1236e005f9054776c") // assign query parameters directly with a map[string][]string parameters := map[string][]string{"test": []string{"test_value"}} diff --git a/examples/archivist/response_metadata/main.go b/examples/archivist/response_metadata/main.go index 2890f1a..6bb3609 100644 --- a/examples/archivist/response_metadata/main.go +++ b/examples/archivist/response_metadata/main.go @@ -4,14 +4,12 @@ import ( "fmt" "../../../unimatrix" + "../../../unimatrix/archivist" ) func main() { unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "5cbc6bb3db90e2f1236e005f9054776c", - "artifacts", - ) + operation := archivist.NewArtifactsOperation("5cbc6bb3db90e2f1236e005f9054776c") // create a new query query := unimatrix.NewQuery(). diff --git a/examples/archivist/retrieving_artifact/main.go b/examples/archivist/retrieving_artifact/main.go index add1519..0b55835 100644 --- a/examples/archivist/retrieving_artifact/main.go +++ b/examples/archivist/retrieving_artifact/main.go @@ -4,14 +4,12 @@ import ( "fmt" "../../../unimatrix" + "../../../unimatrix/archivist" ) func main() { unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "artifacts", - ) + operation := archivist.NewArtifactsOperation("1e338862026376dd593425404a4f75c0") query := unimatrix.NewQuery().Where("uuid", "643a9e056300d54eed7a14066513f435") operation.AssignParameters(query.Parameters()) diff --git a/examples/archivist/retrieving_artifact_associations/main.go b/examples/archivist/retrieving_artifact_associations/main.go index 8565439..2e71719 100644 --- a/examples/archivist/retrieving_artifact_associations/main.go +++ b/examples/archivist/retrieving_artifact_associations/main.go @@ -4,14 +4,12 @@ import ( "fmt" "../../../unimatrix" + "../../../unimatrix/archivist" ) func main() { unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "5cbc6bb3db90e2f1236e005f9054776c", - "artifacts", - ) + operation := archivist.NewArtifactsOperation("5cbc6bb3db90e2f1236e005f9054776c") query := unimatrix.NewQuery(). Where("uuid", "0b801213aed8e27a14df83b8dc02e16e"). @@ -21,7 +19,7 @@ func main() { operation.AssignParameters(query.Parameters()) response, _ := operation.Read() resources, _ := response.Resources() - artifact := resources[0] + artifact := archivist.Artifact{&resources[0]} // get all associations as ResourceAssociations type - map[string][]Resource associations, _ := artifact.Associations() diff --git a/examples/archivist/retrieving_artifact_errors/main.go b/examples/archivist/retrieving_artifact_errors/main.go index ba864aa..f62a0b3 100644 --- a/examples/archivist/retrieving_artifact_errors/main.go +++ b/examples/archivist/retrieving_artifact_errors/main.go @@ -4,13 +4,11 @@ import ( "fmt" "../../../unimatrix" + "../../../unimatrix/archivist" ) func main() { - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "artifacts", - ) + operation := archivist.NewArtifactsOperation("1e338862026376dd593425404a4f75c0") query := unimatrix.NewQuery(). Where("uuid", "does-not-exist") diff --git a/examples/archivist/writing_and_destroying_artifact/main.go b/examples/archivist/writing_and_destroying_artifact/main.go index 8eaa5c3..0b86494 100644 --- a/examples/archivist/writing_and_destroying_artifact/main.go +++ b/examples/archivist/writing_and_destroying_artifact/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/archivist" ) func main() { @@ -18,10 +19,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "artifacts", - ) + operation := archivist.NewArtifactsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) // create artifact diff --git a/examples/archivist/writing_and_destroying_artifacts/main.go b/examples/archivist/writing_and_destroying_artifacts/main.go index cba6670..70a94a2 100644 --- a/examples/archivist/writing_and_destroying_artifacts/main.go +++ b/examples/archivist/writing_and_destroying_artifacts/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/archivist" ) func main() { @@ -18,10 +19,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "artifacts", - ) + operation := archivist.NewArtifactsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) // create artifacts diff --git a/examples/archivist/writing_artifact_errors/main.go b/examples/archivist/writing_artifact_errors/main.go index 2d7b6d0..e9284a1 100644 --- a/examples/archivist/writing_artifact_errors/main.go +++ b/examples/archivist/writing_artifact_errors/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/archivist" ) func main() { @@ -12,10 +13,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "artifacts", - ) + operation := archivist.NewArtifactsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) // create artifact From 8b28a950992d035eaa62c275dca67c93a78be302 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Thu, 31 May 2018 09:57:25 -0400 Subject: [PATCH 18/20] GS-3 Update sample controllers with artifacts operations --- samples/assets_controller/main.go | 3 ++- samples/genres_controller/main.go | 3 ++- samples/schedules_controller/main.go | 6 ++++-- samples/search_controller/main.go | 3 ++- samples/stations_controller/main.go | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/samples/assets_controller/main.go b/samples/assets_controller/main.go index 9549996..5a36e9a 100644 --- a/samples/assets_controller/main.go +++ b/samples/assets_controller/main.go @@ -5,6 +5,7 @@ import ( "os" "../../unimatrix" + "../../unimatrix/archivist" ) // Test Command @@ -23,7 +24,7 @@ func main() { assetUuid := os.Args[2] // Read - operation := unimatrix.NewRealmOperation(realmUuid, "artifacts") + operation := archivist.NewArtifactsOperation(realmUuid) query := unimatrix.NewQuery(). Where("type_name", "asset_artifact"). diff --git a/samples/genres_controller/main.go b/samples/genres_controller/main.go index 03188c4..6abebaf 100644 --- a/samples/genres_controller/main.go +++ b/samples/genres_controller/main.go @@ -5,6 +5,7 @@ import ( "os" "../../unimatrix" + "../../unimatrix/archivist" ) // Test Command @@ -22,7 +23,7 @@ func main() { realmUuid := os.Args[1] // Query - operation := unimatrix.NewRealmOperation(realmUuid, "artifacts") + operation := archivist.NewArtifactsOperation(realmUuid) query := unimatrix.NewQuery(). Where("type_name", "genre_artifact") diff --git a/samples/schedules_controller/main.go b/samples/schedules_controller/main.go index 45e7d44..7f139d5 100644 --- a/samples/schedules_controller/main.go +++ b/samples/schedules_controller/main.go @@ -6,6 +6,7 @@ import ( "strings" "../../unimatrix" + "../../unimatrix/archivist" ) // Test Command @@ -40,7 +41,7 @@ func main() { } // Query - operation := unimatrix.NewRealmOperation(realmUuid, "artifacts") + operation := archivist.NewArtifactsOperation(realmUuid) // - Filtered by Stations query := unimatrix.NewQuery(). @@ -67,7 +68,8 @@ func main() { var stationScheduleEvents = make(map[string][]unimatrix.Resource) for _, resource := range resources { - categories, _ := resource.RelatedArtifacts("category") + artifact := archivist.Artifact{&resource} + categories, _ := artifact.RelatedArtifacts("category") category := categories[0] typeName, _ := category.AttributeAsString("type_name") diff --git a/samples/search_controller/main.go b/samples/search_controller/main.go index ef45dea..b3e5f3d 100644 --- a/samples/search_controller/main.go +++ b/samples/search_controller/main.go @@ -6,6 +6,7 @@ import ( "strings" "../../unimatrix" + "../../unimatrix/archivist" ) // Test Command @@ -78,7 +79,7 @@ func main() { } // Search Query - operation := unimatrix.NewRealmOperation(realmUuid, "artifacts") + operation := archivist.NewArtifactsOperation(realmUuid) resourceTypePresent := false diff --git a/samples/stations_controller/main.go b/samples/stations_controller/main.go index 32dc18a..9433a83 100644 --- a/samples/stations_controller/main.go +++ b/samples/stations_controller/main.go @@ -5,6 +5,7 @@ import ( "os" "../../unimatrix" + "../../unimatrix/archivist" ) // Test Commands @@ -29,7 +30,7 @@ func main() { } // Query - operation := unimatrix.NewRealmOperation(realmUuid, "artifacts") + operation := archivist.NewArtifactsOperation(realmUuid) queryType := "Query" query := unimatrix.NewQuery(). From 80663cae9126b6ed94c1be4b16cac7ea8a3dc032 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Thu, 31 May 2018 10:00:31 -0400 Subject: [PATCH 19/20] GS-8 Update distributor examples with distribution/destination operations --- .../distributing_and_removing_artifact/main.go | 12 ++++-------- .../distributor/querying_for_destinations/main.go | 6 ++---- .../distributor/querying_for_distributions/main.go | 6 ++---- examples/distributor/response_metadata/main.go | 6 ++---- examples/distributor/retrieving_destination/main.go | 6 ++---- examples/distributor/retrieving_distribution/main.go | 6 ++---- .../writing_and_destroying_destination/main.go | 6 ++---- 7 files changed, 16 insertions(+), 32 deletions(-) diff --git a/examples/distributor/distributing_and_removing_artifact/main.go b/examples/distributor/distributing_and_removing_artifact/main.go index c614fb3..51b1e2c 100644 --- a/examples/distributor/distributing_and_removing_artifact/main.go +++ b/examples/distributor/distributing_and_removing_artifact/main.go @@ -6,6 +6,8 @@ import ( "time" "../../../unimatrix" + "../../../unimatrix/archivist" + "../../../unimatrix/distributor" ) func main() { @@ -19,10 +21,7 @@ func main() { // new artifact operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - artifactOperation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "artifacts", - ) + artifactOperation := archivist.NewArtifactsOperation("1e338862026376dd593425404a4f75c0") artifactOperation.SetAccessToken(accessToken) // create artifact for distribution @@ -42,10 +41,7 @@ func main() { // new distribution operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - distributionOperation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "distributions", - ) + distributionOperation := distributor.NewDistributionsOperation("1e338862026376dd593425404a4f75c0") distributionOperation.SetAccessToken(accessToken) // create distribution diff --git a/examples/distributor/querying_for_destinations/main.go b/examples/distributor/querying_for_destinations/main.go index ea564ae..88987dc 100644 --- a/examples/distributor/querying_for_destinations/main.go +++ b/examples/distributor/querying_for_destinations/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/distributor" ) func main() { @@ -18,10 +19,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "destinations", - ) + operation := distributor.NewDestinationsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) // query := unimatrix.NewQuery() diff --git a/examples/distributor/querying_for_distributions/main.go b/examples/distributor/querying_for_distributions/main.go index 07b79a6..8713ee5 100644 --- a/examples/distributor/querying_for_distributions/main.go +++ b/examples/distributor/querying_for_distributions/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/distributor" ) func main() { @@ -18,10 +19,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "distributions", - ) + operation := distributor.NewDistributionsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) // query := unimatrix.NewQuery() diff --git a/examples/distributor/response_metadata/main.go b/examples/distributor/response_metadata/main.go index 6b388b6..7ef37f0 100644 --- a/examples/distributor/response_metadata/main.go +++ b/examples/distributor/response_metadata/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/distributor" ) func main() { @@ -18,10 +19,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "destinations", - ) + operation := distributor.NewDestinationsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) response, _ := operation.Read() diff --git a/examples/distributor/retrieving_destination/main.go b/examples/distributor/retrieving_destination/main.go index d92d7c1..83b2f44 100644 --- a/examples/distributor/retrieving_destination/main.go +++ b/examples/distributor/retrieving_destination/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/distributor" ) func main() { @@ -18,10 +19,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "destinations", - ) + operation := distributor.NewDestinationsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) query := unimatrix.NewQuery(). diff --git a/examples/distributor/retrieving_distribution/main.go b/examples/distributor/retrieving_distribution/main.go index a2bbf09..795942e 100644 --- a/examples/distributor/retrieving_distribution/main.go +++ b/examples/distributor/retrieving_distribution/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/distributor" ) func main() { @@ -18,10 +19,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "distributions", - ) + operation := distributor.NewDistributionsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) query := unimatrix.NewQuery(). diff --git a/examples/distributor/writing_and_destroying_destination/main.go b/examples/distributor/writing_and_destroying_destination/main.go index cf1acfb..0557be6 100644 --- a/examples/distributor/writing_and_destroying_destination/main.go +++ b/examples/distributor/writing_and_destroying_destination/main.go @@ -5,6 +5,7 @@ import ( "os" "../../../unimatrix" + "../../../unimatrix/distributor" ) func main() { @@ -18,10 +19,7 @@ func main() { // new operation unimatrix.SetURL("http://us-west-2.api.acceptance.unimatrix.io") - operation := unimatrix.NewRealmOperation( - "1e338862026376dd593425404a4f75c0", - "destinations", - ) + operation := distributor.NewDestinationsOperation("1e338862026376dd593425404a4f75c0") operation.SetAccessToken(accessToken) // create destination From 8c2835bb1388aebcd36a2fa541ad72d33e6aeeb6 Mon Sep 17 00:00:00 2001 From: Chris Roggi Date: Thu, 31 May 2018 10:11:15 -0400 Subject: [PATCH 20/20] GS-16 Allow other packages to access resource fields --- unimatrix/resource.go | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/unimatrix/resource.go b/unimatrix/resource.go index a33aa6c..80c5ae8 100644 --- a/unimatrix/resource.go +++ b/unimatrix/resource.go @@ -12,11 +12,11 @@ type ResourceError struct { } type Resource struct { - name string - attributes map[string]interface{} + Name string + AttributesMap map[string]interface{} rawAttributes *json.RawMessage - resourceIndex *ResourceIndex - associationIndex *AssociationIndex + ResourceIndex *ResourceIndex + AssociationIndex *AssociationIndex resourceErrors *[]ResourceError } @@ -38,20 +38,20 @@ func NewResource(name string, attributesInterface interface{}) *Resource { } return &Resource{ - name: name, - attributes: attributes, + Name: name, + AttributesMap: attributes, rawAttributes: rawAttributes, } } func (resource *Resource) AddAssociationIndices(resourceIndex *ResourceIndex, associationIndex *AssociationIndex, resourceErrors *[]ResourceError) { - resource.resourceIndex = resourceIndex - resource.associationIndex = associationIndex + resource.ResourceIndex = resourceIndex + resource.AssociationIndex = associationIndex resource.resourceErrors = resourceErrors } func (resource *Resource) UUID() (string, error) { - if uuid, ok := resource.attributes["uuid"].(string); ok { + if uuid, ok := resource.AttributesMap["uuid"].(string); ok { return uuid, nil } else { return "", NewUnimatrixError("Unable to retrieve UUID") @@ -67,15 +67,15 @@ func (resource *Resource) RawAttributes() (*json.RawMessage, error) { } func (resource *Resource) Attributes() (map[string]interface{}, error) { - if resource.attributes != nil { - return resource.attributes, nil + if resource.AttributesMap != nil { + return resource.AttributesMap, nil } else { return nil, NewUnimatrixError("Unable to retrieve attributes") } } func (resource *Resource) AttributeAsString(name string) (string, error) { - if attribute, ok := resource.attributes[name].(string); ok { + if attribute, ok := resource.AttributesMap[name].(string); ok { return attribute, nil } else { return "", NewUnimatrixError("Unable to retrieve attribute as string") @@ -83,7 +83,7 @@ func (resource *Resource) AttributeAsString(name string) (string, error) { } func (resource *Resource) AttributeAsArray(name string) ([]string, error) { - if attribute, ok := resource.attributes[name].([]string); ok { + if attribute, ok := resource.AttributesMap[name].([]string); ok { return attribute, nil } else { return nil, NewUnimatrixError("Unable to retrieve attribute as array") @@ -91,7 +91,7 @@ func (resource *Resource) AttributeAsArray(name string) ([]string, error) { } func (resource *Resource) AttributeAsMap(name string) (map[string]interface{}, error) { - if attribute, ok := resource.attributes[name].(map[string]interface{}); ok { + if attribute, ok := resource.AttributesMap[name].(map[string]interface{}); ok { for key, value := range attribute { if attribute[key], ok = value.(string); !ok { return nil, NewUnimatrixError("Unable to retrieve attribute as map with string values") @@ -104,21 +104,21 @@ func (resource *Resource) AttributeAsMap(name string) (map[string]interface{}, e } func (resource *Resource) SetAttribute(name string, value interface{}) { - resource.attributes[name] = value + resource.AttributesMap[name] = value } func (resource *Resource) Errors() ([]ResourceError, error) { - if resource.resourceErrors == nil || resource.associationIndex == nil { + if resource.resourceErrors == nil || resource.AssociationIndex == nil { return nil, NewUnimatrixError("Unable to retrieve errors") } - var associationIndex = *resource.associationIndex + var associationIndex = *resource.AssociationIndex var resourceErrors = *resource.resourceErrors var errors []ResourceError - if len(associationIndex[resource.name][resource.attributes["id"].(string)]["errors"]) > 0 { + if len(associationIndex[resource.Name][resource.AttributesMap["id"].(string)]["errors"]) > 0 { for _, error := range resourceErrors { - for _, errorId := range associationIndex[resource.name][resource.attributes["id"].(string)]["errors"] { + for _, errorId := range associationIndex[resource.Name][resource.AttributesMap["id"].(string)]["errors"] { if error.Id == errorId { errors = append(errors, error) break @@ -131,14 +131,14 @@ func (resource *Resource) Errors() ([]ResourceError, error) { } func (resource *Resource) Associations() (ResourceAssociations, error) { - if resource.resourceIndex == nil || resource.associationIndex == nil { + if resource.ResourceIndex == nil || resource.AssociationIndex == nil { return nil, NewUnimatrixError("Unable to retrieve associations") } - var resourceIndex = *resource.resourceIndex - var associationIndex = *resource.associationIndex + var resourceIndex = *resource.ResourceIndex + var associationIndex = *resource.AssociationIndex var associations = make(ResourceAssociations) - var associationsById = associationIndex[resource.name][resource.attributes["id"].(string)] + var associationsById = associationIndex[resource.Name][resource.AttributesMap["id"].(string)] for associationType, ids := range associationsById { for _, id := range ids { @@ -150,14 +150,14 @@ func (resource *Resource) Associations() (ResourceAssociations, error) { } func (resource *Resource) Association(name string) ([]Resource, error) { - if resource.resourceIndex == nil || resource.associationIndex == nil { + if resource.ResourceIndex == nil || resource.AssociationIndex == nil { return nil, NewUnimatrixError("Unable to retrieve association") } - var resourceIndex = *resource.resourceIndex - var associationIndex = *resource.associationIndex + var resourceIndex = *resource.ResourceIndex + var associationIndex = *resource.AssociationIndex var association []Resource - var associationsById = associationIndex[resource.name][resource.attributes["id"].(string)] + var associationsById = associationIndex[resource.Name][resource.AttributesMap["id"].(string)] for _, id := range associationsById[name] { association = append(association, resourceIndex[name][id])