コード例 #1
0
ファイル: GitHubAdapter.cs プロジェクト: microsoft/TeamCloud
#pragma warning disable CS0618 // Type or member is obsolete

    // IDistributedLockManager is marked as obsolete, because it's not ready for "prime time"
    // however; it is used to managed singleton function execution within the functions fx !!!

    public GitHubAdapter(
        IAuthorizationSessionClient sessionClient,
        IAuthorizationTokenClient tokenClient,
        IDistributedLockManager distributedLockManager,
        ISecretsStoreProvider secretsStoreProvider,
        IHttpClientFactory httpClientFactory,
        IOrganizationRepository organizationRepository,
        IUserRepository userRepository,
        IDeploymentScopeRepository deploymentScopeRepository,
        IProjectRepository projectRepository,
        IComponentRepository componentRepository,
        IComponentTemplateRepository componentTemplateRepository,
        IAzureSessionService azureSessionService,
        IAzureResourceService azureResourceService,
        IGraphService graphService,
        IFunctionsHost functionsHost = null)
        : base(sessionClient, tokenClient, distributedLockManager, secretsStoreProvider, azureSessionService, graphService, organizationRepository, deploymentScopeRepository, projectRepository, userRepository)
    {
        this.httpClientFactory           = httpClientFactory ?? new DefaultHttpClientFactory();
        this.organizationRepository      = organizationRepository ?? throw new ArgumentNullException(nameof(organizationRepository));
        this.userRepository              = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
        this.deploymentScopeRepository   = deploymentScopeRepository ?? throw new ArgumentNullException(nameof(deploymentScopeRepository));
        this.projectRepository           = projectRepository ?? throw new ArgumentNullException(nameof(projectRepository));
        this.componentRepository         = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
        this.componentTemplateRepository = componentTemplateRepository ?? throw new ArgumentNullException(nameof(componentTemplateRepository));
        this.azureSessionService         = azureSessionService ?? throw new ArgumentNullException(nameof(azureSessionService));
        this.azureResourceService        = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
        this.graphService  = graphService ?? throw new ArgumentNullException(nameof(graphService));
        this.functionsHost = functionsHost ?? FunctionsHost.Default;
    }
コード例 #2
0
 public ComponentTaskExpander(IProjectRepository projectRepository, IAzureResourceService azureResourceService, IGraphService graphService, ICommandAuditReader commandAuditReader, IMemoryCache cache, TelemetryClient telemetryClient) : base(true, telemetryClient)
 {
     this.projectRepository    = projectRepository ?? throw new ArgumentNullException(nameof(projectRepository));
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
     this.graphService         = graphService ?? throw new ArgumentNullException(nameof(graphService));
     this.commandAuditReader   = commandAuditReader ?? throw new ArgumentNullException(nameof(commandAuditReader));
     this.cache = cache ?? throw new ArgumentNullException(nameof(cache));
 }
コード例 #3
0
ファイル: AzureResource.cs プロジェクト: narayanr7/TeamCloud
        protected AzureResource(string resourceId, IAzureResourceService azureResourceService)
        {
            if (resourceId is null)
            {
                throw new ArgumentNullException(nameof(resourceId));
            }

            ResourceId           = AzureResourceIdentifier.Parse(resourceId);
            AzureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
        }
コード例 #4
0
 public ComponentIdentityActivity(IOrganizationRepository organizationRepository,
                                  IDeploymentScopeRepository deploymentScopeRepository,
                                  IProjectRepository projectRepository,
                                  IAzureResourceService azureResourceService)
 {
     this.organizationRepository    = organizationRepository ?? throw new ArgumentNullException(nameof(organizationRepository));
     this.deploymentScopeRepository = deploymentScopeRepository ?? throw new ArgumentNullException(nameof(deploymentScopeRepository));
     this.projectRepository         = projectRepository ?? throw new ArgumentNullException(nameof(projectRepository));
     this.azureResourceService      = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #5
0
#pragma warning disable CS0618 // Type or member is obsolete

    // IDistributedLockManager is marked as obsolete, because it's not ready for "prime time"
    // however; it is used to managed singleton function execution within the functions fx !!!

    public KubernetesAdapter(IAuthorizationSessionClient sessionClient,
                             IAuthorizationTokenClient tokenClient,
                             IDistributedLockManager distributedLockManager,
                             ISecretsStoreProvider secretsStoreProvider,
                             IAzureSessionService azureSessionService,
                             IAzureResourceService azureResourceService,
                             IGraphService graphService,
                             IOrganizationRepository organizationRepository,
                             IDeploymentScopeRepository deploymentScopeRepository,
                             IProjectRepository projectRepository,
                             IUserRepository userRepository)
        : base(sessionClient, tokenClient, distributedLockManager, secretsStoreProvider, azureSessionService, graphService, organizationRepository, deploymentScopeRepository, projectRepository, userRepository)
    {
        this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
    }
 public BenchmarkResultsService(IRepository <BenchmarkTestItem> benchmarkTestItemService,
                                IRepository <BenchmarkExperiment> benchmarkExperimentRepo,
                                IAzureResourceService azureResourceService,
                                IHostingEnvironment env, IBackgroundJobClient backgroungJobClient, IRepository <CSVUpload> csvUploadRepo, ILogger <BenchmarkResultsService> logger,
                                IRepository <ContainerMetric> containerMetricService)
 {
     _benchmarkTestItemService = benchmarkTestItemService;
     _benchmarkExperimentRepo  = benchmarkExperimentRepo;
     _azureResourceService     = azureResourceService;
     _env = env;
     _backgroungJobClient = backgroungJobClient;
     _csvUploadRepo       = csvUploadRepo;
     _logger = logger;
     _containerMetricService = containerMetricService;
 }
コード例 #7
0
    public static async IAsyncEnumerable <Capabilities> GetCapabilitiesAsync(IAzureResourceService azureResourceService, Guid subscriptionId, string region)
    {
        if (azureResourceService is null)
        {
            throw new ArgumentNullException(nameof(azureResourceService));
        }

        if (string.IsNullOrEmpty(region))
        {
            throw new ArgumentException($"'{nameof(region)}' cannot be null or empty.", nameof(region));
        }

        // CAUTION - the ListCapabilitiesAync method of the ContainerInstanceManagementClient
        // has a serious issue and blows up the process when called - lets do the call using
        // Flurl but stick with the library's data object and we are happy

        var token = await azureResourceService.AzureSessionService
                    .AcquireTokenAsync()
                    .ConfigureAwait(false);

        var capabilities = await azureResourceService.AzureSessionService.Environment.ResourceManagerEndpoint
                           .AppendPathSegment($"subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{region}/capabilities")
                           .SetQueryParam("api-version", "2019-12-01")
                           .WithOAuthBearerToken(token)
                           .GetJsonAsync <CapabilitiesListResultInner>()
                           .ConfigureAwait(false);

        while (true)
        {
            foreach (var capability in capabilities.Value ?? Enumerable.Empty <Capabilities>())
            {
                yield return(capability);
            }

            if (string.IsNullOrEmpty(capabilities.NextLink))
            {
                break;
            }

            capabilities = await capabilities.NextLink
                           .WithOAuthBearerToken(token)
                           .GetJsonAsync <CapabilitiesListResultInner>()
                           .ConfigureAwait(false);
        }
    }
コード例 #8
0
ファイル: AzureResource.cs プロジェクト: narayanr7/TeamCloud
        internal static async Task <T> InitializeAsync <T>(T azureResource, IAzureResourceService azureResourceService, bool throwIfNotExists)
            where T : AzureResource
        {
            azureResource.AzureResourceService = azureResourceService;

            var exists = await azureResource
                         .ExistsAsync()
                         .ConfigureAwait(false);

            if (exists)
            {
                return(azureResource);
            }

            if (throwIfNotExists)
            {
                throw new AzureResourceException($"Resource {azureResource.ResourceId} not found");
            }

            return(null);
        }
コード例 #9
0
ファイル: Extensions.cs プロジェクト: narayanr7/TeamCloud
        public static Task <IEnumerable <string> > GetApiVersionsAsync(this IAzureResourceService azureResourceService, AzureResourceIdentifier azureResourceIdentifier, bool includePreviewVersions = false)
        {
            if (azureResourceService is null)
            {
                throw new ArgumentNullException(nameof(azureResourceService));
            }

            if (azureResourceIdentifier is null)
            {
                throw new ArgumentNullException(nameof(azureResourceIdentifier));
            }

            if (string.IsNullOrEmpty(azureResourceIdentifier.ResourceNamespace))
            {
                return(azureResourceService.GetApiVersionsAsync(azureResourceIdentifier.SubscriptionId, "Microsoft.Resources", "resourceGroups", includePreviewVersions));
            }
            else
            {
                return(azureResourceService.GetApiVersionsAsync(azureResourceIdentifier.SubscriptionId, azureResourceIdentifier.ResourceNamespace, azureResourceIdentifier.ResourceTypeName, includePreviewVersions));
            }
        }
コード例 #10
0
    public static async Task <IEnumerable <Usage> > GetUsageAsync(IAzureResourceService azureResourceService, Guid subscriptionId, string region)
    {
        if (azureResourceService is null)
        {
            throw new ArgumentNullException(nameof(azureResourceService));
        }

        if (string.IsNullOrEmpty(region))
        {
            throw new ArgumentException($"'{nameof(region)}' cannot be null or empty.", nameof(region));
        }

        var client = await azureResourceService.AzureSessionService
                     .CreateClientAsync <ContainerInstanceManagementClient>(subscriptionId : subscriptionId)
                     .ConfigureAwait(false);

        var usage = await client.ContainerGroupUsage
                    .ListAsync(region)
                    .ConfigureAwait(false);

        return(usage.Value);
    }
コード例 #11
0
 public ComponentTaskRunnerActivity(IOrganizationRepository organizationRepository,
                                    IDeploymentScopeRepository deploymentScopeRepository,
                                    IProjectRepository projectRepository,
                                    IComponentRepository componentRepository,
                                    IComponentTemplateRepository componentTemplateRepository,
                                    IComponentTaskRepository componentTaskRepository,
                                    IAzureSessionService azureSessionService,
                                    IAzureResourceService azureResourceService,
                                    IAdapterProvider adapterProvider,
                                    IRunnerOptions runnerOptions)
 {
     this.organizationRepository      = organizationRepository ?? throw new ArgumentNullException(nameof(organizationRepository));
     this.deploymentScopeRepository   = deploymentScopeRepository ?? throw new ArgumentNullException(nameof(deploymentScopeRepository));
     this.projectRepository           = projectRepository ?? throw new ArgumentNullException(nameof(projectRepository));
     this.componentRepository         = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
     this.componentTemplateRepository = componentTemplateRepository ?? throw new ArgumentNullException(nameof(componentTemplateRepository));
     this.componentTaskRepository     = componentTaskRepository ?? throw new ArgumentNullException(nameof(componentTaskRepository));
     this.azureSessionService         = azureSessionService ?? throw new ArgumentNullException(nameof(azureSessionService));
     this.azureResourceService        = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
     this.adapterProvider             = adapterProvider ?? throw new ArgumentNullException(nameof(adapterProvider));
     this.runnerOptions = runnerOptions ?? throw new ArgumentNullException(nameof(runnerOptions));
 }
コード例 #12
0
#pragma warning disable CS0618 // Type or member is obsolete

    // IDistributedLockManager is marked as obsolete, because it's not ready for "prime time"
    // however; it is used to managed singleton function execution within the functions fx !!!

    public AzureResourceManagerAdapter(IAuthorizationSessionClient sessionClient,
                                       IAuthorizationTokenClient tokenClient,
                                       IDistributedLockManager distributedLockManager,
                                       ISecretsStoreProvider secretsStoreProvider,
                                       IAzureSessionService azureSessionService,
                                       IGraphService graphService,
                                       IAzureResourceService azureResourceService,
                                       IOrganizationRepository organizationRepository,
                                       IUserRepository userRepository,
                                       IDeploymentScopeRepository deploymentScopeRepository,
                                       IProjectRepository projectRepository,
                                       IComponentRepository componentRepository,
                                       IComponentTemplateRepository componentTemplateRepository)
        : base(sessionClient, tokenClient, distributedLockManager, secretsStoreProvider, azureSessionService, graphService, organizationRepository, deploymentScopeRepository, projectRepository, userRepository)
    {
        this.azureSessionService         = azureSessionService ?? throw new ArgumentNullException(nameof(azureSessionService));
        this.azureResourceService        = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
        this.organizationRepository      = organizationRepository ?? throw new ArgumentNullException(nameof(organizationRepository));
        this.userRepository              = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
        this.deploymentScopeRepository   = deploymentScopeRepository ?? throw new ArgumentNullException(nameof(deploymentScopeRepository));
        this.projectRepository           = projectRepository ?? throw new ArgumentNullException(nameof(projectRepository));
        this.componentRepository         = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
        this.componentTemplateRepository = componentTemplateRepository ?? throw new ArgumentNullException(nameof(componentTemplateRepository));
    }
 public DeleteResourcesHandler(IAzureResourceService azureResourceService)
 {
     _azureResourceService = azureResourceService;
 }
コード例 #14
0
 public AdapterInitializationLoggerFactory(IProjectRepository projectRepository, IAzureResourceService azureResourceService)
 {
     this.projectRepository    = projectRepository ?? throw new ArgumentNullException(nameof(projectRepository));
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #15
0
 public ComponentResourcesActivity(IAzureResourceService azureResourceService)
 {
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #16
0
 public ProjectSubscriptionSelectActivity(IProjectTypesRepositoryReadOnly projectTypesRepository, IAzureResourceService azureResourceService)
 {
     this.projectTypesRepository = projectTypesRepository ?? throw new ArgumentNullException(nameof(projectTypesRepository));
     this.azureResourceService   = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AzureDeleteResourcesByNameCommandHandler"/> class.
 /// </summary>
 /// <param name="azureResourceService">The azure resource service.</param>
 public AzureDeleteResourcesByNameCommandHandler(IAzureResourceService azureResourceService)
 {
     _azureResourceService = azureResourceService;
 }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AzureTestCreateResourcesCommandHandler"/> class.
 /// </summary>
 /// <param name="azureResourceService">The azure resource service.</param>
 /// <param name="backgroungJobClient">The backgroung job client.</param>
 public AzureTestCreateResourcesCommandHandler(IAzureResourceService azureResourceService, IBackgroundJobClient backgroungJobClient)
 {
     _azureResourceService = azureResourceService;
     _backgroungJobClient  = backgroungJobClient;
 }
コード例 #19
0
 public ResourceProviderRegisterActivity(IProvidersRepository providersRepository, IAzureResourceService azureResourceService)
 {
     this.providersRepository  = providersRepository ?? throw new ArgumentNullException(nameof(providersRepository));
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #20
0
 public SynchronizeServiceConnectionsActivity(IAzureResourceService azureResourceService, IAuthenticationService authenticationService, IDistributedCache cache)
 {
     this.azureResourceService  = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
     this.authenticationService = authenticationService ?? throw new ArgumentNullException(nameof(authenticationService));
     this.cache = cache ?? throw new ArgumentNullException(nameof(cache));
 }
コード例 #21
0
 public ResourceDeleteActivity(IAzureResourceService azureResourceService)
 {
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #22
0
 public ProjectSubscriptionVersionActivity(IAzureResourceService azureResourceService)
 {
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #23
0
 public ResourceGroupResetActivity(IAzureDeploymentService azureDeploymentService, IAzureResourceService azureResourceService)
 {
     this.azureDeploymentService = azureDeploymentService ?? throw new ArgumentNullException(nameof(azureDeploymentService));
     this.azureResourceService   = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #24
0
 public AzureResourceGroupContributorActivity(IAzureResourceService azureResourceService, IProjectsRepositoryReadOnly projectsRepository)
 {
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
     this.projectsRepository   = projectsRepository ?? throw new ArgumentNullException(nameof(projectsRepository));
 }
コード例 #25
0
 public AzureResourceGroup(Guid subscriptionId, string resourceGroupName, IAzureResourceService azureResourceService)
     : base(GetResourceId(subscriptionId, resourceGroupName), azureResourceService)
 {
 }
コード例 #26
0
 public ProjectIdentityDeleteActivity(IAzureDirectoryService azureDirectoryService, IAzureResourceService azureResourceService)
 {
     this.azureDirectoryService = azureDirectoryService ?? throw new ArgumentNullException(nameof(azureDirectoryService));
     this.azureResourceService  = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #27
0
 public ProjectResourcesTagActivity(IAzureResourceService azureResourceService)
 {
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }
コード例 #28
0
 public AzureSubscription(Guid subscriptionId, IAzureResourceService azureResourceService)
     : base(GetResourceId(subscriptionId), azureResourceService)
 {
 }
コード例 #29
0
 public ProjectResourcesAccessActivity(IAzureSessionService azureSessionService, IAzureResourceService azureResourceService, IProjectsRepository projectsRepository)
 {
     this.azureSessionService  = azureSessionService ?? throw new ArgumentNullException(nameof(azureSessionService));
     this.azureResourceService = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
     this.projectsRepository   = projectsRepository ?? throw new ArgumentNullException(nameof(projectsRepository));
 }
コード例 #30
0
 public ComponentTaskTerminateActivity(IComponentTaskRepository componentTaskRepository, IAzureResourceService azureResourceService)
 {
     this.componentTaskRepository = componentTaskRepository ?? throw new ArgumentNullException(nameof(componentTaskRepository));
     this.azureResourceService    = azureResourceService ?? throw new ArgumentNullException(nameof(azureResourceService));
 }