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

[AutoPR sql/resource-manager] Add resource group based LTR API #4341

Merged
merged 1 commit into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ public interface LongTermRetentionBackups extends HasInner<LongTermRetentionBack
/**
* Lists the long term retention backups for a given location.
*
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
* @param locationName The location of the database
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<LongTermRetentionBackup> listByLocationAsync(final String locationName);
Observable<LongTermRetentionBackup> listByResourceGroupLocationAsync(final String resourceGroupName, final String locationName);

/**
* Lists the long term retention backups for a given server.
*
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
* @param locationName The location of the database
* @param longTermRetentionServerName The name of the server
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<LongTermRetentionBackup> listByServerAsync(final String locationName, final String longTermRetentionServerName);
Observable<LongTermRetentionBackup> listByResourceGroupServerAsync(final String resourceGroupName, final String locationName, final String longTermRetentionServerName);

/**
* Gets a long term retention backup.
Expand All @@ -48,6 +50,18 @@ public interface LongTermRetentionBackups extends HasInner<LongTermRetentionBack
*/
Observable<LongTermRetentionBackup> getAsync(String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName);

/**
* Deletes a long term retention backup.
*
* @param locationName The location of the database
* @param longTermRetentionServerName The name of the server
* @param longTermRetentionDatabaseName The name of the database
* @param backupName The backup name.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Completable deleteAsync(String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName);

/**
* Lists all long term retention backups for a database.
*
Expand All @@ -59,16 +73,61 @@ public interface LongTermRetentionBackups extends HasInner<LongTermRetentionBack
*/
Observable<LongTermRetentionBackup> listByDatabaseAsync(final String locationName, final String longTermRetentionServerName, final String longTermRetentionDatabaseName);

