コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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());
        }
コード例 #5
0
ファイル: MLControllerExtension.cs プロジェクト: xlgwr/osdr
        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));
        }
コード例 #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"));
        }
コード例 #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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: MLControllerExtension.cs プロジェクト: xlgwr/osdr
        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);
        }
コード例 #10
0
 public static async Task <HttpResponseMessage> GetFolder(this OsdrWebClient client, Guid id)
 {
     return(await client.GetData($"api/entities/folders/{id}"));
 }
コード例 #11
0
 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}'}}]"));
 }
コード例 #12
0
 public static async Task <HttpResponseMessage> GetRecordEntityById(this OsdrWebClient client, Guid id)
 {
     return(await client.GetData($"/api/entities/records/{id}"));
 }
コード例 #13
0
 public static async Task <HttpResponseMessage> CreateFolderEntity(this OsdrWebClient client, Guid parentNodeId, string name)
 {
     return(await client.PostData("api/entities/folders", $"{{'Name': '{name}', parentId: '{parentNodeId}'}}"));
 }
コード例 #14
0
 public static async Task <HttpResponseMessage> GetEntitiesMe(this OsdrWebClient client, string type)
 {
     return(await client.GetData($"api/entities/{type}/me"));
 }
コード例 #15
0
 public static async Task <HttpResponseMessage> GetFolderEntityById(this OsdrWebClient client, Guid id)
 {
     return(await client.GetEntityById("Folders", id));
 }
コード例 #16
0
 public static async Task <HttpResponseMessage> GetBlobFileEntityById(this OsdrWebClient client, Guid fileId, Guid blobId)
 {
     return(await GetBlobById(client, "files", fileId, blobId));
 }
コード例 #17
0
        public static async Task <HttpResponseMessage> GetUserMe(this OsdrWebClient client)
        {
            var response = await client.GetData("api/me");

            return(response);
        }
コード例 #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'}}]}}]"));
 }
コード例 #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);
        }
コード例 #20
0
 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));
 }
コード例 #21
0
 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));
 }
コード例 #22
0
 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));
 }
コード例 #23
0
 public static async Task <HttpResponseMessage> GetEntitiesFolders(this OsdrWebClient client)
 {
     return(await client.GetData("api/entities/folders/me"));
 }
コード例 #24
0
 public static async Task <HttpResponseMessage> GetBlobFileMetadataById(this OsdrWebClient client, Guid fileId, Guid blobId)
 {
     return(await client.GetData($"/api/entities/files/{fileId}/blobs/{blobId}/info"));
 }
コード例 #25
0
 public static async Task <HttpResponseMessage> GetUserEntityById(this OsdrWebClient client, Guid userId)
 {
     return(await GetEntityById(client, "users", userId));
 }
コード例 #26
0
 public static async Task <HttpResponseMessage> GetBlobRecordEntityById(this OsdrWebClient client, Guid recordId, Guid blobId)
 {
     return(await GetBlobById(client, "records", recordId, blobId));
 }
コード例 #27
0
 public static async Task <HttpResponseMessage> GetImagesFileEntityById(this OsdrWebClient client, Guid fileId, Guid imageId)
 {
     return(await GetImagesById(client, "files", fileId, imageId));
 }
コード例 #28
0
 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}"));
 }
コード例 #29
0
 public static async Task <HttpResponseMessage> GetEntityById(this OsdrWebClient client, string type, Guid id)
 {
     return(await client.GetData($"/api/entities/{type}/{id}"));
 }
コード例 #30
0
 public static async Task <HttpResponseMessage> GetImagesRecordEntityById(this OsdrWebClient client, Guid recordId, Guid imageId)
 {
     return(await GetImagesById(client, "records", recordId, imageId));
 }