public void FolderPutCreateFolderTest()
        {
            var path = Path.Combine(TempFolderPath, "TestFolder0");

            //PutCreate folder
            var request = new PutCreateFolderRequest();

            request.Path        = path;
            request.Storage     = StorageName;
            request.DestStorage = StorageName;
            CreateFolderResponse response = null;

            try
            {
                response = StorageApi.PutCreateFolder(request);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains("not supported"), ex.Message);
                return;
            }

            Assert.AreEqual(200, response.Code);

            //The folder should exists on path
            var fileExist = FileExist(StorageName, path);

            Assert.IsTrue((bool)fileExist.IsExist);
            Assert.IsTrue((bool)fileExist.IsFolder);
        }
Esempio n. 2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateFolderResponse response = new CreateFolderResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Arn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Arn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("FolderId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.FolderId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("RequestId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RequestId = unmarshaller.Unmarshall(context);
                    continue;
                }
            }
            response.Status = (int)context.ResponseData.StatusCode;

            return(response);
        }
        public static CreateFolderResponse Unmarshall(UnmarshallerContext context)
        {
            CreateFolderResponse createFolderResponse = new CreateFolderResponse();

            createFolderResponse.HttpResponse = context.HttpResponse;
            createFolderResponse.RequestId    = context.StringValue("CreateFolder.RequestId");
            createFolderResponse.FolderId     = context.LongValue("CreateFolder.FolderId");

            return(createFolderResponse);
        }
        public static CreateFolderResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateFolderResponse createFolderResponse = new CreateFolderResponse();

            createFolderResponse.HttpResponse   = _ctx.HttpResponse;
            createFolderResponse.RequestId      = _ctx.StringValue("CreateFolder.RequestId");
            createFolderResponse.Success        = _ctx.BooleanValue("CreateFolder.Success");
            createFolderResponse.ErrorCode      = _ctx.StringValue("CreateFolder.ErrorCode");
            createFolderResponse.ErrorMessage   = _ctx.StringValue("CreateFolder.ErrorMessage");
            createFolderResponse.Data           = _ctx.StringValue("CreateFolder.Data");
            createFolderResponse.HttpStatusCode = _ctx.IntegerValue("CreateFolder.HttpStatusCode");

            return(createFolderResponse);
        }
Esempio n. 5
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateFolderResponse response = new CreateFolderResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Metadata", targetDepth))
                {
                    var unmarshaller = FolderMetadataUnmarshaller.Instance;
                    response.Metadata = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a new folder
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="userId"></param>
        /// <param name="parentFolderId"></param>
        /// <param name="newFolderName"></param>
        /// <returns></returns>

        //ToDo: Create Folder is deprecated
        public string CreateFolder(string projectId, string userId, string parentFolderId, string newFolderName)
        {
            if (projectId.StartsWith("b.") == false)
            {
                projectId = "b." + projectId;
            }

            var request = new RestRequest(Method.POST);

            // "data/v1/projects/" + projectId + "/folders"
            request.Resource = string.Format("{0}{1}/folders",
                                             "data/v1/projects/",
                                             projectId);

            request.AddHeader("Authorization", "Bearer " + Token);
            request.AddHeader("Content-Type", "application/vnd.api+json");
            request.AddHeader("x-user-id", userId);
            request.AddParameter("application/vnd.api+json", createFolderJsonBody(newFolderName, parentFolderId), ParameterType.RequestBody);

            IRestResponse response = ExecuteRequest(request);

            if (response.StatusCode != System.Net.HttpStatusCode.Created)
            {
                return("error");
            }

            JsonSerializerSettings jss = new JsonSerializerSettings();

            jss.NullValueHandling = NullValueHandling.Ignore;

            CreateFolderResponse jsonResponse =
                JsonConvert.DeserializeObject <CreateFolderResponse>(response.Content, jss);

            string newFolderId = jsonResponse.data.id;

            return(newFolderId);
        }
Esempio n. 7
0
        public string CustomCreateStorageLocation(string projectId, string folderId, string filePath)
        {
            string fileName = System.IO.Path.GetFileName(filePath);

            if (projectId.StartsWith("b.") == false)
            {
                projectId = "b." + projectId;
            }

            var request = new RestRequest(Method.POST);

            // "data/v1/projects/" + projectId + "/folders"
            request.Resource = Urls["folders_folder_storage"];

            request.AddParameter("ProjectId", projectId, ParameterType.UrlSegment);
            request.AddHeader("Authorization", "Bearer " + Token);
            request.AddHeader("Content-Type", "application/vnd.api+json");
            request.AddParameter("application/vnd.api+json", CustomCreateStorageJsonBody(fileName, folderId), ParameterType.RequestBody);

            IRestResponse response = ExecuteRequest(request);

            if (response.StatusCode != System.Net.HttpStatusCode.Created)
            {
                return("error");
            }

            JsonSerializerSettings jss = new JsonSerializerSettings();

            jss.NullValueHandling = NullValueHandling.Ignore;

            CreateFolderResponse jsonResponse =
                JsonConvert.DeserializeObject <CreateFolderResponse>(response.Content, jss);

            string objectId = jsonResponse.data.id;

            return(objectId);
        }
        private void CreateFolderFinished(object sender, create_folderCompletedEventArgs e)
        {
            object[] state = (object[])e.UserState;
            OperationFinished<CreateFolderResponse> createFolderFinishedHandler =
                (OperationFinished<CreateFolderResponse>)state[0];
            CreateFolderResponse response;

            if (e.Error != null)
            {
                response = new CreateFolderResponse
                {
                    Status = CreateFolderStatus.Failed,
                    UserState = state[1],
                    Error = e.Error
                };
            }
            else
            {
                response = new CreateFolderResponse
                {
                    Status = StatusMessageParser.ParseAddFolderStatus(e.Result),
                    UserState = state[1]
                };

                if (response.Status == CreateFolderStatus.Successful)
                {
                    response.Folder = new FolderBase(e.folder);
                }

                response.Error = response.Status == CreateFolderStatus.Unknown
                                    ?
                                        new UnknownOperationStatusException(e.Result)
                                    :
                                        null;
            }

            createFolderFinishedHandler(response);
        }