void SetupClient(IOctopusClient client)
 {
     client.Repository.LoadRootDocument().Returns(new RootResource()
     {
         Version = NotSupportedOctopusVersion
     });
 }
Exemplo n.º 2
0
        public static List <ProjectTriggerResource> FindAllProjectTriggers(this IOctopusClient client, ProjectResource project)
        {
            var items = new List <ProjectTriggerResource>();

            client.Paginate(project.Links["Triggers"], (ResourceCollection <ProjectTriggerResource> page) => { items.AddRange(page.Items); return(true); });
            return(items);
        }
Exemplo n.º 3
0
 public OctopusRepository(IOctopusClient client, RepositoryScope repositoryScope = null)
 {
     Client                    = client;
     Scope                     = repositoryScope ?? RepositoryScope.Unspecified();
     Accounts                  = new AccountRepository(this);
     ActionTemplates           = new ActionTemplateRepository(this);
     Artifacts                 = new ArtifactRepository(this);
     Backups                   = new BackupRepository(this);
     BuiltInPackageRepository  = new BuiltInPackageRepositoryRepository(this);
     CertificateConfiguration  = new CertificateConfigurationRepository(this);
     Certificates              = new CertificateRepository(this);
     Channels                  = new ChannelRepository(this);
     CommunityActionTemplates  = new CommunityActionTemplateRepository(this);
     Configuration             = new ConfigurationRepository(this);
     DashboardConfigurations   = new DashboardConfigurationRepository(this);
     Dashboards                = new DashboardRepository(this);
     Defects                   = new DefectsRepository(this);
     DeploymentProcesses       = new DeploymentProcessRepository(this);
     Deployments               = new DeploymentRepository(this);
     Environments              = new EnvironmentRepository(this);
     Events                    = new EventRepository(this);
     FeaturesConfiguration     = new FeaturesConfigurationRepository(this);
     Feeds                     = new FeedRepository(this);
     Interruptions             = new InterruptionRepository(this);
     LibraryVariableSets       = new LibraryVariableSetRepository(this);
     Lifecycles                = new LifecyclesRepository(this);
     MachinePolicies           = new MachinePolicyRepository(this);
     MachineRoles              = new MachineRoleRepository(this);
     Machines                  = new MachineRepository(this);
     Migrations                = new MigrationRepository(this);
     OctopusServerNodes        = new OctopusServerNodeRepository(this);
     PerformanceConfiguration  = new PerformanceConfigurationRepository(this);
     PackageMetadataRepository = new PackageMetadataRepository(this);
     ProjectGroups             = new ProjectGroupRepository(this);
     Projects                  = new ProjectRepository(this);
     ProjectTriggers           = new ProjectTriggerRepository(this);
     Proxies                   = new ProxyRepository(this);
     Releases                  = new ReleaseRepository(this);
     RetentionPolicies         = new RetentionPolicyRepository(this);
     Schedulers                = new SchedulerRepository(this);
     ServerStatus              = new ServerStatusRepository(this);
     Spaces                    = new SpaceRepository(this);
     Subscriptions             = new SubscriptionRepository(this);
     TagSets                   = new TagSetRepository(this);
     Tasks                     = new TaskRepository(this);
     Teams                     = new TeamsRepository(this);
     Tenants                   = new TenantRepository(this);
     TenantVariables           = new TenantVariablesRepository(this);
     UserRoles                 = new UserRolesRepository(this);
     Users                     = new UserRepository(this);
     VariableSets              = new VariableSetRepository(this);
     Workers                   = new WorkerRepository(this);
     WorkerPools               = new WorkerPoolRepository(this);
     ScopedUserRoles           = new ScopedUserRoleRepository(this);
     UserPermissions           = new UserPermissionsRepository(this);
     UserInvites               = new UserInvitesRepository(this);
     loadRootResource          = new Lazy <RootResource>(LoadRootDocumentInner, true);
     loadSpaceRootResource     = new Lazy <SpaceRootResource>(LoadSpaceRootDocumentInner, true);
 }
