public static CreateMountTargetResponse Unmarshall(UnmarshallerContext context)
        {
            CreateMountTargetResponse createMountTargetResponse = new CreateMountTargetResponse();

            createMountTargetResponse.HttpResponse      = context.HttpResponse;
            createMountTargetResponse.RequestId         = context.StringValue("CreateMountTarget.RequestId");
            createMountTargetResponse.MountTargetDomain = context.StringValue("CreateMountTarget.MountTargetDomain");

            return(createMountTargetResponse);
        }
Example #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)
        {
            CreateMountTargetResponse response = new CreateMountTargetResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("FileSystemId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.FileSystemId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("IpAddress", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.IpAddress = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LifeCycleState", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.LifeCycleState = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("MountTargetId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.MountTargetId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NetworkInterfaceId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NetworkInterfaceId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("OwnerId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.OwnerId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("SubnetId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.SubnetId = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        /**
         * Creates a mount target and waits for it to become available. We recommend to retry these requests
         * so that if you receive a timeout or server error and you won't run into the risk of creating multiple resources.
         *
         * This creates a mount target WITHOUT specifying a hostname. This means that the mount target will only be accessible
         * via its private IP address.
         *
         * @param fsClient the service client to use to create the mount target
         * @param vcnClient a client used to communiate with the Virtual Networking service
         * @param compartmentId the OCID of the compartment where the file system will be created
         * @param displayName the display name of the mount target
         * @param availabilityDomain the availability domain where the file system will be created
         * @param subnet the subnet where the mount target will reside. If no private IP address is explicitly specified at
         * creation time then the mount target will be assigned a free private IP address from the subnet
         *
         * @return the created mount target
         */
        private static async Task <MountTarget> CreateMountTarget(FileStorageClient fsClient, VirtualNetworkClient vcnClient,
                                                                  string compartmentId, string displayName, AvailabilityDomain availabilityDomain, Subnet subnet)
        {
            logger.Info("Creating mount target......");

            CreateMountTargetDetails createDetails = new CreateMountTargetDetails
            {
                AvailabilityDomain = availabilityDomain.Name,
                SubnetId           = subnet.Id,
                CompartmentId      = compartmentId,
                DisplayName        = displayName
            };
            CreateMountTargetRequest createRequest = new CreateMountTargetRequest
            {
                CreateMountTargetDetails = createDetails
            };
            var retryConfiguration = new RetryConfiguration
            {
                MaxAttempts = 5
            };
            CreateMountTargetResponse createResponse = await fsClient.CreateMountTarget(createRequest, retryConfiguration);

            logger.Info($"Created Mount target: {createResponse.MountTarget.DisplayName}");

            logger.Info("Waiting for mount target to become available");
            GetMountTargetRequest getRequest = new GetMountTargetRequest
            {
                MountTargetId = createResponse.MountTarget.Id
            };
            GetMountTargetResponse getResponse = fsClient.Waiters.ForMountTarget(getRequest, MountTarget.LifecycleStateEnum.Active).Execute();

            logger.Info($"Mount target state: {getResponse.MountTarget.LifecycleState}");

            string mountTargetPrivateIpId           = getResponse.MountTarget.PrivateIpIds[0];
            GetPrivateIpRequest getPrivateIpRequest = new GetPrivateIpRequest
            {
                PrivateIpId = mountTargetPrivateIpId
            };
            GetPrivateIpResponse getPrivateIpResponse = await vcnClient.GetPrivateIp(getPrivateIpRequest);

            logger.Info($"Mount target private IP: {getPrivateIpResponse.PrivateIp.IpAddress}");

            return(getResponse.MountTarget);
        }