public static async Task <HttpResponseMessage> SetParentFolder(this OsdrWebClient client, Guid fileId, int version, Guid folderId)
        {
            var url  = $"/api/entities/files/{fileId}?version={version}";
            var data = $"[{{'op':'replace','path':'ParentId','value':'{folderId}'}}]";

            return(await client.PatchData(url, data));
        }
        public static async Task <HttpResponseMessage> SetPublicFileEntity(this OsdrWebClient client, Guid fileId, int version, bool isPublic)
        {
            var url  = $"/api/entities/files/{fileId}?version={version}";
            var data = $"[{{'op':'replace','path':'/Permissions/IsPublic','value':{isPublic.ToString().ToLower()}}}]";

            return(await client.PatchData(url, data));
        }
        public static async Task <HttpResponseMessage> SetFileName(this OsdrWebClient client, Guid fileId, int version, string name)
        {
            var url  = $"/api/entities/files/{fileId}?version={version}";
            var data = $"[{{'op':'replace','path':'Name','value':'{name}'}}]";

            return(await client.PatchData(url, data));
        }
        private async Task <IEnumerable <Guid> > GetNodeIdsForCategory(OsdrWebClient client, Guid categoryId)
        {
            var response = await client.GetData($"/api/categorytrees/tree/{categoryId}");

            response.EnsureSuccessStatusCode();
            var json = await response.Content.ReadAsStringAsync();

            json = json.Replace("_id", "id");
            var treeJson = JsonConvert.DeserializeObject <Dictionary <string, object> >(json)["nodes"].ToString();
            var tree     = JsonConvert.DeserializeObject <List <TreeNode> >(treeJson);

            return(tree.GetNodeIds());
        }
Beispiel #5
0
        public static async Task <HttpResponseMessage> MachineLearningPredict(this OsdrWebClient client,
                                                                              Guid parentId, Guid modelBlobId, Guid datasetBlobId, Guid userId, string datasetBucket, Guid modelBucket, string folderName)
        {
            var postData = $@"
			{{
				'TargetFolderId': '{parentId}',
				'DatasetBlobId': '{datasetBlobId}',
				'DatasetBucket': '{datasetBucket}',
				'ModelBlobId': '{modelBlobId}',
				'ModelBucket': '{modelBucket}',
				'UserId': '{userId}'
			}}"            ;

            return(await client.PostData("/api/machinelearning/predictions", postData));
        }
Beispiel #6
0
        public static async Task <HttpResponseMessage> GetNodes(this OsdrWebClient client, string filter = null, string projection = null)
        {
            var stringProjection = "";

            if (projection != null)
            {
                stringProjection = $"&$projection={projection}";
            }

            if (filter != null)
            {
                return(await client.GetData($"api/nodes?$filter={filter}{stringProjection}"));
            }

            return(await client.GetData($"api/nodes"));
        }
Beispiel #7
0
        public OsdrTestHarness() : base()
        {
            var token = keycloak.GetToken("john", "qqq123").Result;

            JohnClient = new HttpClient();
            JohnClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);

            token = keycloak.GetToken("jane", "qqq123").Result;

            JaneClient = new HttpClient();
            JaneClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);

            UnauthorizedClient = new HttpClient();

            JohnApi         = new OsdrWebClient(JohnClient);
            JaneApi         = new OsdrWebClient(JaneClient);
            UnauthorizedApi = new OsdrWebClient(UnauthorizedClient);
        }
        public static async Task <HttpResponseMessage> GetPublicEntity(this OsdrWebClient client, string type,
                                                                       int pageNumber = 1, int pageSize = 20, string filter = null, string projection = null)
        {
            HttpResponseMessage response = null;
            var stringProjection         = "";

            if (projection != null)
            {
                stringProjection = $"&$projection={projection}";
            }

            if (filter != null)
            {
                response = await client.GetData($"/api/entities/{type}/public?PageNumber={pageNumber}&PageSize={pageSize}&$filter={filter}{stringProjection}");
            }
            else
            {
                response = await client.GetData($"/api/entities/{type}/public?PageNumber={pageNumber}&PageSize={pageSize}&{stringProjection}");
            }

            return(response);
        }
Beispiel #9
0
        public static async Task <HttpResponseMessage> MachineLearningTrain(this OsdrWebClient client,
                                                                            Guid sourceBlobId, string sourceBucket, Guid userId, Guid parentId, bool optimize)
        {
            var folderId      = Guid.NewGuid();
            var createMLModel = new CreateMachineLearningModel
            {
                TargetFolderId = folderId,
                SourceBlobId   = sourceBlobId,
                Scaler         = "some sting named as Scaler",
                SourceBucket   = sourceBucket,
                UserId         = userId,
                SourceFileName = "combined lysomotrophic.sdf",
                Methods        = new List <string> {
                    "NaiveBayes"
                },
                TrainingParameter = "Soluble",
                SubSampleSize     = 1,
                TestDataSize      = new decimal(.1),
                KFold             = 2,
                ModelType         = "Classification",
                Fingerprints      = new List <Fingerprint>
                {
                    new Fingerprint {
                        Type   = "ecfp",
                        Radius = 2,
                        Size   = 512
                    }
                },
                Optimize = optimize
            };

            var postParameters = JsonConvert.SerializeObject(createMLModel);

            var response = await client.PostData("/api/machinelearning/models", postParameters);

            return(response);
        }
 public static async Task <HttpResponseMessage> GetFolder(this OsdrWebClient client, Guid id)
 {
     return(await client.GetData($"api/entities/folders/{id}"));
 }
 public static async Task <HttpResponseMessage> RenameFolder(this OsdrWebClient client, Guid id, string newName)
 {
     return(await client.PatchData($"api/entities/folders/{id}?version=1", $"[{{op: 'replace', path: '/name', value: '{newName}'}}]"));
 }
 public static async Task <HttpResponseMessage> GetRecordEntityById(this OsdrWebClient client, Guid id)
 {
     return(await client.GetData($"/api/entities/records/{id}"));
 }
 public static async Task <HttpResponseMessage> CreateFolderEntity(this OsdrWebClient client, Guid parentNodeId, string name)
 {
     return(await client.PostData("api/entities/folders", $"{{'Name': '{name}', parentId: '{parentNodeId}'}}"));
 }
 public static async Task <HttpResponseMessage> GetEntitiesMe(this OsdrWebClient client, string type)
 {
     return(await client.GetData($"api/entities/{type}/me"));
 }
 public static async Task <HttpResponseMessage> GetFolderEntityById(this OsdrWebClient client, Guid id)
 {
     return(await client.GetEntityById("Folders", id));
 }
 public static async Task <HttpResponseMessage> GetBlobFileEntityById(this OsdrWebClient client, Guid fileId, Guid blobId)
 {
     return(await GetBlobById(client, "files", fileId, blobId));
 }
Beispiel #17
0
        public static async Task <HttpResponseMessage> GetUserMe(this OsdrWebClient client)
        {
            var response = await client.GetData("api/me");

            return(response);
        }
Beispiel #18
0
 public static async Task <HttpResponseMessage> DeleteFolder(this OsdrWebClient client, Guid id, int version)
 {
     return(await client.PatchData("api/nodecollections", $@"[{{'op': 'add','path':'/deleted','value':[{{'id':'{id}','version':{version},'type':'Folder'}}]}}]"));
 }
Beispiel #19
0
        public static async Task <HttpResponseMessage> GetUserPublicInfoById(this OsdrWebClient client, Guid userId)
        {
            var response = await client.GetData($"api/users/{userId}/public-info");

            return(response);
        }
 public static async Task <HttpResponseMessage> GetStreamFolderEntityById(this OsdrWebClient client, Guid folderId, int start = 1, int count = -1)
 {
     return(await GetStreamById(client, "folders", folderId, start, count));
 }
 public static async Task <HttpResponseMessage> GetStreamRecordEntityById(this OsdrWebClient client, Guid recordId, int start = 0, int count = -1)
 {
     return(await GetStreamById(client, "records", recordId, start, count));
 }
 public static async Task <HttpResponseMessage> GetStreamFileEntityById(this OsdrWebClient client, Guid fileId, int start = 0, int count = -1)
 {
     return(await GetStreamById(client, "files", fileId, start, count));
 }
 public static async Task <HttpResponseMessage> GetEntitiesFolders(this OsdrWebClient client)
 {
     return(await client.GetData("api/entities/folders/me"));
 }
 public static async Task <HttpResponseMessage> GetBlobFileMetadataById(this OsdrWebClient client, Guid fileId, Guid blobId)
 {
     return(await client.GetData($"/api/entities/files/{fileId}/blobs/{blobId}/info"));
 }
 public static async Task <HttpResponseMessage> GetUserEntityById(this OsdrWebClient client, Guid userId)
 {
     return(await GetEntityById(client, "users", userId));
 }
 public static async Task <HttpResponseMessage> GetBlobRecordEntityById(this OsdrWebClient client, Guid recordId, Guid blobId)
 {
     return(await GetBlobById(client, "records", recordId, blobId));
 }
 public static async Task <HttpResponseMessage> GetImagesFileEntityById(this OsdrWebClient client, Guid fileId, Guid imageId)
 {
     return(await GetImagesById(client, "files", fileId, imageId));
 }
 public static async Task <HttpResponseMessage> GetStreamById(this OsdrWebClient client, string type, Guid id, int start = 0, int count = -1)
 {
     return(await client.GetData($"/api/entities/{type}/{id}/stream?Start={start}&Count={count}"));
 }
 public static async Task <HttpResponseMessage> GetEntityById(this OsdrWebClient client, string type, Guid id)
 {
     return(await client.GetData($"/api/entities/{type}/{id}"));
 }
 public static async Task <HttpResponseMessage> GetImagesRecordEntityById(this OsdrWebClient client, Guid recordId, Guid imageId)
 {
     return(await GetImagesById(client, "records", recordId, imageId));
 }