Exemplo n.º 4
0
 protected BasicRepository(IOctopusRepository repository, string collectionLinkName, Func <IOctopusRepository, string> getCollectionLinkName = null)
 {
     Repository                 = repository;
     client                     = repository.Client;
     CollectionLinkName         = collectionLinkName;
     AdditionalQueryParameters  = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
     this.getCollectionLinkName = getCollectionLinkName;
 }
Exemplo n.º 5
0
 static string DetermineCollectionLinkName(IOctopusClient client)
 {
     // For backwards compatibility.
     // In Octopus 3.11, what was Certificates was moved to CertificatesConfiguration, to make room for the certificates feature.
     // This allows pre-3.11 clients to still work.
     // The null check is just for tests.
     return(client.RootDocument == null || client.RootDocument.Links.ContainsKey("CertificateConfiguration")
         ? "CertificateConfiguration"
         : "Certificates");
 }
        /// <summary>
        /// Gathers the Interruptions tied to a Task
        /// </summary>
        /// <param name="client">The Repository this is tacked on to.</param>
        /// <param name="resourceId">The resource id to returns interruptions for.</param>
        /// <param name="pendingOnly">Returns only pending interruptions.</param>
        /// <returns>Enumerable of InterruptionResources.</returns>
        internal static IEnumerable <InterruptionResource> GetResourceInterruptions(this IOctopusClient client, string resourceId, bool pendingOnly)
        {
            var interruptions = new List <InterruptionResource>();

            client.Paginate <InterruptionResource>(string.Format(ResourceStrings.InterruptionRegardingLink, client.RootDocument.Link(ResourceStrings.InterruptionLink), resourceId, pendingOnly.ToString()), new { }, page =>
            {
                interruptions.AddRange(page.Items);
                return(true);
            });
            return(interruptions);
        }
        /// <summary>
        /// Gathers the Events tied to a resource for auditing.
        /// </summary>
        /// <param name="client">The Repository this is tacked on to.</param>
        /// <param name="resourceId">The resource id of the object for events returned.</param>
        /// <param name="eventCategory">The type of category of events returned [null returns all].</param>
        /// <returns>Enumerable of EventsResources.</returns>
        internal static IEnumerable <EventResource> GetResourceEvents(this IOctopusClient client, string resourceId, string eventCategory)
        {
            var events = new List <EventResource>();

            client.Paginate <EventResource>(string.Format(ResourceStrings.EventRegardingLink, client.RootDocument.Link(ResourceStrings.EventLink), resourceId, eventCategory), new { }, page =>
            {
                events.AddRange(page.Items);
                return(true);
            });
            return(events);
        }
        /// <summary>
        /// Gathers deployments based on release
        /// </summary>
        /// <param name="client">The Repository this is tacked on to.</param>
        /// <param name="release">The release to get deployments of.</param>
        /// <returns>Enumerable of Deployment Resources.</returns>
        internal static IEnumerable <DeploymentResource> GetReleaseDeployments(this IOctopusClient client, ReleaseResource release)
        {
            List <DeploymentResource> deployments = new List <DeploymentResource>();

            client.Paginate <DeploymentResource>(release.Link(ResourceStrings.DeploymentLink), new { }, page =>
            {
                deployments.AddRange(page.Items);
                return(true);
            });
            return(deployments);
        }
        /// <summary>
        /// Gathers the releases Tied to a channel.
        /// </summary>
        /// <param name="client">The Repository this is tacked on to.</param>
        /// <param name="channel">The channel to gather</param>
        /// <returns>Enumerable of Release Resources.</returns>
        internal static IEnumerable <ReleaseResource> GetChannelReleases(this IOctopusClient client, ChannelResource channel)
        {
            List <ReleaseResource> releases = new List <ReleaseResource>();

            client.Paginate <ReleaseResource>(channel.Link(ResourceStrings.ReleaseLink), new { }, page =>
            {
                releases.AddRange(page.Items);
                return(true);
            });
            return(releases);
        }
        /// <summary>
        /// Gets the Channels of the passed Project
        /// </summary>
        /// <param name="client">The Repository this is tacked on to.</param>
        /// <param name="project">The Project to get Channels of</param>
        /// <returns></returns>
        internal static IEnumerable <ChannelResource> GetProjectChannels(this IOctopusClient client, ProjectResource project)
        {
            List <ChannelResource> channels = new List <ChannelResource>();

            client.Paginate <ChannelResource>(project.Link(ResourceStrings.ChannelLink), new { }, page =>
            {
                channels.AddRange(page.Items);
                return(true);
            });
            return(channels);
        }
        /// <summary>
        /// Clones one project from another.
        /// </summary>
        /// <param name="client">The Repository this is tacked on to.</param>
        /// <param name="newProjectName">The new project's name.</param>
        /// <param name="newProjectDescription">The new project's description,</param>
        /// <param name="projectToClone">The project to clone from.</param>
        /// <param name="projectGroupIdForNewProject">The group the project will be placed into [null will copy the group from the projectToClone].</param>
        /// <param name="lifcycleId">The life cycle of the new project [null will copy the lifecycle from the projectToClone].</param>
        internal static void CloneProject(this IOctopusClient client, string newProjectName, string newProjectDescription, ProjectResource projectToClone, string projectGroupIdForNewProject, string lifcycleId)
        {
            var projectToCreate = new ProjectResource
            {
                Name           = newProjectName,
                Description    = newProjectDescription,
                ProjectGroupId = projectGroupIdForNewProject,
                LifecycleId    = lifcycleId
            };

            client.Post(string.Format(ResourceStrings.CloneCommandApiFormat, projectToClone.Id), projectToCreate);
        }
