public override Task <UpdateArtifactResponse> UpdateArtifact(UpdateArtifactRequest artifactRequest, ServerCallContext ctx) { _log.Info("gRpc request for: UpdateArtifact"); return(Task.FromResult(ModelManager.UpdateArtifact(artifactRequest))); }
internal static void UpdateArtifact(ArtifactType type, string folderName) { Log.Error("Updating: " + type + " name = " + folderName); var path = ArtifactPath + FolderSeparator + folderName; if (Directory.Exists(path)) { var artifactFolder = new DirectoryInfo(path); Log.Info("Loading Updated Artifact From: " + artifactFolder.Name); var bJson = artifactFolder.GetFiles("*.json"); //eventually load the proto and md as well. var updateArtifactRequest = new UpdateArtifactRequest { Type = type }; switch (type) { case ArtifactType.Base: try { var baseType = GetArtifact <Base>(bJson[0]); updateArtifactRequest.ArtifactTypeObject = Any.Pack(baseType); var response = Client.TaxonomyClient.UpdateArtifact(updateArtifactRequest); Log.Info("Updated: " + response.Updated); } catch (Exception e) { Log.Error("Failed to load base token type: " + artifactFolder.Name); Log.Error(e); } break; case ArtifactType.Behavior: try { var typeFromJson = GetArtifact <Behavior>(bJson[0]); updateArtifactRequest.ArtifactTypeObject = Any.Pack(typeFromJson); var response = Client.TaxonomyClient.UpdateArtifact(updateArtifactRequest); Log.Info("Updated: " + response.Updated); } catch (Exception e) { Log.Error("Failed to load/update type: " + type + " name = " + artifactFolder.Name); Log.Error(e); } break; case ArtifactType.BehaviorGroup: try { var typeFromJson = GetArtifact <BehaviorGroup>(bJson[0]); updateArtifactRequest.ArtifactTypeObject = Any.Pack(typeFromJson); var response = Client.TaxonomyClient.UpdateArtifact(updateArtifactRequest); Log.Info("Updated: " + response.Updated); } catch (Exception e) { Log.Error("Failed to load/update type: " + type + " name = " + artifactFolder.Name); Log.Error(e); } break; case ArtifactType.PropertySet: try { var typeFromJson = GetArtifact <PropertySet>(bJson[0]); updateArtifactRequest.ArtifactTypeObject = Any.Pack(typeFromJson); var response = Client.TaxonomyClient.UpdateArtifact(updateArtifactRequest); Log.Info("Updated: " + response.Updated); } catch (Exception e) { Log.Error("Failed to load/update type: " + type + " name = " + artifactFolder.Name); Log.Error(e); } break; case ArtifactType.TokenTemplate: try { var typeFromJson = GetArtifact <TokenTemplate>(bJson[0]); updateArtifactRequest.ArtifactTypeObject = Any.Pack(typeFromJson); var response = Client.TaxonomyClient.UpdateArtifact(updateArtifactRequest); Log.Info("Updated: " + response.Updated); } catch (Exception e) { Log.Error("Failed to load/update type: " + type + " name = " + artifactFolder.Name); Log.Error(e); } break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } } else { Log.Warn("Local Artifact Folder: " + path + " NOT FOUND."); } }