Skip to content

Commit

Permalink
Migrate APIStatus model to OpenAPI-gen model (#995)
Browse files Browse the repository at this point in the history
* Migrate APIStatus model to OpenAPI-gen model

* Skip datafeed codegen

* Remove API deserializer test
  • Loading branch information
bherbst authored Jan 18, 2025
1 parent 538ce3d commit e9a9cf6
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 615 deletions.
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ task checkstyle(type: Checkstyle) {
dependencies {
implementation project(':libTba')
implementation project(':libImgur')
implementation project(':tba-api')

// Android support libraries
implementation("androidx.activity:activity:1.9.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
import android.view.Menu;
import android.view.MenuItem;

import androidx.annotation.Nullable;

import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.datafeed.refresh.RefreshController;
import com.thebluealliance.androidclient.datafeed.status.TBAStatusController;
import com.thebluealliance.androidclient.eventbus.ConnectivityChangeEvent;
import com.thebluealliance.androidclient.interfaces.InvalidateHost;
import com.thebluealliance.androidclient.models.ApiStatus;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import javax.inject.Inject;

import androidx.annotation.Nullable;
import dagger.hilt.android.AndroidEntryPoint;
import thebluealliance.api.model.APIStatus;

/**
* An activity that serves as a host to datafeed fragments
Expand Down Expand Up @@ -79,7 +78,7 @@ public RefreshController getRefreshController() {
protected void onResume() {
super.onResume();
mEventBus.register(this);
ApiStatus status = mStatusController.fetchApiStatus();
APIStatus status = mStatusController.fetchApiStatus();
commonStatusUpdate(status);
}

Expand All @@ -89,12 +88,12 @@ protected void onPause() {
mEventBus.unregister(this);
}

private void commonStatusUpdate(@Nullable ApiStatus newStatus) {
private void commonStatusUpdate(@Nullable APIStatus newStatus) {
if (newStatus == null) {
return;
}

if (newStatus.getFmsApiDown()) {
if (newStatus.getIsDatafeedDown()) {
// Everything is broken
showWarningMessage(BaseActivity.WARNING_FIRST_API_DOWN);
} else {
Expand All @@ -110,7 +109,7 @@ private void commonStatusUpdate(@Nullable ApiStatus newStatus) {
*
* @param newStatus The new API Status
*/
protected void onTbaStatusUpdate(ApiStatus newStatus) {
protected void onTbaStatusUpdate(APIStatus newStatus) {
// Default to do nothing
}

Expand All @@ -130,7 +129,7 @@ public void onConnectivityChanged(ConnectivityChangeEvent event) {
*/
@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onApiStatusUpdated(ApiStatus tbaStatus) {
public void onApiStatusUpdated(APIStatus tbaStatus) {
commonStatusUpdate(tbaStatus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.NavUtils;
import androidx.core.app.TaskStackBuilder;
import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.ViewPager;

import com.google.common.collect.ImmutableList;
import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.ShareUris;
Expand All @@ -33,7 +25,6 @@
import com.thebluealliance.androidclient.helpers.EventTeamHelper;
import com.thebluealliance.androidclient.helpers.TeamHelper;
import com.thebluealliance.androidclient.interfaces.EventsParticipatedUpdate;
import com.thebluealliance.androidclient.models.ApiStatus;
import com.thebluealliance.androidclient.models.Event;
import com.thebluealliance.androidclient.subscribers.EventsParticipatedDropdownSubscriber;
import com.thebluealliance.androidclient.types.ModelType;
Expand All @@ -47,8 +38,16 @@

import javax.inject.Inject;

import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.NavUtils;
import androidx.core.app.TaskStackBuilder;
import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.ViewPager;
import dagger.hilt.android.AndroidEntryPoint;
import rx.schedulers.Schedulers;
import thebluealliance.api.model.APIStatus;

@AndroidEntryPoint
public class TeamAtEventActivity extends MyTBASettingsActivity
Expand Down Expand Up @@ -293,7 +292,7 @@ public void updateTeamAvatar(TeamAvatarUpdateEvent avatarUpdateEvent) {
}

@Override
protected void onTbaStatusUpdate(ApiStatus newStatus) {
protected void onTbaStatusUpdate(APIStatus newStatus) {
super.onTbaStatusUpdate(newStatus);
if (newStatus.getDownEvents().contains(mEventKey)) {
// This event is down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
import android.os.Bundle;
import android.view.MenuItem;

import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.ViewPager;

import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.ShareUris;
import com.thebluealliance.androidclient.TbaLogger;
Expand All @@ -17,14 +13,17 @@
import com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent;
import com.thebluealliance.androidclient.helpers.ConnectionDetector;
import com.thebluealliance.androidclient.helpers.EventHelper;
import com.thebluealliance.androidclient.models.ApiStatus;
import com.thebluealliance.androidclient.types.ModelType;
import com.thebluealliance.androidclient.views.SlidingTabs;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.ViewPager;
import dagger.hilt.android.AndroidEntryPoint;
import thebluealliance.api.model.APIStatus;

@AndroidEntryPoint
public class ViewEventActivity extends MyTBASettingsActivity
Expand Down Expand Up @@ -213,7 +212,7 @@ public void scrollToTab(int tab) {
}

@Override
protected void onTbaStatusUpdate(ApiStatus newStatus) {
protected void onTbaStatusUpdate(APIStatus newStatus) {
super.onTbaStatusUpdate(newStatus);
if (newStatus.getDownEvents().contains(mEventKey)) {
// This event is down
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.thebluealliance.androidclient.api.call;



import com.thebluealliance.androidclient.models.ApiStatus;
import com.thebluealliance.androidclient.models.Award;
import com.thebluealliance.androidclient.models.District;
import com.thebluealliance.androidclient.models.DistrictRanking;
Expand All @@ -18,6 +16,7 @@
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import thebluealliance.api.model.APIStatus;

@Deprecated
public interface TbaApiV2 {
Expand All @@ -28,7 +27,7 @@ public interface TbaApiV2 {
*/

@GET("api/v2/status")
Call<ApiStatus> fetchApiStatus();
Call<APIStatus> fetchApiStatus();


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
package com.thebluealliance.androidclient.api.call;



import retrofit2.Call;
import retrofit2.http.*;

import okhttp3.RequestBody;

import com.thebluealliance.androidclient.models.ApiStatus;
import com.thebluealliance.androidclient.models.Event;
import com.thebluealliance.androidclient.models.Award;
import com.thebluealliance.androidclient.models.District;
import com.thebluealliance.androidclient.models.DistrictRanking;
import com.thebluealliance.androidclient.models.Team;
import com.thebluealliance.androidclient.models.Event;
import com.thebluealliance.androidclient.models.EventAlliance;
import com.thebluealliance.androidclient.models.Award;
import com.thebluealliance.androidclient.models.Match;
import com.thebluealliance.androidclient.models.RankingResponseObject;
import com.thebluealliance.androidclient.models.TeamAtEventStatus;
import com.thebluealliance.androidclient.models.Media;
import com.thebluealliance.androidclient.models.RankingResponseObject;
import com.thebluealliance.androidclient.models.Robot;
import com.thebluealliance.androidclient.models.Team;
import com.thebluealliance.androidclient.models.TeamAtEventStatus;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import thebluealliance.api.model.APIStatus;

public interface TbaApiV3 {
/**
Expand All @@ -33,7 +29,7 @@ public interface TbaApiV3 {
*/

@GET("api/v3/status")
Call<ApiStatus> fetchApiStatus();
Call<APIStatus> fetchApiStatus();


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.thebluealliance.androidclient.api.rx;

import com.google.gson.JsonElement;
import com.thebluealliance.androidclient.models.ApiStatus;
import com.thebluealliance.androidclient.models.Award;
import com.thebluealliance.androidclient.models.District;
import com.thebluealliance.androidclient.models.DistrictRanking;
Expand All @@ -18,6 +17,7 @@
import retrofit2.http.Header;
import retrofit2.http.Path;
import rx.Observable;
import thebluealliance.api.model.APIStatus;

@Deprecated
public interface TbaApiV2 {
Expand All @@ -28,7 +28,7 @@ public interface TbaApiV2 {
*/

@GET("api/v2/status")
Observable<Response<ApiStatus>> fetchApiStatus();
Observable<Response<APIStatus>> fetchApiStatus();


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
package com.thebluealliance.androidclient.api.rx;

import com.google.gson.JsonElement;
import rx.Observable;
import retrofit2.Response;

import retrofit2.http.*;

import okhttp3.RequestBody;

import com.thebluealliance.androidclient.models.ApiStatus;
import com.thebluealliance.androidclient.models.Event;
import com.thebluealliance.androidclient.models.Award;
import com.thebluealliance.androidclient.models.District;
import com.thebluealliance.androidclient.models.DistrictRanking;
import com.thebluealliance.androidclient.models.Team;
import com.thebluealliance.androidclient.models.Event;
import com.thebluealliance.androidclient.models.EventAlliance;
import com.thebluealliance.androidclient.models.Award;
import com.thebluealliance.androidclient.models.Match;
import com.thebluealliance.androidclient.models.RankingResponseObject;
import com.thebluealliance.androidclient.models.TeamAtEventStatus;
import com.thebluealliance.androidclient.models.Media;
import com.thebluealliance.androidclient.models.RankingResponseObject;
import com.thebluealliance.androidclient.models.Robot;
import com.thebluealliance.androidclient.models.Team;
import com.thebluealliance.androidclient.models.TeamAtEventStatus;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import retrofit2.Response;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import rx.Observable;
import thebluealliance.api.model.APIStatus;

public interface TbaApiV3 {
/**
Expand All @@ -34,7 +30,7 @@ public interface TbaApiV3 {
*/

@GET("api/v3/status")
Observable<Response<ApiStatus>> fetchApiStatus();
Observable<Response<APIStatus>> fetchApiStatus();


/**
Expand Down
Loading

0 comments on commit e9a9cf6

Please sign in to comment.