Exemplo n.º 12
0
        public OctopusRepository(IOctopusClient client)
        {
            this.Client = client;

            Accounts                 = new AccountRepository(client);
            ActionTemplates          = new ActionTemplateRepository(client);
            Artifacts                = new ArtifactRepository(client);
            Backups                  = new BackupRepository(client);
            BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client);
            CertificateConfiguration = new CertificateConfigurationRepository(client);
            Certificates             = new CertificateRepository(client);
            Channels                 = new ChannelRepository(client);
            CommunityActionTemplates = new CommunityActionTemplateRepository(client);
            Configuration            = new ConfigurationRepository(client);
            DashboardConfigurations  = new DashboardConfigurationRepository(client);
            Dashboards               = new DashboardRepository(client);
            Defects                  = new DefectsRepository(client);
            DeploymentProcesses      = new DeploymentProcessRepository(client);
            Deployments              = new DeploymentRepository(client);
            Environments             = new EnvironmentRepository(client);
            Events = new EventRepository(client);
            FeaturesConfiguration = new FeaturesConfigurationRepository(client);
            Feeds                    = new FeedRepository(client);
            Interruptions            = new InterruptionRepository(client);
            LibraryVariableSets      = new LibraryVariableSetRepository(client);
            Lifecycles               = new LifecyclesRepository(client);
            MachinePolicies          = new MachinePolicyRepository(client);
            MachineRoles             = new MachineRoleRepository(client);
            Machines                 = new MachineRepository(client);
            Migrations               = new MigrationRepository(client);
            OctopusServerNodes       = new OctopusServerNodeRepository(client);
            PerformanceConfiguration = new PerformanceConfigurationRepository(client);
            ProjectGroups            = new ProjectGroupRepository(client);
            Projects                 = new ProjectRepository(client);
            ProjectTriggers          = new ProjectTriggerRepository(client);
            Proxies                  = new ProxyRepository(client);
            Releases                 = new ReleaseRepository(client);
            RetentionPolicies        = new RetentionPolicyRepository(client);
            Schedulers               = new SchedulerRepository(client);
            ServerStatus             = new ServerStatusRepository(client);
            Subscriptions            = new SubscriptionRepository(client);
            TagSets                  = new TagSetRepository(client);
            Tasks                    = new TaskRepository(client);
            Teams                    = new TeamsRepository(client);
            Tenants                  = new TenantRepository(client);
            TenantVariables          = new TenantVariablesRepository(client);
            UserRoles                = new UserRolesRepository(client);
            Users                    = new UserRepository(client);
            VariableSets             = new VariableSetRepository(client);
            Workers                  = new WorkerRepository(client);
            WorkerPools              = new WorkerPoolRepository(client);
        }
        /// <summary>
        /// Gathers the Users from a Team.
        /// </summary>
        /// <param name="client">The Repository this is tacked on to.</param>
        /// <param name="team">The team to return the user resources from.</param>
        /// <returns>Enumerable of UserResources.</returns>
        internal static IEnumerable <UserResource> GetTeamUsers(this IOctopusClient client, TeamResource team)
        {
            List <UserResource> users = new List <UserResource>();

            foreach (var userId in team.MemberUserIds)
            {
                var user = client.Get <UserResource>(string.Format(ResourceStrings.TeamUserIdFormat, userId));
                if (user != null)
                {
                    users.Add(user);
                }
            }
            return(users);
        }