/**
* Lists the long term retention backups for a given location.
*
* @param locationName The location of the database
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<LongTermRetentionBackup> listByLocationAsync(final String locationName);

/**
* Lists the long term retention backups for a given server.
*
* @param locationName The location of the database
* @param longTermRetentionServerName The name of the server
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<LongTermRetentionBackup> listByServerAsync(final String locationName, final String longTermRetentionServerName);

/**
* Gets a long term retention backup.
*
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
* @param locationName The location of the database.
* @param longTermRetentionServerName The name of the server
* @param longTermRetentionDatabaseName The name of the database
* @param backupName The backup name.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<LongTermRetentionBackup> getByResourceGroupAsync(String resourceGroupName, String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName);

/**
* Lists all long term retention backups for a database.
*
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
* @param locationName The location of the database
* @param longTermRetentionServerName The name of the server
* @param longTermRetentionDatabaseName The name of the database
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<LongTermRetentionBackup> listByResourceGroupDatabaseAsync(final String resourceGroupName, final String locationName, final String longTermRetentionServerName, final String longTermRetentionDatabaseName);

/**
* Deletes a long term retention backup.
*
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
* @param locationName The location of the database
* @param longTermRetentionServerName The name of the server
* @param longTermRetentionDatabaseName The name of the database
* @param backupName The backup name.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Completable deleteAsync(String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName);
Completable deleteByResourceGroupAsync(String resourceGroupName, String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName);

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

class LongTermRetentionBackupImpl extends IndexableRefreshableWrapperImpl<LongTermRetentionBackup, LongTermRetentionBackupInner> implements LongTermRetentionBackup {
private final SqlManager manager;
private String resourceGroupName;
private String locationName;
private String longTermRetentionServerName;
private String longTermRetentionDatabaseName;
Expand All @@ -23,6 +24,7 @@ class LongTermRetentionBackupImpl extends IndexableRefreshableWrapperImpl<LongTe
LongTermRetentionBackupImpl(LongTermRetentionBackupInner inner, SqlManager manager) {
super(null, inner);
this.manager = manager;
this.resourceGroupName = IdParsingUtils.getValueFromIdByName(inner.id(), "resourceGroups");
this.locationName = IdParsingUtils.getValueFromIdByName(inner.id(), "locations");
this.longTermRetentionServerName = IdParsingUtils.getValueFromIdByName(inner.id(), "longTermRetentionServers");
this.longTermRetentionDatabaseName = IdParsingUtils.getValueFromIdByName(inner.id(), "longTermRetentionDatabases");
Expand All @@ -37,7 +39,7 @@ public SqlManager manager() {
@Override
protected Observable<LongTermRetentionBackupInner> getInnerAsync() {
LongTermRetentionBackupsInner client = this.manager().inner().longTermRetentionBackups();
return client.getAsync(this.locationName, this.longTermRetentionServerName, this.longTermRetentionDatabaseName, this.backupName);
return client.getByResourceGroupAsync(this.resourceGroupName, this.locationName, this.longTermRetentionServerName, this.longTermRetentionDatabaseName, this.backupName);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,78 @@ private LongTermRetentionBackupImpl wrapModel(LongTermRetentionBackupInner inner
return new LongTermRetentionBackupImpl(inner, manager());
}

@Override
public Observable<LongTermRetentionBackup> listByResourceGroupLocationAsync(final String resourceGroupName, final String locationName) {
LongTermRetentionBackupsInner client = this.inner();
return client.listByResourceGroupLocationAsync(resourceGroupName, locationName)
.flatMapIterable(new Func1<Page<LongTermRetentionBackupInner>, Iterable<LongTermRetentionBackupInner>>() {
@Override
public Iterable<LongTermRetentionBackupInner> call(Page<LongTermRetentionBackupInner> page) {
return page.items();
}
})
.map(new Func1<LongTermRetentionBackupInner, LongTermRetentionBackup>() {
@Override
public LongTermRetentionBackup call(LongTermRetentionBackupInner inner) {
return new LongTermRetentionBackupImpl(inner, manager());
}
});
}

@Override
public Observable<LongTermRetentionBackup> listByResourceGroupServerAsync(final String resourceGroupName, final String locationName, final String longTermRetentionServerName) {
LongTermRetentionBackupsInner client = this.inner();
return client.listByResourceGroupServerAsync(resourceGroupName, locationName, longTermRetentionServerName)
.flatMapIterable(new Func1<Page<LongTermRetentionBackupInner>, Iterable<LongTermRetentionBackupInner>>() {
@Override
public Iterable<LongTermRetentionBackupInner> call(Page<LongTermRetentionBackupInner> page) {
return page.items();
}
})
.map(new Func1<LongTermRetentionBackupInner, LongTermRetentionBackup>() {
@Override
public LongTermRetentionBackup call(LongTermRetentionBackupInner inner) {
return new LongTermRetentionBackupImpl(inner, manager());
}
});
}

@Override
public Observable<LongTermRetentionBackup> getAsync(String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName) {
LongTermRetentionBackupsInner client = this.inner();
return client.getAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName)
.map(new Func1<LongTermRetentionBackupInner, LongTermRetentionBackup>() {
@Override
public LongTermRetentionBackup call(LongTermRetentionBackupInner inner) {
return new LongTermRetentionBackupImpl(inner, manager());
}
});
}

@Override
public Completable deleteAsync(String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName) {
LongTermRetentionBackupsInner client = this.inner();
return client.deleteAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName).toCompletable();
}

@Override
public Observable<LongTermRetentionBackup> listByDatabaseAsync(final String locationName, final String longTermRetentionServerName, final String longTermRetentionDatabaseName) {
LongTermRetentionBackupsInner client = this.inner();
return client.listByDatabaseAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName)
.flatMapIterable(new Func1<Page<LongTermRetentionBackupInner>, Iterable<LongTermRetentionBackupInner>>() {
@Override
public Iterable<LongTermRetentionBackupInner> call(Page<LongTermRetentionBackupInner> page) {
return page.items();
}
})
.map(new Func1<LongTermRetentionBackupInner, LongTermRetentionBackup>() {
@Override
public LongTermRetentionBackup call(LongTermRetentionBackupInner inner) {
return new LongTermRetentionBackupImpl(inner, manager());
}
});
}

@Override
public Observable<LongTermRetentionBackup> listByLocationAsync(final String locationName) {
LongTermRetentionBackupsInner client = this.inner();
Expand Down Expand Up @@ -70,9 +142,9 @@ public LongTermRetentionBackup call(LongTermRetentionBackupInner inner) {
}

@Override
public Observable<LongTermRetentionBackup> listByDatabaseAsync(final String locationName, final String longTermRetentionServerName, final String longTermRetentionDatabaseName) {
public Observable<LongTermRetentionBackup> listByResourceGroupDatabaseAsync(final String resourceGroupName, final String locationName, final String longTermRetentionServerName, final String longTermRetentionDatabaseName) {
LongTermRetentionBackupsInner client = this.inner();
return client.listByDatabaseAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName)
return client.listByResourceGroupDatabaseAsync(resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName)
.flatMapIterable(new Func1<Page<LongTermRetentionBackupInner>, Iterable<LongTermRetentionBackupInner>>() {
@Override
public Iterable<LongTermRetentionBackupInner> call(Page<LongTermRetentionBackupInner> page) {
Expand All @@ -88,9 +160,9 @@ public LongTermRetentionBackup call(LongTermRetentionBackupInner inner) {
}

@Override
public Observable<LongTermRetentionBackup> getAsync(String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName) {
public Observable<LongTermRetentionBackup> getByResourceGroupAsync(String resourceGroupName, String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName) {
LongTermRetentionBackupsInner client = this.inner();
return client.getAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName)
return client.getByResourceGroupAsync(resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName)
.map(new Func1<LongTermRetentionBackupInner, LongTermRetentionBackup>() {
@Override
public LongTermRetentionBackup call(LongTermRetentionBackupInner inner) {
Expand All @@ -100,9 +172,9 @@ public LongTermRetentionBackup call(LongTermRetentionBackupInner inner) {
}

@Override
public Completable deleteAsync(String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName) {
public Completable deleteByResourceGroupAsync(String resourceGroupName, String locationName, String longTermRetentionServerName, String longTermRetentionDatabaseName, String backupName) {
LongTermRetentionBackupsInner client = this.inner();
return client.deleteAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName).toCompletable();
return client.deleteByResourceGroupAsync(resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName).toCompletable();
}

}
Loading