public void GetFolder()
        {
            moq::Mock <Folders.FoldersClient> mockGrpcClient = new moq::Mock <Folders.FoldersClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetFolderRequest request = new GetFolderRequest
            {
                FolderName = gagr::FolderName.FromFolder("[FOLDER]"),
            };
            Folder expectedResponse = new Folder
            {
                FolderName  = gagr::FolderName.FromFolder("[FOLDER]"),
                Parent      = "parent7858e4d0",
                DisplayName = "display_name137f65c2",
                State       = Folder.Types.State.Unspecified,
                CreateTime  = new wkt::Timestamp(),
                UpdateTime  = new wkt::Timestamp(),
                DeleteTime  = new wkt::Timestamp(),
                Etag        = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetFolder(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            FoldersClient client   = new FoldersClientImpl(mockGrpcClient.Object, null);
            Folder        response = client.GetFolder(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetFolderRequestObjectAsync()
        {
            moq::Mock <Folders.FoldersClient> mockGrpcClient = new moq::Mock <Folders.FoldersClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetFolderRequest request = new GetFolderRequest
            {
                FolderName = gagr::FolderName.FromFolder("[FOLDER]"),
            };
            Folder expectedResponse = new Folder
            {
                FolderName  = gagr::FolderName.FromFolder("[FOLDER]"),
                Parent      = "parent7858e4d0",
                DisplayName = "display_name137f65c2",
                State       = Folder.Types.State.Unspecified,
                CreateTime  = new wkt::Timestamp(),
                UpdateTime  = new wkt::Timestamp(),
                DeleteTime  = new wkt::Timestamp(),
                Etag        = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetFolderAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Folder>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            FoldersClient client = new FoldersClientImpl(mockGrpcClient.Object, null);
            Folder        responseCallSettings = await client.GetFolderAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Folder responseCancellationToken = await client.GetFolderAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
示例#3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetFolderRequest request;

            try
            {
                request = new GetFolderRequest
                {
                    CatalogId    = CatalogId,
                    DataAssetKey = DataAssetKey,
                    FolderKey    = FolderKey,
                    IsIncludeObjectRelationships = IsIncludeObjectRelationships,
                    Fields       = Fields,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
示例#4
0
        /// <summary>
        /// Creates a waiter using the provided configuration.
        /// </summary>
        /// <param name="request">Request to send.</param>
        /// <param name="config">Wait Configuration</param>
        /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
        /// <returns>a new Oci.common.Waiter instance</returns>
        public Waiter <GetFolderRequest, GetFolderResponse> ForFolder(GetFolderRequest request, WaiterConfiguration config, params LifecycleState[] targetStates)
        {
            var agent = new WaiterAgent <GetFolderRequest, GetFolderResponse>(
                request,
                request => client.GetFolder(request),
                response => targetStates.Contains(response.Folder.LifecycleState.Value),
                targetStates.Contains(LifecycleState.Deleted)
                );

            return(new Waiter <GetFolderRequest, GetFolderResponse>(config, agent));
        }
        private void HandleOutput(GetFolderRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForFolder(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetFolder(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Folder);
        }
示例#6
0
        /// <summary>
        /// Gets the specified folder.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        ///   <c>GetFolderRequest</c> with an folder.
        /// </returns>
        public GetFolderResponse Get(GetFolderRequest request)
        {
            var model =
                repository.AsQueryable<MediaFolder>(media => media.Id == request.FolderId && media.ContentType == Module.MediaManager.Models.MediaContentType.Folder)
                    .Select(
                        media =>
                        new FolderModel
                            {
                                Id = media.Id,
                                Version = media.Version,
                                CreatedBy = media.CreatedByUser,
                                CreatedOn = media.CreatedOn,
                                LastModifiedBy = media.ModifiedByUser,
                                LastModifiedOn = media.ModifiedOn,
                                Title = media.Title,
                                IsArchived = media.IsArchived,
                                Type = (MediaType)(int)media.Type,
                                ParentFolderId = media.Folder != null ? (Guid?)media.Folder.Id : null
                            }).FirstOne();

            return new GetFolderResponse { Data = model };
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetFolderRequest request;

            try
            {
                request = new GetFolderRequest
                {
                    WorkspaceId  = WorkspaceId,
                    FolderKey    = FolderKey,
                    OpcRequestId = OpcRequestId
                };

                response = client.GetFolder(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Folder);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
示例#8
0
 /// <summary>
 /// Creates a waiter using default wait configuration.
 /// </summary>
 /// <param name="request">Request to send.</param>
 /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
 /// <returns>a new Oci.common.Waiter instance</returns>
 public Waiter <GetFolderRequest, GetFolderResponse> ForFolder(GetFolderRequest request, params LifecycleState[] targetStates)
 {
     return(this.ForFolder(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }
 public Folder Get(GetFolderRequest request)
 {
     return Repository.GetById(request.Id);
 }