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

Implement cloudsql #274

Merged
merged 10 commits into from
Oct 9, 2024
Merged

Implement cloudsql #274

merged 10 commits into from
Oct 9, 2024

Conversation

harjain99
Copy link
Contributor

No description provided.


if (getReplicationCluster() != null) {
throw new GyroException(
"The 'replication-cluster' field is not supported for creating a new instance. It can only be configured in an update call.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than throwing the error, we should follow up with an update call to handle this, rather than making the user do gyro up again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that problem here is that there is a sort of circular dependency. To set this value, a replica of the primary instance (which is basically another DatabaseInstanceResource) needs to be created first which then needs to be added back to the primary instance.
I don't think an update call would solve the issue here unfortunately.

databaseInstance.setSwitchTransactionLogsToCloudStorageEnabled(getSwitchTransactionLogsToCloudStorageEnabled());
}

client.instances().insert(getProjectId(), databaseInstance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there other resources that might need this resource ?
Asking to know if a thought to a wait function was given

Copy link
Contributor Author

@harjain99 harjain99 Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added waits

Comment on lines 73 to 77
return String.format(
"Acl Entry [Value: %s, Expiration Time: %s, Name: %s]",
getValue(),
getExpirationTime(),
getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will look funky if only the value is provided.
We should probably create this string conditionally

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a stringbuilder to construct the key

* The start time for the daily backup configuration in UTC timezone in the 24 hour format - `HH:MM`.
*/
@Updatable
@Regex("[0-2][0-9]:[0-5][0-9]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the hour regex will fail, 25-29 will be valid by this regex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


setBackupRetentionSettings(null);
if (model.getBackupRetentionSettings() != null) {
DbBackupRetentionSettings settings = new DbBackupRetentionSettings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new subresource ?

Copy link
Contributor

@deepanjan90 deepanjan90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the copyFrom() should have suberesource object created with newSubresource declarations

public InsightsConfig toInsightsConfig() {
InsightsConfig config = new InsightsConfig();

if (getQueryInsightsEnabled() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this field is a required value, this will never be a null conditional right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}

/**
* The list of external networks that are allowed to connect to the instance using the IP.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc entry with @subresource

Comment on lines +69 to +74
if (getSecondaryZone() != null) {
preference.setSecondaryZone(getSecondaryZone());
}
if (getZone() != null) {
preference.setZone(getZone());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of them are required, that will create a blank class ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api lets you set these to null and still has default values for them.

Comment on lines +88 to +98
if (getDay() != null) {
window.setDay(getDay());
}

if (getHour() != null) {
window.setHour(getHour());
}

if (getUpdateTrack() != null) {
window.setUpdateTrack(getUpdateTrack());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, none of them are required will that create a blank class and process ?

import gyro.core.resource.Diffable;
import gyro.google.Copyable;

public class DbMySqlReplicaConfiguration extends Diffable implements Copyable<MySqlReplicaConfiguration> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any required/updatable fields ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like it from the sdk

import gyro.core.resource.Diffable;
import gyro.google.Copyable;

public class DbOnPremisesConfiguration extends Diffable implements Copyable<OnPremisesConfiguration> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any required/updatable fields ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like it from the sdk


public PasswordValidationPolicy toPasswordValidationPolicy() {
PasswordValidationPolicy policy = new PasswordValidationPolicy();
policy.setEnablePasswordPolicy(getEnablePasswordPolicy());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the rest of the configuration still allowed if this is set to false ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added validation


public PscConfig toPscConfig() {
PscConfig config = new PscConfig();
config.setPscEnabled(getPscEnabled());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is set to false can you still set the projects ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Validation

* Only for Enterprise Plus edition instances.
*/
@Updatable
public String getFailoverDrReplicaName() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably be required, given it is the only settable field in this class


public Settings toSettings() {
Settings settings = new Settings();
settings.setSettingsVersion(getSettingsVersion());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably be a required field then.

Also given this is a db settings, re check to see if there are other fields that are required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The settings version is an output field so I don't think it's need the annotation.
It just needs to be provided on every update call.

The tier is basically the only thing required other than the name.

Comment on lines +81 to +83
config.setCanReschedule(getCanReschedule());
config.setScheduleDeadlineTime(getScheduleDeadlineTime());
config.setStartTime(getStartTime());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can all of these be set to null, given none of this is required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api doesn't seem to complain even if they are all set to null values.

Copy link
Contributor

@deepanjan90 deepanjan90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the copyFrom() should have suberesource object created with newSubresource declarations.

Double check all the docs for subresource to make sure they have the doc entry with @subresource

@harjain99 harjain99 mentioned this pull request Oct 7, 2024
@harjain99 harjain99 reopened this Oct 7, 2024
@harjain99 harjain99 merged commit 0f2b16d into master Oct 9, 2024
2 checks passed
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.

2 participants