Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spaceship] add methods to rename and disable/enable devices #20928

Merged
merged 3 commits into from
Dec 16, 2022

Conversation

nekrich
Copy link
Contributor

@nekrich nekrich commented Dec 12, 2022

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

We want to fully automate device management on the Developer Portal, which includes renaming, enabling, and disabling devices.

Description

Implemented App Store Connect APIs Modify a Registered Device PATCH request.

Testing Steps

Spaceship::ConnectAPI::Device.disable("udid")
Spaceship::ConnectAPI::Device.enable("udid")
Spaceship::ConnectAPI::Device.rename("udid", "new name")

@getaaron
Copy link
Collaborator

Looks like find_by_udid doesn't actually need the platform param. I opened #20931 to remove it.

Co-authored-by: Aaron Brager <getaaron@gmail.com>
@nekrich
Copy link
Contributor Author

nekrich commented Dec 13, 2022

@getaaron , thanks for the review. Fixed everything I could 😅

@getaaron
Copy link
Collaborator

looks good! will merge after someone approves #20931

@getaaron getaaron merged commit 6ff1c49 into fastlane:master Dec 16, 2022
@getaaron
Copy link
Collaborator

Thanks again for adding this!

@rasberik
Copy link

rasberik commented May 12, 2023

Can someone confirm if it still works, I cant get it work with ConnectAPI

I am getting authentication error on network response for enable and disable (havent tried rename, but its all same request I believe) although Spaceship::ConnectAPI::Device.all is working as expected.

Had to use Spaceship.device.all(with same credentials) and then use enable! and disable! methods from spaceship/lib/spaceship/portal/device.rb, but unfortunately no renaming ability there

Flow that doesnt work:

Spaceship.login
Spaceship.select_team(team_id: valid_team_id)
devices = Spaceship::ConnectAPI::Device.all
puts devices.count # prints 74
devices.each do |device|
  Spaceship::ConnectAPI::Device.disable(device.udid) if some_boolean
end

This request is forbidden for security reasons - Please select a team.

5 of these errors:

#<Object:0x000000010747cfb8>
#<struct Faraday::Request http_method=:patch, path="devices/REDACTED_VALID_ID", params={}, headers={"User-Agent"=>"Spaceship 2.212.2", "csrf"=>"REDACTED_VALUE", "csrf_ts"=>"1683566312207", "Content-Type"=>"application/json"}, body="{\"data\":{\"attributes\":{\"name\":\"REDACTED_NAME\",\"status\":\"DISABLED\"},\"id\":\"REDACTED_VALID_ID\",\"type\":\"devices\"}}", options=#<Faraday::RequestOptions timeout=300, open_timeout=300>>
#<Object:0x0000000107472a90>

Flow that works:

Spaceship.login
Spaceship.select_team(team_id: valid_team_id)
devices = Spaceship.device.all(include_disabled: true)
puts devices.count # prints 74
devices.each do |device|
  device.disable! if some_boolean
end

@nekrich

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants