Skip to content

Commit

Permalink
Refatcor API client
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-alhuang committed Jun 27, 2024
1 parent 44cc28e commit 30dda19
Show file tree
Hide file tree
Showing 25 changed files with 1,031 additions and 678 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Snowflake Computing Inc. All rights reserved.
* Copyright (c) 2021-2024 Snowflake Computing Inc. All rights reserved.
*/

package net.snowflake.ingest.streaming;
Expand Down Expand Up @@ -150,7 +150,7 @@ public ZoneId getDefaultTimezone() {
}

public String getFullyQualifiedTableName() {
return String.format("%s.%s.%s", this.dbName, this.schemaName, this.tableName);
return Utils.getFullyQualifiedTableName(this.dbName, this.schemaName, this.tableName);
}

public OnErrorOption getOnErrorOption() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/*
* Copyright (c) 2022 Snowflake Computing Inc. All rights reserved.
* Copyright (c) 2022-2024 Snowflake Computing Inc. All rights reserved.
*/

package net.snowflake.ingest.streaming.internal;

import net.snowflake.ingest.utils.Utils;

/**
* Channel immutable identification and encryption attributes.
*
Expand Down Expand Up @@ -36,12 +38,12 @@ class ChannelFlushContext {
String encryptionKey,
Long encryptionKeyId) {
this.name = name;
this.fullyQualifiedName = String.format("%s.%s.%s.%s", dbName, schemaName, tableName, name);
this.fullyQualifiedName =
Utils.getFullyQualifiedChannelName(dbName, schemaName, tableName, name);
this.dbName = dbName;
this.schemaName = schemaName;
this.tableName = tableName;
this.fullyQualifiedTableName =
String.format("%s.%s.%s", this.getDbName(), this.getSchemaName(), this.getTableName());
this.fullyQualifiedTableName = Utils.getFullyQualifiedTableName(dbName, schemaName, tableName);
this.channelSequencer = channelSequencer;
this.encryptionKey = encryptionKey;
this.encryptionKeyId = encryptionKeyId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Snowflake Computing Inc. All rights reserved.
* Copyright (c) 2021-2024 Snowflake Computing Inc. All rights reserved.
*/

package net.snowflake.ingest.streaming.internal;
Expand All @@ -8,7 +8,7 @@
import java.util.List;

/** Class to deserialize a request from a channel status request */
class ChannelsStatusRequest {
class ChannelsStatusRequest implements StreamingIngestRequest {

// Used to deserialize a channel request
static class ChannelStatusRequestDTO {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2024 Snowflake Computing Inc. All rights reserved.
*/

package net.snowflake.ingest.streaming.internal;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.snowflake.ingest.utils.Utils;

/** Class used to serialize the client / channel configure request. */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ConfigureRequest implements StreamingIngestRequest {
@JsonProperty("role")
private String role;

@JsonProperty("database")
private String database;

@JsonProperty("schema")
private String schema;

@JsonProperty("table")
private String table;

@JsonProperty("file_name")
private String fileName;

/**
* Constructor for client configure request
*
* @param role Role to be used for the request.
*/
ConfigureRequest(String role) {
this.role = role;
}

/**
* Constructor for channel configure request
*
* @param role Role to be used for the request.
* @param database Database name.
* @param schema Schema name.
* @param table Table name.
*/
ConfigureRequest(String role, String database, String schema, String table) {
this.role = role;
this.database = database;
this.schema = schema;
this.table = table;
}

String getRole() {
return role;
}

String getDatabase() {
return database;
}

String getSchema() {
return schema;
}

String getTable() {
return table;
}

String getFileName() {
return fileName;
}

/** Set the file name for the GCS signed url request. */
void setFileName(String fileName) {
this.fileName = fileName;
}

String getFullyQualifiedTableName() {
return Utils.getFullyQualifiedTableName(database, schema, table);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

package net.snowflake.ingest.streaming.internal;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Class used to deserialize responses from configure endpoint */
@JsonIgnoreProperties(ignoreUnknown = true)
class ConfigureResponse extends StreamingIngestResponse {
@JsonProperty("prefix")
private String prefix;
Expand Down Expand Up @@ -63,4 +65,11 @@ Long getDeploymentId() {
void setDeploymentId(Long deploymentId) {
this.deploymentId = deploymentId;
}

String getClientPrefix() {
if (this.deploymentId == null) {
return this.prefix;
}
return this.prefix + "_" + this.deploymentId;
}
}
Loading

0 comments on commit 30dda19

Please sign in to comment.