Exemplo n.º 14
0
        private void Assertion(IOctopusClient client)
        {
            var repository      = new OctopusRepository(client);
            var nullPropertiesQ = from p in typeof(OctopusRepository).GetProperties()
                                  where !delayInitialisedProperties.Contains(p.Name)
                                  where p.GetMethod.Invoke(repository, new object[0]) == null
                                  select p.Name;

            var nullProperties = nullPropertiesQ.ToArray();

            if (nullProperties.Any())
            {
                Assert.Fail("The following properties are null after OctopusAsyncRepository instantiation: " + nullProperties.CommaSeperate());
            }
        }
Exemplo n.º 15
0
 public OctopusRepository(IOctopusClient client)
 {
     this.Client = client;
     Feeds = new FeedRepository(client);
     Backups = new BackupRepository(client);
     Machines = new MachineRepository(client);
     MachineRoles = new MachineRoleRepository(client);
     MachinePolicies = new MachinePolicyRepository(client);
     Subscriptions = new SubscriptionRepository(client);
     Environments = new EnvironmentRepository(client);
     Events = new EventRepository(client);
     FeaturesConfiguration = new FeaturesConfigurationRepository(client);
     ProjectGroups = new ProjectGroupRepository(client);
     Projects = new ProjectRepository(client);
     Proxies = new ProxyRepository(client);
     Tasks = new TaskRepository(client);
     Users = new UserRepository(client);
     VariableSets = new VariableSetRepository(client);
     LibraryVariableSets = new LibraryVariableSetRepository(client);
     DeploymentProcesses = new DeploymentProcessRepository(client);
     Releases = new ReleaseRepository(client);
     Deployments = new DeploymentRepository(client);
     Certificates = new CertificateRepository(client);
     Dashboards = new DashboardRepository(client);
     DashboardConfigurations = new DashboardConfigurationRepository(client);
     Artifacts = new ArtifactRepository(client);
     Interruptions = new InterruptionRepository(client);
     ServerStatus = new ServerStatusRepository(client);
     UserRoles = new UserRolesRepository(client);
     Teams = new TeamsRepository(client);
     RetentionPolicies = new RetentionPolicyRepository(client);
     Accounts = new AccountRepository(client);
     Defects = new DefectsRepository(client);
     Lifecycles = new LifecyclesRepository(client);
     OctopusServerNodes = new OctopusServerNodeRepository(client);
     Channels = new ChannelRepository(client);
     ProjectTriggers = new ProjectTriggerRepository(client);
     Schedulers = new SchedulerRepository(client);
     Tenants = new TenantRepository(client);
     TagSets = new TagSetRepository(client);
     BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client);
     ActionTemplates = new ActionTemplateRepository(client);
     CommunityActionTemplates = new CommunityActionTemplateRepository(client);
 }
