Octopus.Client Teams.FindByName

Hello,

I’m trying to build out a script to update Teams properties (UserRoles). Teams.FindByName($teamName) returns nothing. I can do a Teams.FindAll and retrieve what appears to be the first 10. I have been searching for documentation on the parameters for FindByName/FindAll, but having no luck. I suspect something like skip,take in the REST API. Is there documentation for these and other methods?

($repositoryForSpace.Teams.FindAll()).Count
10

Hi @azdw24,

Thanks for getting in touch! I’m sorry to see you’re hitting this unexpected behavior. I gave this a test locally (running version 2022.3.10382) and my $repository.Teams.FindByName($teamName) looks to return the one team correctly, as shown in the following screenshot.

I’m hoping some additional information will help us identify the issue in your instance. Could you let me know your Octopus version? Would you be willing to share the sanitized script you’re running?

I look forward to hearing back and getting to the bottom of this one!

Best regards,

Kenny

Hello Kenny,

Thanks for responding. This would be v2021.1 (Build 7316). I can select one of the top 10 and get a good response. It seems like maybe pagination of some sort. I haven’t been able find documentation on the parameters for Octopus.Client to return all records. Unless the length of the team name is an issue. For the script, I’m basically reusing the following:

https://github.com/OctopusDeploy/OctopusDeploy-Api/blob/51e99f88262e24705b054b6f4704f0cd719e9524/Octopus.Client/PowerShell/Teams/AddEnvironmentToTeam.ps1



|
OctopusDeploy-Api/AddEnvironmentToTeam.ps1 at 51e99f88262e24705b054b6f4704f0cd719e9524 · OctopusDeploy/OctopusDeploy-Api
Code snippet samples for various operations in the Octopus Deploy REST API - OctopusDeploy-Api/AddEnvironmentToTeam.ps1 at 51e99f88262e24705b054b6f4704f0cd719e9524 · OctopusDeploy/OctopusDeploy-Api
github.com
|

  • | - |

I know I’ve had to deal with this in a REST call “/api/teams/Teams-181/scopeduserroles{?skip,take}” but need to understand parameter for the Octopus.Client.

Thanks,
Dan

Hi @azdw24

I’ve just tried this on my test Octopus.Client solution and I can successfully retrieve a list of 13 teams for a space using the Teams.FindAll() method.

I noticed that the Count was an extension method when pushing the TeamResources into an IEnumerable list. I would assume this would be the same using the Client outside of a .Net environment:

Is it possible for you to share your code/script file so we can test it out on our side?

Kind Regards
Sean