public void UpdateEnvironmentRequestObject()
        {
            moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict);
            UpdateEnvironmentRequest request = new UpdateEnvironmentRequest
            {
                Environment = new Environment(),
                UpdateMask  = new wkt::FieldMask(),
                AllowLoadToDraftAndDiscardChanges = true,
            };
            Environment expectedResponse = new Environment
            {
                EnvironmentName           = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
                Description               = "description2cf9da67",
                AgentVersionAsVersionName = VersionName.FromProjectVersion("[PROJECT]", "[VERSION]"),
                State                = Environment.Types.State.Loading,
                UpdateTime           = new wkt::Timestamp(),
                TextToSpeechSettings = new TextToSpeechSettings(),
                Fulfillment          = new Fulfillment(),
            };

            mockGrpcClient.Setup(x => x.UpdateEnvironment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EnvironmentsClient client   = new EnvironmentsClientImpl(mockGrpcClient.Object, null);
            Environment        response = client.UpdateEnvironment(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task CreateEnvironmentRequestObjectAsync()
        {
            moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict);
            CreateEnvironmentRequest request = new CreateEnvironmentRequest
            {
                ParentAsAgentName = AgentName.FromProject("[PROJECT]"),
                Environment       = new Environment(),
                EnvironmentId     = "environment_id26e3069e",
            };
            Environment expectedResponse = new Environment
            {
                EnvironmentName           = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
                Description               = "description2cf9da67",
                AgentVersionAsVersionName = VersionName.FromProjectVersion("[PROJECT]", "[VERSION]"),
                State                = Environment.Types.State.Loading,
                UpdateTime           = new wkt::Timestamp(),
                TextToSpeechSettings = new TextToSpeechSettings(),
                Fulfillment          = new Fulfillment(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #3
0
 public static string GetName(this EnvironmentName environment)
 {
     return(environment switch
     {
         EnvironmentName.Clear => "Clear",
         EnvironmentName.Twilight_Clear => "Twilight_Clear",
         EnvironmentName.Misty => "Misty",
         EnvironmentName.Darklands_dark => "Darklands_dark",
         EnvironmentName.Heath_clear => "Heath clear",
         EnvironmentName.DeepForest_Mist => "DeepForest Mist",
         EnvironmentName.GDKing => "GDKing",
         EnvironmentName.Rain => "Rain",
         EnvironmentName.LightRain => "LightRain",
         EnvironmentName.ThunderStorm => "ThunderStorm",
         EnvironmentName.Eikthyr => "Eikthyr",
         EnvironmentName.GoblinKing => "GoblinKing",
         EnvironmentName.nofogts => "nofogts",
         EnvironmentName.SwampRain => "SwampRain",
         EnvironmentName.Bonemass => "Bonemass",
         EnvironmentName.Snow => "Snow",
         EnvironmentName.Twilight_Snow => "Twilight_Snow",
         EnvironmentName.Twilight_SnowStorm => "Twilight_SnowStorm",
         EnvironmentName.SnowStorm => "SnowStorm",
         EnvironmentName.Moder => "Moder",
         EnvironmentName.Ashrain => "Ashrain",
         EnvironmentName.Crypt => "Crypt",
         EnvironmentName.SunkenCrypt => "SunkenCrypt",
         _ => null,
     });
Example #4
0
 public bool IsDevelopment()
 {
     if (!string.IsNullOrEmpty(EnvironmentName))
     {
         return(EnvironmentName.Equals("Development", StringComparison.OrdinalIgnoreCase));
     }
     return(false);
 }
Example #5
0
        public AddEnvironmentStep2Model(RenderingEnvironment environment)
        {
            EnvironmentName = environment.Name;
            SubscriptionId  = environment.SubscriptionId;
            LocationName    = environment.LocationName;
            RenderManager   = environment.RenderManager;

            if (!string.IsNullOrEmpty(environment.ResourceGroupName))
            {
                NewResourceGroupName = null;
                ExistingResourceGroupNameAndLocation
                    = $"{environment.ResourceGroupName};{environment.LocationName}";
            }
            else
            {
                NewResourceGroupName = EnvironmentName + "-rg";
            }

            if (environment.KeyVault != null)
            {
                NewKeyVaultName = null;
                ExistingKeyVaultIdLocationAndUri
                    = $"{environment.KeyVault.ResourceId};{environment.KeyVault.Location};{environment.KeyVault.Uri}";
            }
            else
            {
                var kvName = EnvironmentName.Length > 21 ? EnvironmentName.Substring(0, 21) : EnvironmentName;
                NewKeyVaultName = $"{Regex.Replace(kvName, "/[&\\/\\\\_-]/g", "")}-kv";
            }

            if (environment.BatchAccount != null)
            {
                NewBatchAccountName = null;
                BatchAccountResourceIdLocationUrl
                    = $"{environment.BatchAccount.ResourceId};{environment.BatchAccount.Location};{environment.BatchAccount.Url}";
            }

            if (environment.StorageAccount != null)
            {
                NewStorageAccountName = null;
                StorageAccountResourceIdAndLocation
                    = $"{environment.StorageAccount.ResourceId};{environment.StorageAccount.Location}";
            }

            if (environment.Subnet?.ResourceId != null)
            {
                NewVnetName = null;
                SubnetResourceIdLocationAndAddressPrefix = environment.Subnet.ToString();
            }

            if (environment.ApplicationInsightsAccount?.ResourceId != null)
            {
                NewApplicationInsightsName = null;
                ApplicationInsightsIdAndLocation
                    = $"{environment.ApplicationInsightsAccount.ResourceId};{environment.ApplicationInsightsAccount.Location}";
            }
        }
Example #6
0
        public override EventRuleElement GetRuleMatch(string collection, IEnumerable <EventRuleElement> eventRules)
        {
            var rule = GetRulesMatch(collection, eventRules)
                       .FirstOrDefault(r => r.Events.HasFlag(TfsEvents.ReleaseEnvironmentCompleted) &&
                                       EnvironmentName.IsMatchOrNoPattern(r.Environment) &&
                                       (!r.EnvironmentStatusesEnums.Any() || r.EnvironmentStatusesEnums.Contains(EnvironmentStatus)));

            return(rule);
        }
 /// <summary>
 /// Acquires a security token from the authority.
 /// </summary>
 /// <param name="applicationId">Identifier of the client requesting the token.</param>
 /// <param name="account">Account information used when requesting the token.</param>
 /// <param name="password">Password, or secret, used when requesting the token.</param>
 /// <param name="environmentName">Name of the environment to be used when requesting the token.</param>
 /// <param name="tokenCache">Token cache used to lookup cached tokens.</param>
 /// <returns>The access token and related information.</returns>
 public AuthenticationResult Authenticate(
     string applicationId,
     AzureAccount account,
     SecureString password,
     EnvironmentName environmentName,
     TokenCache tokenCache)
 {
     return(null);
 }
        protected override void ProcessRecord()
        {
            var baseResourceList    = new List <EnvironmentResource>();
            var environmentNameList = EnvironmentName?.ToList().ConvertAll(s => s.ToLower());

            switch (this.ParameterSetName)
            {
            case All:
                baseResourceList = _connection.Repository.Environments.FindAll();
                break;

            case ByName:
                //Multiple values but one of them is wildcarded, which is not an accepted scenario (I.e -MachineName WebServer*, Database1)
                if (environmentNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && environmentNameList.Count > 1))
                {
                    throw OctoposhExceptions.ParameterCollectionHasRegularAndWildcardItem("EnvironmentName");
                }
                //Only 1 wildcarded value (ie -MachineName WebServer*)
                else if (environmentNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && environmentNameList.Count == 1))
                {
                    var pattern = new WildcardPattern(environmentNameList.First().ToLower());
                    baseResourceList = _connection.Repository.Environments.FindMany(x => pattern.IsMatch(x.Name.ToLower()));
                }
                //multiple non-wildcared values (i.e. -MachineName WebServer1,Database1)
                else if (!environmentNameList.Any(WildcardPattern.ContainsWildcardCharacters))
                {
                    baseResourceList = _connection.Repository.Environments.FindMany(x => environmentNameList.Contains(x.Name.ToLower()));
                }
                break;
            }

            if (ResourceOnly)
            {
                if (baseResourceList.Count == 1)
                {
                    WriteObject(baseResourceList.FirstOrDefault(), true);
                }
                else
                {
                    WriteObject(baseResourceList, true);
                }
            }
            else
            {
                var converter  = new OutputConverter();
                var outputList = converter.GetOctopusEnvironment(baseResourceList);

                if (outputList.Count == 1)
                {
                    WriteObject(outputList.FirstOrDefault(), true);
                }
                else
                {
                    WriteObject(outputList, true);
                }
            }
        }
        /// <summary>
        /// Acquires a security token from the authority.
        /// </summary>
        /// <param name="applicationId">Identifier of the client requesting the token.</param>
        /// <param name="account">Account information used when requesting the token.</param>
        /// <param name="password">Password, or secret, used when requesting the token.</param>
        /// <param name="environmentName">Name of the environment to be used when requesting the token.</param>
        /// <param name="tokenCache">Token cache used to lookup cached tokens.</param>
        /// <returns>The access token and related information.</returns>
        public AuthenticationResult Authenticate(
            string applicationId,
            AzureAccount account,
            SecureString password,
            EnvironmentName environmentName,
            TokenCache tokenCache)
        {
            AuthenticationContext authContext;
            AuthenticationResult  authResult;
            PartnerEnvironment    environment;

            environment = PartnerEnvironment.PublicEnvironments[environmentName];

            authContext = new AuthenticationContext(
                $"{environment.ActiveDirectoryAuthority}{account.Properties[AzureAccountPropertyType.Tenant]}",
                tokenCache);

            if (account.Type == AccountType.ServicePrincipal)
            {
                authResult = Task.Run(() => authContext.AcquireTokenAsync(
                                          environment.AzureAdGraphEndpoint,
                                          new ClientCredential(
                                              account.Id,
                                              account.Properties[AzureAccountPropertyType.ServicePrincipalSecret]))).Result;
            }
            else if (string.IsNullOrEmpty(account.Id) && password == null)
            {
                authResult = Task.Run(() => authContext.AcquireTokenAsync(
                                          environment.PartnerCenterEndpoint,
                                          applicationId,
                                          redirectUri,
                                          new PlatformParameters(PromptBehavior.Never),
                                          new UserIdentifier(account.Id, UserIdentifierType.RequiredDisplayableId))).Result;
            }
            else if (!string.IsNullOrEmpty(account.Id) && password != null)
            {
                authResult = Task.Run(() => authContext.AcquireTokenAsync(
                                          environment.PartnerCenterEndpoint,
                                          applicationId,
                                          new UserPasswordCredential(
                                              account.Id,
                                              password))).Result;
            }
            else
            {
                authResult = Task.Run(() => authContext.AcquireTokenAsync(
                                          environment.PartnerCenterEndpoint,
                                          applicationId,
                                          redirectUri,
                                          new PlatformParameters(PromptBehavior.Always),
                                          UserIdentifier.AnyUser)).Result;
            }

            return(authResult);
        }
 /// <summary>Snippet for GetEnvironment</summary>
 public void GetEnvironmentResourceNames()
 {
     // Snippet: GetEnvironment(EnvironmentName, CallSettings)
     // Create client
     CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.Create();
     // Initialize request argument(s)
     EnvironmentName name = EnvironmentName.FromUserEnvironment("[USER]", "[ENVIRONMENT]");
     // Make the request
     Environment response = cloudShellServiceClient.GetEnvironment(name);
     // End snippet
 }
Example #11
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = ClientId != null?ClientId.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (ApplicationName != null ? ApplicationName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (EnvironmentName != null ? EnvironmentName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ConfigurationName != null ? ConfigurationName.GetHashCode() : 0);
                return(hashCode);
            }
        }
Example #12
0
 /// <summary>Snippet for CreateExperiment</summary>
 public void CreateExperimentResourceNames()
 {
     // Snippet: CreateExperiment(EnvironmentName, Experiment, CallSettings)
     // Create client
     ExperimentsClient experimentsClient = ExperimentsClient.Create();
     // Initialize request argument(s)
     EnvironmentName parent     = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]");
     Experiment      experiment = new Experiment();
     // Make the request
     Experiment response = experimentsClient.CreateExperiment(parent, experiment);
     // End snippet
 }
 /// <summary>Snippet for GetEnvironment</summary>
 public void GetEnvironmentRequestObject()
 {
     // Snippet: GetEnvironment(GetEnvironmentRequest, CallSettings)
     // Create client
     CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.Create();
     // Initialize request argument(s)
     GetEnvironmentRequest request = new GetEnvironmentRequest
     {
         EnvironmentName = EnvironmentName.FromUserEnvironment("[USER]", "[ENVIRONMENT]"),
     };
     // Make the request
     Environment response = cloudShellServiceClient.GetEnvironment(request);
     // End snippet
 }
        /// <summary>Snippet for GetEnvironmentAsync</summary>
        public async Task GetEnvironmentResourceNamesAsync()
        {
            // Snippet: GetEnvironmentAsync(EnvironmentName, CallSettings)
            // Additional: GetEnvironmentAsync(EnvironmentName, CancellationToken)
            // Create client
            CloudShellServiceClient cloudShellServiceClient = await CloudShellServiceClient.CreateAsync();

            // Initialize request argument(s)
            EnvironmentName name = EnvironmentName.FromUserEnvironment("[USER]", "[ENVIRONMENT]");
            // Make the request
            Environment response = await cloudShellServiceClient.GetEnvironmentAsync(name);

            // End snippet
        }
 /// <summary>Snippet for GetEnvironment</summary>
 public void GetEnvironmentRequestObject()
 {
     // Snippet: GetEnvironment(GetEnvironmentRequest, CallSettings)
     // Create client
     EnvironmentsClient environmentsClient = EnvironmentsClient.Create();
     // Initialize request argument(s)
     GetEnvironmentRequest request = new GetEnvironmentRequest
     {
         EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
     };
     // Make the request
     gcdv::Environment response = environmentsClient.GetEnvironment(request);
     // End snippet
 }
Example #16
0
 /// <summary>Snippet for CreateExperiment</summary>
 public void CreateExperimentRequestObject()
 {
     // Snippet: CreateExperiment(CreateExperimentRequest, CallSettings)
     // Create client
     ExperimentsClient experimentsClient = ExperimentsClient.Create();
     // Initialize request argument(s)
     CreateExperimentRequest request = new CreateExperimentRequest
     {
         ParentAsEnvironmentName = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"),
         Experiment = new Experiment(),
     };
     // Make the request
     Experiment response = experimentsClient.CreateExperiment(request);
     // End snippet
 }
        /// <summary>Snippet for DeleteEnvironment</summary>
        public void DeleteEnvironmentRequestObject()
        {
            // Snippet: DeleteEnvironment(DeleteEnvironmentRequest, CallSettings)
            // Create client
            EnvironmentsClient environmentsClient = EnvironmentsClient.Create();
            // Initialize request argument(s)
            DeleteEnvironmentRequest request = new DeleteEnvironmentRequest
            {
                EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
            };

            // Make the request
            environmentsClient.DeleteEnvironment(request);
            // End snippet
        }
Example #18
0
        /// <summary>Snippet for CreateExperimentAsync</summary>
        public async Task CreateExperimentResourceNamesAsync()
        {
            // Snippet: CreateExperimentAsync(EnvironmentName, Experiment, CallSettings)
            // Additional: CreateExperimentAsync(EnvironmentName, Experiment, CancellationToken)
            // Create client
            ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync();

            // Initialize request argument(s)
            EnvironmentName parent     = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]");
            Experiment      experiment = new Experiment();
            // Make the request
            Experiment response = await experimentsClient.CreateExperimentAsync(parent, experiment);

            // End snippet
        }
        /// <summary>Snippet for ListDeploymentsAsync</summary>
        public async Task ListDeploymentsRequestObjectAsync()
        {
            // Snippet: ListDeploymentsAsync(ListDeploymentsRequest, CallSettings)
            // Create client
            DeploymentsClient deploymentsClient = await DeploymentsClient.CreateAsync();

            // Initialize request argument(s)
            ListDeploymentsRequest request = new ListDeploymentsRequest
            {
                ParentAsEnvironmentName = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"),
            };
            // Make the request
            PagedAsyncEnumerable <ListDeploymentsResponse, Deployment> response = deploymentsClient.ListDeploymentsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Deployment item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListDeploymentsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Deployment item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <Deployment> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Deployment item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Example #20
0
        public void DeleteEnvironmentRequestObject()
        {
            moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict);
            DeleteEnvironmentRequest request = new DeleteEnvironmentRequest
            {
                EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteEnvironment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EnvironmentsClient client = new EnvironmentsClientImpl(mockGrpcClient.Object, null);

            client.DeleteEnvironment(request);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for GetEnvironmentHistory</summary>
        public void GetEnvironmentHistoryRequestObject()
        {
            // Snippet: GetEnvironmentHistory(GetEnvironmentHistoryRequest, CallSettings)
            // Create client
            EnvironmentsClient environmentsClient = EnvironmentsClient.Create();
            // Initialize request argument(s)
            GetEnvironmentHistoryRequest request = new GetEnvironmentHistoryRequest
            {
                ParentAsEnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
            };
            // Make the request
            PagedEnumerable <EnvironmentHistory, EnvironmentHistory.Types.Entry> response = environmentsClient.GetEnvironmentHistory(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (EnvironmentHistory.Types.Entry item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (EnvironmentHistory page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (EnvironmentHistory.Types.Entry item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <EnvironmentHistory.Types.Entry> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (EnvironmentHistory.Types.Entry item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
        /// <summary>Snippet for DeleteEnvironmentAsync</summary>
        public async Task DeleteEnvironmentRequestObjectAsync()
        {
            // Snippet: DeleteEnvironmentAsync(DeleteEnvironmentRequest, CallSettings)
            // Additional: DeleteEnvironmentAsync(DeleteEnvironmentRequest, CancellationToken)
            // Create client
            EnvironmentsClient environmentsClient = await EnvironmentsClient.CreateAsync();

            // Initialize request argument(s)
            DeleteEnvironmentRequest request = new DeleteEnvironmentRequest
            {
                EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
            };
            // Make the request
            await environmentsClient.DeleteEnvironmentAsync(request);

            // End snippet
        }
Example #23
0
        public async stt::Task DeleteEnvironmentRequestObjectAsync()
        {
            moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict);
            DeleteEnvironmentRequest request = new DeleteEnvironmentRequest
            {
                EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteEnvironmentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            EnvironmentsClient client = new EnvironmentsClientImpl(mockGrpcClient.Object, null);
            await client.DeleteEnvironmentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            await client.DeleteEnvironmentAsync(request, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for ListDeployments</summary>
        public void ListDeploymentsResourceNames()
        {
            // Snippet: ListDeployments(EnvironmentName, string, int?, CallSettings)
            // Create client
            DeploymentsClient deploymentsClient = DeploymentsClient.Create();
            // Initialize request argument(s)
            EnvironmentName parent = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]");
            // Make the request
            PagedEnumerable <ListDeploymentsResponse, Deployment> response = deploymentsClient.ListDeployments(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Deployment item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListDeploymentsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Deployment item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <Deployment> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Deployment item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Example #25
0
        public PartnerContext Authenticate(string applicationId, EnvironmentName environment, string username, SecureString password, string tenantId)
        {
            AuthenticationResult authResult;
            IPartner             partner;
            OrganizationProfile  profile;
            PartnerContext       context;

            applicationId.AssertNotEmpty(nameof(applicationId));
            environment.AssertNotNull(nameof(environment));
            tenantId.AssertNotEmpty(nameof(tenantId));

            try
            {
                context = new PartnerContext
                {
                    ApplicationId = applicationId,
                    Environment   = environment,
                    TenantId      = tenantId,
                    Username      = username
                };

                authResult = Authenticate(context, password);

                partner = PartnerSession.Instance.ClientFactory.CreatePartnerOperations(context);
                profile = partner.Profiles.OrganizationProfile.Get();

                context.CountryCode = profile.DefaultAddress.Country;
                context.Locale      = profile.Culture;
                context.UserId      = authResult.UserInfo.UniqueId;

                return(context);
            }
            finally
            {
                authResult = null;
                partner    = null;
                profile    = null;
            }
        }
Example #26
0
 public override int GetHashCode()
 {
     unchecked // overflow is fine, just wrap
     {
         var hash = 17;
         hash *= 23 + LogLevel.GetHashCode();
         hash *= 23 + (EnvironmentName != null ? EnvironmentName.GetHashCode() : 0);
         hash *= 23 + (ClientId.HasValue ? ClientId.GetHashCode() : 0);
         hash *= 23 + (ClientVersion != null ? ClientVersion.GetHashCode() : 0);
         hash *= 23 + (MachineName != null ? MachineName.GetHashCode() : 0);
         hash *= 23 + (TenantId.HasValue ? TenantId.GetHashCode() : 0);
         hash *= 23 + (UserId.HasValue ? UserId.GetHashCode() : 0);
         hash *= 23 + (UserName != null ? UserName.GetHashCode() : 0);
         hash *= 23 + (SessionId.HasValue ? SessionId.GetHashCode() : 0);
         hash *= 23 + (DeviceId.HasValue ? DeviceId.GetHashCode() : 0);
         hash *= 23 + (CorrelationId.HasValue ? CorrelationId.GetHashCode() : 0);
         hash *= 23 + (Source != null ? Source.GetHashCode() : 0);
         hash *= 23 + (Message != null ? Message.GetHashCode() : 0);
         hash *= 23 + (Callstack != null ? Callstack.GetHashCode() : 0);
         return(hash);
     }
 }
Example #27
0
        public async Task <List <EnvironmentName> > GetEnvironmentName()
        {
            string hash = await getHash();

            var requestRepository = new HttpRequestMessage(HttpMethod.Get,
                                                           "https://api.bitbucket.org/2.0/repositories/microservicesharinghub/quan3_dev/src/" + hash + "/Config");

            requestRepository.Headers.Add("Accept", "application/json");


            var clientRepository = _clientFactory.CreateClient("bitbucket");

            var reponses = await clientRepository.SendAsync(requestRepository);

            List <EnvironmentName> environmentNames = new List <EnvironmentName>();
            List <Value>           values           = new List <Value>();

            if (reponses.IsSuccessStatusCode)
            {
                FileObject file = await reponses.Content.ReadAsAsync <FileObject>();

                values = file.values;
            }
            foreach (Value v  in values)
            {
                if (v.type.Equals("commit_directory"))
                {
                    int             longName        = v.path.Length - 7;
                    string          name            = v.path.ToString().Substring(7, longName);
                    EnvironmentName environmentName = new EnvironmentName();
                    environmentName.name = name;
                    environmentNames.Add(environmentName);
                }
            }
            return(environmentNames);
        }
Example #28
0
        public async stt::Task GetEnvironmentRequestObjectAsync()
        {
            moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetEnvironmentRequest request = new GetEnvironmentRequest
            {
                Name = "name1c9368b0",
            };
            Environment expectedResponse = new Environment
            {
                EnvironmentName = EnvironmentName.FromProjectLocationEnvironment("[PROJECT]", "[LOCATION]", "[ENVIRONMENT]"),
                Config          = new EnvironmentConfig(),
                Uuid            = "uuid6f877cef",
                State           = Environment.Types.State.Unspecified,
                CreateTime      = new wkt::Timestamp(),
                UpdateTime      = new wkt::Timestamp(),
                Labels          =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #29
0
        /// <summary>Snippet for ExportAgentAsync</summary>
        public async Task ExportAgentRequestObjectAsync()
        {
            // Snippet: ExportAgentAsync(ExportAgentRequest, CallSettings)
            // Additional: ExportAgentAsync(ExportAgentRequest, CancellationToken)
            // Create client
            AgentsClient agentsClient = await AgentsClient.CreateAsync();

            // Initialize request argument(s)
            ExportAgentRequest request = new ExportAgentRequest
            {
                AgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"),
                AgentUri  = "",
                EnvironmentAsEnvironmentName = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"),
            };
            // Make the request
            Operation <ExportAgentResponse, Struct> response = await agentsClient.ExportAgentAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <ExportAgentResponse, Struct> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            ExportAgentResponse result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <ExportAgentResponse, Struct> retrievedResponse = await agentsClient.PollOnceExportAgentAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                ExportAgentResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Example #30
0
 public static void Simulate(string machineName, EnvironmentType? type, EnvironmentName? name)
 {
     _simulatedMachineName = machineName;
     _simulatedEnvironmentType = type;
     _simulatedEnvironmentName = name;
     _isSimulating = true;
 }
Example #31
0
        public FileNameDialog()
        {
            InitializeComponent();

            EnvironmentName.Focus();
        }