Exemplo n.º 16
0
        public void SetUp()
        {
            clientFactory = Substitute.For <IOctopusClientFactory>();
            client        = Substitute.For <IOctopusClient>();
            clientFactory.CreateClient(Arg.Any <OctopusServerEndpoint>()).Returns(client);
            operation      = new RegisterMachineOperation(clientFactory);
            serverEndpoint = new OctopusServerEndpoint("http://octopus", "ABC123");

            environments = new ResourceCollection <EnvironmentResource>(new EnvironmentResource[0], LinkCollection.Self("/foo"));
            machines     = new ResourceCollection <MachineResource>(new MachineResource[0], LinkCollection.Self("/foo"));
            client.RootDocument.Returns(new RootResource {
                Links = LinkCollection.Self("/api").Add("Environments", "/api/environments").Add("Machines", "/api/machines")
            });

            client.When(x => x.Paginate(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <Func <ResourceCollection <EnvironmentResource>, bool> >()))
            .Do(ci => ci.Arg <Func <ResourceCollection <EnvironmentResource>, bool> >()(environments));

            client.When(x => x.Paginate(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <Func <ResourceCollection <MachineResource>, bool> >()))
            .Do(ci => ci.Arg <Func <ResourceCollection <MachineResource>, bool> >()(machines));

            client.List <MachineResource>(Arg.Any <string>(), Arg.Any <object>()).Returns(machines);
        }
 public UserRepository(IOctopusClient client)
     : base(client, "Users")
 {
     invitations = new InvitationRepository(client);
 }
Exemplo n.º 18
0
 public WorkerRepository(IOctopusClient client) : base(client, "Workers")
 {
 }
Exemplo n.º 19
0
 public MachineRoleRepository(IOctopusClient client)
 {
     this.client = client;
 }
 public OctopusServerNodeRepository(IOctopusClient client)
     : base(client, "OctopusServerNodes")
 {
 }
 protected BasicRepository(IOctopusClient client, string collectionLinkName)
 {
     this.client             = client;
     this.CollectionLinkName = collectionLinkName;
 }
Exemplo n.º 22
0
 public MachineRoleRepository(IOctopusClient client)
 {
     this.client = client;
 }
 public ConfigurationRepository(IOctopusClient client)
 {
     this.client             = client;
     this.collectionLinkName = "Configuration";
 }
Exemplo n.º 24
0
 public TaskRepository(IOctopusClient client)
     : base(client, "Tasks")
 {
 }
 public TenantVariablesRepository(IOctopusClient client)
     : base(client, "TenantVariables")
 {
 }
 public DashboardConfigurationRepository(IOctopusClient client)
 {
     this.client = client;
 }
Exemplo n.º 27
0
 public SchedulerRepository(IOctopusClient client)
 {
     this.client = client;
 }
 public FeaturesConfigurationRepository(IOctopusClient client)
 {
     this.client = client;
 }
Exemplo n.º 29
0
 public DashboardRepository(IOctopusClient client)
 {
     this.client = client;
 }
Exemplo n.º 30
0
 public ProjectGroupRepository(IOctopusClient client)
     : base(client, "ProjectGroups")
 {
 }
 public BuiltInPackageRepositoryRepository(IOctopusClient client)
 {
     this.client = client;
 }
Exemplo n.º 32
0
 public AccountRepository(IOctopusClient client)
     : base(client, "Accounts")
 {
 }
 public BuiltInPackageRepositoryRepository(IOctopusClient client)
 {
     this.client = client;
 }
 public MachinePolicyRepository(IOctopusClient client) : base(client, "MachinePolicies")
 {
 }
Exemplo n.º 35
0
 public TenantRepository(IOctopusClient client)
     : base(client, "Tenants")
 {
 }
 public ActionTemplateRepository(IOctopusClient client)
 {
     this.client = client;
     templatesPath = client.RootDocument.Link("ActionTemplates");
 }
 public DeploymentRepository(IOctopusClient client)
     : base(client, "Deployments")
 {
 }
Exemplo n.º 38
0
 public ProxyRepository(IOctopusClient client)
     : base(client, "Proxies")
 {
 }
Exemplo n.º 39
0
 public BackupRepository(IOctopusClient client)
 {
     this.client = client;
 }