-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding workflow state and create connector resources created
Signed-off-by: Amit Galitzky <[email protected]>
- Loading branch information
1 parent
ac76a44
commit 8b09716
Showing
22 changed files
with
745 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/org/opensearch/flowframework/model/ResourcesCreated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.flowframework.model; | ||
|
||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.common.io.stream.Writeable; | ||
import org.opensearch.core.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
import org.opensearch.core.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; | ||
import static org.opensearch.flowframework.common.CommonValue.RESOURCE_ID_FIELD; | ||
import static org.opensearch.flowframework.common.CommonValue.RESOURCE_NAME_FIELD; | ||
|
||
public class ResourcesCreated implements ToXContentObject, Writeable { | ||
|
||
public String resourceName; | ||
public String resourceId; | ||
|
||
public ResourcesCreated(String resourceName, String resourceId) { | ||
this.resourceName = resourceName; | ||
this.resourceId = resourceId; | ||
} | ||
|
||
public ResourcesCreated(StreamInput input) throws IOException { | ||
this.resourceName = input.readString(); | ||
this.resourceId = input.readString(); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
XContentBuilder xContentBuilder = builder.startObject() | ||
.field(RESOURCE_NAME_FIELD, resourceName) | ||
.field(RESOURCE_ID_FIELD, resourceId); | ||
return xContentBuilder.endObject(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(resourceName); | ||
out.writeString(resourceId); | ||
} | ||
|
||
public static ResourcesCreated parse(XContentParser parser) throws IOException { | ||
String resourceName = null; | ||
String resourceId = null; | ||
|
||
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser); | ||
while (parser.nextToken() != XContentParser.Token.END_OBJECT) { | ||
String fieldName = parser.currentName(); | ||
parser.nextToken(); | ||
|
||
switch (fieldName) { | ||
case RESOURCE_NAME_FIELD: | ||
resourceName = parser.text(); | ||
break; | ||
case RESOURCE_ID_FIELD: | ||
resourceId = parser.text(); | ||
break; | ||
default: | ||
throw new IOException("Unable to parse field [" + fieldName + "] in a resources_created object."); | ||
} | ||
} | ||
return new ResourcesCreated(resourceName, resourceId); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.