index int64 | repo_id string | file_path string | content string |
|---|---|---|---|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/ValidationException.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1;
import java.util.Map;
public class ValidationException extends TlkException {
public ValidationException(ValidationError error, int statusCode) {
super(error, statusCode);
}
@SuppressWarnings("unchecked")
public Map<String, FieldValidationError> getValidationPayload() {
return ((ValidationError) getError()).getPayload();
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/AggregatedSolution.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonProperty;
public class AggregatedSolution {
@JsonProperty("pool_id")
private String poolId;
@JsonProperty("task_id")
private String taskId;
private double confidence;
@JsonProperty("output_values")
private Map<String, Object> outputValues;
public String getPoolId() {
return poolId;
}
public String getTaskId() {
return taskId;
}
public double getConfidence() {
return confidence;
}
public Map<String, Object> getOutputValues() {
return outputValues;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/AggregatedSolutionClient.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
public interface AggregatedSolutionClient {
AggregatedSolutionOperation aggregateSolutionsByPool(PoolAggregatedSolutionRequest request);
ModificationResult<AggregatedSolution> aggregateSolutionsByTask(TaskAggregatedSolutionRequest request);
SearchResult<AggregatedSolution> findAggregatedSolutions(String operationId,
AggregatedSolutionSearchRequest request);
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/AggregatedSolutionFilterParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import ai.toloka.client.v1.FilterParam;
public enum AggregatedSolutionFilterParam implements FilterParam {
;
private String parameter;
AggregatedSolutionFilterParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/AggregatedSolutionOperation.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import com.fasterxml.jackson.annotation.JsonProperty;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.operation.OperationType;
public class AggregatedSolutionOperation extends Operation<AggregatedSolutionOperation.Parameters,
AggregatedSolutionOperation> {
public static final OperationType TYPE = OperationType.SOLUTION_AGGREGATE;
public AggregatedSolutionOperation() {}
public static class Parameters {
@JsonProperty("pool_id")
private String poolId;
public String getPoolId() {
return poolId;
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/AggregatedSolutionRangeParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import ai.toloka.client.v1.RangeParam;
public enum AggregatedSolutionRangeParam implements RangeParam {
taskId(AggregatedSolutionSearchRequest.TASK_ID_PARAMETER);
private String parameter;
AggregatedSolutionRangeParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/AggregatedSolutionSearchRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import java.util.Map;
import ai.toloka.client.v1.SearchRequest;
public class AggregatedSolutionSearchRequest extends SearchRequest {
static final String TASK_ID_PARAMETER = "task_id";
public AggregatedSolutionSearchRequest(Map<String, Object> filterParameters, Map<String, Object> rangeParameters,
String sortParameter, Integer limit) {
super(filterParameters, rangeParameters, sortParameter, limit);
}
public static AggregatedAssignmentsBuilder make() {
return new AggregatedAssignmentsBuilder(
new AssignmentFilterBuilder(), new AggregatedAssignmentsRangeBuilder(),
new AggregatedAssignmentsSortBuilder());
}
public static class AggregatedAssignmentsBuilder extends Builder
<AggregatedSolutionSearchRequest, AggregatedAssignmentsBuilder, AssignmentFilterBuilder,
AggregatedAssignmentsRangeBuilder, AggregatedAssignmentsSortBuilder> {
public AggregatedAssignmentsBuilder(
AssignmentFilterBuilder filterBuilder,
AggregatedAssignmentsRangeBuilder rangeBuilder,
AggregatedAssignmentsSortBuilder sortBuilder
) {
super(filterBuilder, rangeBuilder, sortBuilder);
}
@Override public AggregatedSolutionSearchRequest done() {
return new AggregatedSolutionSearchRequest(filterBuilder.getFilterParameters(),
rangeBuilder.getRangeParameters(), sortBuilder.getSortParameter(), getLimit());
}
}
public static class AssignmentFilterBuilder
extends FilterBuilder<AssignmentFilterBuilder, AggregatedAssignmentsBuilder,
AggregatedSolutionFilterParam> {
}
public static class AggregatedAssignmentsRangeBuilder
extends RangeBuilder<AggregatedAssignmentsRangeBuilder, AggregatedAssignmentsBuilder,
AggregatedSolutionRangeParam> {
public RangeItemBuilder<AggregatedAssignmentsRangeBuilder> byTaskId(String taskId) {
return by(AggregatedSolutionRangeParam.taskId, taskId);
}
}
public static class AggregatedAssignmentsSortBuilder
extends SortBuilder<AggregatedAssignmentsSortBuilder, AggregatedAssignmentsBuilder,
AggregatedSolutionSortParam> {
public SortItem<AggregatedAssignmentsSortBuilder> byTaskId() {
return by(AggregatedSolutionSortParam.taskId);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/AggregatedSolutionSortParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import ai.toloka.client.v1.SortParam;
public enum AggregatedSolutionSortParam implements SortParam {
taskId(AggregatedSolutionSearchRequest.TASK_ID_PARAMETER);
private String parameter;
AggregatedSolutionSortParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/AggregatedSolutionType.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public final class AggregatedSolutionType extends FlexibleEnum<AggregatedSolutionType> {
private AggregatedSolutionType(String name) {
super(name);
}
public static final AggregatedSolutionType WEIGHTED_DYNAMIC_OVERLAP =
new AggregatedSolutionType("WEIGHTED_DYNAMIC_OVERLAP");
public static final AggregatedSolutionType DAWID_SKENE = new AggregatedSolutionType("DAWID_SKENE");
private static final AggregatedSolutionType[] VALUES = {WEIGHTED_DYNAMIC_OVERLAP, DAWID_SKENE};
private static final ConcurrentMap<String, AggregatedSolutionType> DISCOVERED_VALUES = new ConcurrentHashMap<>();
public static AggregatedSolutionType[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), AggregatedSolutionType.class);
}
@JsonCreator
public static AggregatedSolutionType valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new FlexibleEnum.NewEnumCreator<AggregatedSolutionType>() {
@Override public AggregatedSolutionType create(String name) {
return new AggregatedSolutionType(name);
}
});
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/DawidSkenePoolAggregatedSolutionRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class DawidSkenePoolAggregatedSolutionRequest extends PoolAggregatedSolutionRequest {
private List<Field> fields;
public DawidSkenePoolAggregatedSolutionRequest(String poolId, List<Field> fields) {
super(AggregatedSolutionType.DAWID_SKENE, poolId);
this.fields = new ArrayList<>(fields);
}
public List<Field> getFields() {
return Collections.unmodifiableList(fields);
}
public static class Field {
private String name;
public Field(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/PoolAggregatedSolutionRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import com.fasterxml.jackson.annotation.JsonProperty;
public abstract class PoolAggregatedSolutionRequest {
private AggregatedSolutionType type;
@JsonProperty("pool_id")
private String poolId;
protected PoolAggregatedSolutionRequest(AggregatedSolutionType type, String poolId) {
this.type = type;
this.poolId = poolId;
}
public AggregatedSolutionType getType() {
return type;
}
public String getPoolId() {
return poolId;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/TaskAggregatedSolutionRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import com.fasterxml.jackson.annotation.JsonProperty;
public abstract class TaskAggregatedSolutionRequest {
private AggregatedSolutionType type;
@JsonProperty("task_id")
private String taskId;
@JsonProperty("pool_id")
private String poolId;
protected TaskAggregatedSolutionRequest(AggregatedSolutionType type, String taskId, String poolId) {
this.type = type;
this.taskId = taskId;
this.poolId = poolId;
}
public AggregatedSolutionType getType() {
return type;
}
public String getTaskId() {
return taskId;
}
public String getPoolId() {
return poolId;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/WeightedDynamicOverlapPoolAggregatedSolutionRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
public class WeightedDynamicOverlapPoolAggregatedSolutionRequest extends PoolAggregatedSolutionRequest {
@JsonProperty("answer_weight_skill_id")
private String answerWeightSkillId;
private List<Field> fields;
public WeightedDynamicOverlapPoolAggregatedSolutionRequest(String poolId, String answerWeightSkillId,
List<Field> fields) {
super(AggregatedSolutionType.WEIGHTED_DYNAMIC_OVERLAP, poolId);
this.answerWeightSkillId = answerWeightSkillId;
this.fields = new ArrayList<>(fields);
}
public String getAnswerWeightSkillId() {
return answerWeightSkillId;
}
public List<Field> getFields() {
return Collections.unmodifiableList(fields);
}
public static class Field {
private String name;
public Field(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/aggregatedsolutions/WeightedDynamicOverlapTaskAggregatedSolutionRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.aggregatedsolutions;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
public class WeightedDynamicOverlapTaskAggregatedSolutionRequest extends TaskAggregatedSolutionRequest {
@JsonProperty("answer_weight_skill_id")
private String answerWeightSkillId;
private List<Field> fields;
public WeightedDynamicOverlapTaskAggregatedSolutionRequest(String taskId, String poolId,
String answerWeightSkillId, List<Field> fields) {
super(AggregatedSolutionType.WEIGHTED_DYNAMIC_OVERLAP, taskId, poolId);
this.answerWeightSkillId = answerWeightSkillId;
this.fields = new ArrayList<>(fields);
}
public String getAnswerWeightSkillId() {
return answerWeightSkillId;
}
public List<Field> getFields() {
return fields;
}
public static class Field {
private String name;
public Field(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/assignment/Assignment.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.assignment;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import ai.toloka.client.v1.solution.Solution;
import ai.toloka.client.v1.task.Task;
public class Assignment {
private String id;
@JsonProperty("task_suite_id")
private String taskSuiteId;
@JsonProperty("pool_id")
private String poolId;
@JsonProperty("user_id")
private String userId;
private AssignmentStatus status;
private BigDecimal reward;
private List<Task> tasks;
@JsonProperty("first_declined_solution_attempt")
public List<Solution> firstDeclinedSolutionAttempt;
private List<Solution> solutions;
@JsonProperty("public_comment")
private String publicComment;
private Boolean mixed;
private Boolean automerged;
private Date created;
private Date submitted;
private Date accepted;
private Date rejected;
private Date skipped;
private Date expired;
public String getId() {
return id;
}
public String getTaskSuiteId() {
return taskSuiteId;
}
public String getPoolId() {
return poolId;
}
public String getUserId() {
return userId;
}
public AssignmentStatus getStatus() {
return status;
}
public BigDecimal getReward() {
return reward;
}
public List<Task> getTasks() {
return tasks;
}
public List<Solution> getFirstDeclinedSolutionAttempt() {
return firstDeclinedSolutionAttempt;
}
public List<Solution> getSolutions() {
return solutions;
}
public String getPublicComment() {
return publicComment;
}
public Boolean getMixed() {
return mixed;
}
public Boolean getAutomerged() {
return automerged;
}
public Date getCreated() {
return created;
}
public Date getSubmitted() {
return submitted;
}
public Date getAccepted() {
return accepted;
}
public Date getRejected() {
return rejected;
}
public Date getSkipped() {
return skipped;
}
public Date getExpired() {
return expired;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/assignment/AssignmentClient.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.assignment;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
public interface AssignmentClient {
SearchResult<Assignment> findAssignments(AssignmentSearchRequest request);
Assignment getAssignment(String assignmentId);
ModificationResult<Assignment> patchAssignment(String assignmentId, AssignmentPatch patch);
ModificationResult<Assignment> acceptAssignment(String assignmentId, String publicComment);
ModificationResult<Assignment> rejectAssignment(String assignmentId, String publicComment);
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/assignment/AssignmentFilterParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.assignment;
import ai.toloka.client.v1.FilterParam;
public enum AssignmentFilterParam implements FilterParam {
status(AssignmentSearchRequest.STATUS_PARAMETER),
taskId(AssignmentSearchRequest.TASK_ID_PARAMETER),
taskSuiteId(AssignmentSearchRequest.TASK_SUITE_ID_PARAMETER),
poolId(AssignmentSearchRequest.POOL_ID_PARAMETER),
userId(AssignmentSearchRequest.USER_ID_PARAMETER);
private String parameter;
AssignmentFilterParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/assignment/AssignmentPatch.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.assignment;
import com.fasterxml.jackson.annotation.JsonProperty;
public class AssignmentPatch {
private AssignmentStatus status;
@JsonProperty("public_comment")
private String publicComment;
public AssignmentPatch() {}
public AssignmentPatch(AssignmentStatus status, String publicComment) {
this.status = status;
this.publicComment = publicComment;
}
public void setStatus(AssignmentStatus status) {
this.status = status;
}
public void setPublicComment(String publicComment) {
this.publicComment = publicComment;
}
public AssignmentStatus getStatus() {
return status;
}
public String getPublicComment() {
return publicComment;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/assignment/AssignmentRangeParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.assignment;
import ai.toloka.client.v1.RangeParam;
public enum AssignmentRangeParam implements RangeParam {
id(AssignmentSearchRequest.ID_PARAMETER),
created(AssignmentSearchRequest.CREATED_PARAMETER),
submitted(AssignmentSearchRequest.SUBMITTED_PARAMETER);
private String parameter;
AssignmentRangeParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/assignment/AssignmentSearchRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.assignment;
import java.util.Date;
import java.util.Map;
import ai.toloka.client.v1.SearchRequest;
public class AssignmentSearchRequest extends SearchRequest {
static final String STATUS_PARAMETER = "status";
static final String TASK_ID_PARAMETER = "task_id";
static final String TASK_SUITE_ID_PARAMETER = "task_suite_id";
static final String POOL_ID_PARAMETER = "pool_id";
static final String USER_ID_PARAMETER = "user_id";
static final String ID_PARAMETER = "id";
static final String CREATED_PARAMETER = "created";
static final String SUBMITTED_PARAMETER = "submitted";
public AssignmentSearchRequest(Map<String, Object> filterParameters, Map<String, Object> rangeParameters,
String sortParameter, Integer limit) {
super(filterParameters, rangeParameters, sortParameter, limit);
}
public static AssignmentBuilder make() {
return new AssignmentBuilder(
new AssignmentFilterBuilder(), new AssignmentRangeBuilder(), new AssignmentSortBuilder());
}
public static class AssignmentBuilder extends Builder
<AssignmentSearchRequest, AssignmentBuilder, AssignmentFilterBuilder, AssignmentRangeBuilder,
AssignmentSortBuilder> {
public AssignmentBuilder(AssignmentFilterBuilder filterBuilder, AssignmentRangeBuilder rangeBuilder,
AssignmentSortBuilder sortBuilder) {
super(filterBuilder, rangeBuilder, sortBuilder);
}
@Override public AssignmentSearchRequest done() {
return new AssignmentSearchRequest(filterBuilder.getFilterParameters(), rangeBuilder.getRangeParameters(),
sortBuilder.getSortParameter(), getLimit());
}
}
public static class AssignmentFilterBuilder
extends FilterBuilder<AssignmentFilterBuilder, AssignmentBuilder, AssignmentFilterParam> {
public AssignmentFilterBuilder byStatus(AssignmentStatus status) {
return by(AssignmentFilterParam.status, status);
}
public AssignmentFilterBuilder byTaskId(String taskId) {
return by(AssignmentFilterParam.taskId, taskId);
}
public AssignmentFilterBuilder byTaskSuiteId(String taskSuiteId) {
return by(AssignmentFilterParam.taskSuiteId, taskSuiteId);
}
public AssignmentFilterBuilder byPoolId(String poolId) {
return by(AssignmentFilterParam.poolId, poolId);
}
public AssignmentFilterBuilder byUserId(String userId) {
return by(AssignmentFilterParam.userId, userId);
}
}
public static class AssignmentRangeBuilder
extends RangeBuilder<AssignmentRangeBuilder, AssignmentBuilder, AssignmentRangeParam> {
public RangeItemBuilder<AssignmentRangeBuilder> byId(String id) {
return by(AssignmentRangeParam.id, id);
}
public RangeItemBuilder<AssignmentRangeBuilder> byCreated(Date created) {
return by(AssignmentRangeParam.created, created);
}
public RangeItemBuilder<AssignmentRangeBuilder> bySubmitted(Date submitted) {
return by(AssignmentRangeParam.submitted, submitted);
}
}
public static class AssignmentSortBuilder
extends SortBuilder<AssignmentSortBuilder, AssignmentBuilder, AssignmentSortParam> {
public SortItem<AssignmentSortBuilder> byId() {
return by(AssignmentSortParam.id);
}
public SortItem<AssignmentSortBuilder> byCreated() {
return by(AssignmentSortParam.created);
}
public SortItem<AssignmentSortBuilder> bySubmitted() {
return by(AssignmentSortParam.submitted);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/assignment/AssignmentSortParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.assignment;
import ai.toloka.client.v1.SortParam;
public enum AssignmentSortParam implements SortParam {
id(AssignmentSearchRequest.ID_PARAMETER),
created(AssignmentSearchRequest.CREATED_PARAMETER),
submitted(AssignmentSearchRequest.SUBMITTED_PARAMETER);
private String parameter;
AssignmentSortParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/assignment/AssignmentStatus.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.assignment;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public final class AssignmentStatus extends FlexibleEnum<AssignmentStatus> {
private AssignmentStatus(String name) {
super(name);
}
public static final AssignmentStatus ACTIVE = new AssignmentStatus("ACTIVE");
public static final AssignmentStatus SUBMITTED = new AssignmentStatus("SUBMITTED");
public static final AssignmentStatus ACCEPTED = new AssignmentStatus("ACCEPTED");
public static final AssignmentStatus REJECTED = new AssignmentStatus("REJECTED");
public static final AssignmentStatus SKIPPED = new AssignmentStatus("SKIPPED");
public static final AssignmentStatus EXPIRED = new AssignmentStatus("EXPIRED");
private static final AssignmentStatus[] VALUES = {ACTIVE, SUBMITTED, ACCEPTED, REJECTED, SKIPPED, EXPIRED};
private static final ConcurrentMap<String, AssignmentStatus> DISCOVERED_VALUES = new ConcurrentHashMap<>();
public static AssignmentStatus[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), AssignmentStatus.class);
}
@JsonCreator
public static AssignmentStatus valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<AssignmentStatus>() {
@Override public AssignmentStatus create(String name) {
return new AssignmentStatus(name);
}
});
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/AssignmentAttachment.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import com.fasterxml.jackson.annotation.JsonProperty;
public class AssignmentAttachment extends Attachment<AssignmentAttachment.Details> {
public static class Details {
@JsonProperty("user_id")
private String userId;
@JsonProperty("assignment_id")
private String assignmentId;
@JsonProperty("pool_id")
private String poolId;
public String getUserId() {
return userId;
}
public String getAssignmentId() {
return assignmentId;
}
public String getPoolId() {
return poolId;
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/Attachment.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import ai.toloka.client.v1.Owner;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "attachment_type",
visible = true, defaultImpl = Attachment.UnknownAttachment.class)
@JsonSubTypes({
@JsonSubTypes.Type(value = AssignmentAttachment.class, name = "ASSIGNMENT_ATTACHMENT")
})
public abstract class Attachment<D> {
protected String id;
protected Owner owner;
@JsonProperty("attachment_type")
protected AttachmentType attachmentType;
protected String name;
@JsonProperty("media_type")
protected String mediaType;
protected D details;
protected Date created;
public String getId() {
return id;
}
public AttachmentType getAttachmentType() {
return attachmentType;
}
public String getName() {
return name;
}
public String getMediaType() {
return mediaType;
}
public D getDetails() {
return details;
}
public Date getCreated() {
return created;
}
public Owner getOwner() {
return owner;
}
public static class UnknownAttachment extends Attachment {}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/AttachmentClient.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import ai.toloka.client.v1.SearchResult;
public interface AttachmentClient {
SearchResult<Attachment<?>> findAttachments(AttachmentSearchRequest request);
Attachment<?> getAttachment(String attachmentId);
AttachmentDownload downloadAttachment(String attachmentId);
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/AttachmentDownload.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import java.io.InputStream;
public class AttachmentDownload {
private final InputStream entity;
private final String contentType;
private final String contentLength;
private final String transferEncoding;
private final String contentDisposition;
public AttachmentDownload(final InputStream entity,
final String contentType,
final String contentLength,
final String transferEncoding,
final String contentDisposition) {
this.entity = entity;
this.contentType = contentType;
this.contentLength = contentLength;
this.transferEncoding = transferEncoding;
this.contentDisposition = contentDisposition;
}
public InputStream getEntity() {
return entity;
}
public String getContentType() {
return contentType;
}
public String getContentLength() {
return contentLength;
}
public String getTransferEncoding() {
return transferEncoding;
}
public String getContentDisposition() {
return contentDisposition;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/AttachmentFilterParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import ai.toloka.client.v1.FilterParam;
public enum AttachmentFilterParam implements FilterParam {
ownerId(AttachmentSearchRequest.OWNER_ID_PARAMETER),
ownerCompanyId(AttachmentSearchRequest.OWNER_COMPANY_ID_PARAMETER),
name(AttachmentSearchRequest.NAME_PARAMETER),
attachmentType(AttachmentSearchRequest.ATTACHMENT_TYPE_PARAMETER),
userId(AttachmentSearchRequest.USER_ID_PARAMETER),
assignmentId(AttachmentSearchRequest.ASSIGNMENT_ID_PARAMETER),
poolId(AttachmentSearchRequest.POOL_ID_PARAMETER);
private String parameter;
AttachmentFilterParam(String parameter) {
this.parameter = parameter;
}
@Override public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/AttachmentRangeParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import ai.toloka.client.v1.RangeParam;
public enum AttachmentRangeParam implements RangeParam {
id(AttachmentSearchRequest.ID_PARAMETER),
created(AttachmentSearchRequest.CREATED_PARAMETER);
private String parameter;
AttachmentRangeParam(String parameter) {
this.parameter = parameter;
}
@Override public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/AttachmentSearchRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import java.util.Date;
import java.util.Map;
import ai.toloka.client.v1.SearchRequest;
public class AttachmentSearchRequest extends SearchRequest {
static final String OWNER_ID_PARAMETER = "owner_id";
static final String OWNER_COMPANY_ID_PARAMETER = "owner_company_id";
public static final String NAME_PARAMETER = "name";
public static final String ATTACHMENT_TYPE_PARAMETER = "type";
public static final String USER_ID_PARAMETER = "user_id";
public static final String ASSIGNMENT_ID_PARAMETER = "assignment_id";
public static final String POOL_ID_PARAMETER = "pool_id";
public static final String ID_PARAMETER = "id";
public static final String CREATED_PARAMETER = "created";
private AttachmentSearchRequest(Map<String, Object> filterParameters, Map<String, Object> rangeParameters,
String sortParameter, Integer limit) {
super(filterParameters, rangeParameters, sortParameter, limit);
}
public static AttachmentBuilder make() {
return new AttachmentBuilder(
new AttachmentFilterBuilder(), new AttachmentRangeBuilder(), new AttachmentSortBuilder());
}
public static class AttachmentBuilder extends Builder<
AttachmentSearchRequest,
AttachmentBuilder,
AttachmentFilterBuilder,
AttachmentRangeBuilder,
AttachmentSortBuilder> {
private AttachmentBuilder(AttachmentFilterBuilder filterBuilder, AttachmentRangeBuilder rangeBuilder,
AttachmentSortBuilder sortBuilder) {
super(filterBuilder, rangeBuilder, sortBuilder);
}
@Override public AttachmentSearchRequest done() {
return new AttachmentSearchRequest(filterBuilder.getFilterParameters(), rangeBuilder.getRangeParameters(),
sortBuilder.getSortParameter(), getLimit());
}
}
public static class AttachmentFilterBuilder
extends FilterBuilder<AttachmentFilterBuilder, AttachmentBuilder, AttachmentFilterParam> {
public AttachmentFilterBuilder byOwnerId(String ownerId) {
return by(AttachmentFilterParam.ownerId, ownerId);
}
public AttachmentFilterBuilder byOwnerCompanyId(String ownerCompanyId) {
return by(AttachmentFilterParam.ownerCompanyId, ownerCompanyId);
}
public AttachmentFilterBuilder byName(String name) {
return by(AttachmentFilterParam.name, name);
}
public AttachmentFilterBuilder byAttachmentType(AttachmentType attachmentType) {
return by(AttachmentFilterParam.attachmentType, attachmentType);
}
public AttachmentFilterBuilder byUserId(String userId) {
return by(AttachmentFilterParam.userId, userId);
}
public AttachmentFilterBuilder byAssignmentId(String assignmentId) {
return by(AttachmentFilterParam.assignmentId, assignmentId);
}
public AttachmentFilterBuilder byPoolId(String poolId) {
return by(AttachmentFilterParam.poolId, poolId);
}
}
public static class AttachmentRangeBuilder
extends RangeBuilder<AttachmentRangeBuilder, AttachmentBuilder, AttachmentRangeParam> {
public RangeItemBuilder<AttachmentRangeBuilder> byId(String id) {
return by(AttachmentRangeParam.id, id);
}
public RangeItemBuilder<AttachmentRangeBuilder> byCreated(Date created) {
return by(AttachmentRangeParam.created, created);
}
}
public static class AttachmentSortBuilder
extends SortBuilder<AttachmentSortBuilder, AttachmentBuilder, AttachmentSortParam> {
public SortItem<AttachmentSortBuilder> byId() {
return by(AttachmentSortParam.id);
}
public SortItem<AttachmentSortBuilder> byCreated() {
return by(AttachmentSortParam.created);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/AttachmentSortParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import ai.toloka.client.v1.SortParam;
public enum AttachmentSortParam implements SortParam {
id(AttachmentSearchRequest.ID_PARAMETER),
created(AttachmentSearchRequest.CREATED_PARAMETER);
private String parameter;
AttachmentSortParam(String parameter) {
this.parameter = parameter;
}
@Override public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/attachment/AttachmentType.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.attachment;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public final class AttachmentType extends FlexibleEnum<AttachmentType> {
public static final AttachmentType ASSIGNMENT_ATTACHMENT = new AttachmentType("ASSIGNMENT_ATTACHMENT");
private static final AttachmentType[] VALUES = {ASSIGNMENT_ATTACHMENT};
private static final ConcurrentMap<String, AttachmentType> DISCOVERED_VALUES = new ConcurrentHashMap<>();
public static AttachmentType[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), AttachmentType.class);
}
@JsonCreator
public static AttachmentType valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<AttachmentType>() {
@Override public AttachmentType create(String name) {
return new AttachmentType(name);
}
});
}
private AttachmentType(String name) {
super(name);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/AbstractClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.io.InputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ai.toloka.client.v1.BatchCreateResult;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.NotFoundException;
import ai.toloka.client.v1.RequestParameters;
import ai.toloka.client.v1.SearchRequest;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.ServiceUnavailableException;
import ai.toloka.client.v1.TlkError;
import ai.toloka.client.v1.TlkException;
import ai.toloka.client.v1.TolokaRequestIOException;
import ai.toloka.client.v1.ValidationError;
import ai.toloka.client.v1.ValidationException;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.pool.PoolOpenOperation;
import static ai.toloka.client.v1.impl.transport.MapperUtil.getObjectReader;
import static ai.toloka.client.v1.impl.transport.MapperUtil.getTolokaDateFormat;
public abstract class AbstractClientImpl {
private static final Logger logger = LoggerFactory.getLogger(AbstractClientImpl.class);
private static final String ASYNC_MODE_PARAMETER = "async_mode";
private static final int DEFAULT_BUFFER_SIZE = 16 * 1024;
private final String prefix;
private final TolokaClientFactoryImpl factory;
private final ExecutorService executor;
protected AbstractClientImpl(TolokaClientFactoryImpl factory) {
this(factory, "v1");
}
protected AbstractClientImpl(TolokaClientFactoryImpl factory, String versionPrefix) {
this.prefix = versionPrefix;
this.factory = factory;
this.executor = Executors.newCachedThreadPool();
}
public URI getTolokaApiUrl() {
return factory.getTolokaApiUrl();
}
public HttpClient getHttpClient() {
return factory.getHttpClient();
}
public Consumer<HttpRequestBase> getHttpConsumer() {
return factory.getHeadersSupplier();
}
public TolokaClientFactoryImpl getFactory() {
return factory;
}
private static URIBuilder addPaths(URIBuilder uriBuilder, String... paths) {
for (String path : paths) {
if (path == null || path.isEmpty()) {
continue;
}
uriBuilder.setPath(
uriBuilder.getPath().endsWith("/")
? uriBuilder.getPath() + path
: uriBuilder.getPath() + "/" + path);
}
return uriBuilder;
}
protected URIBuilder addVersionPrefix(URIBuilder uriBuilder, String... paths) {
String[] v1Paths = new String[paths.length + 1];
v1Paths[0] = prefix;
System.arraycopy(paths, 0, v1Paths, 1, paths.length);
return addPaths(uriBuilder, v1Paths);
}
protected <T> SearchResult<T> find(
final SearchRequest request,
final String path,
final TypeReference typeReference
) {
return new RequestExecutorWrapper<SearchResult<T>>() {
@Override
SearchResult<T> execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path);
if (request != null) {
uriBuilder.addParameters(convertParameters(request.getQueryParameters()));
}
HttpResponse response = TransportUtil
.executeGet(getHttpClient(), uriBuilder.build(), getHttpConsumer());
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw parseException(response);
}
return getObjectReader(typeReference).readValue(response.getEntity().getContent());
}
}.wrap();
}
protected <T> T get(final String id, final String path, final Class<T> clazz) {
Assertions.checkArgNotNull(id, "Id may not be null");
return new RequestExecutorWrapper<T>() {
@Override
T execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path, id).build();
HttpResponse response = TransportUtil.executeGet(getHttpClient(), uri, getHttpConsumer());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
return getObjectReader(clazz).readValue(response.getEntity().getContent());
}
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
EntityUtils.consumeQuietly(response.getEntity());
return null;
}
throw parseException(response);
}
}.wrap();
}
protected <T, R> ModificationResult<R> create(final T form,
final String path,
final Class<R> responseClass,
final Map<String, Object> queryParameters) {
return new RequestExecutorWrapper<ModificationResult<R>>() {
@Override
ModificationResult<R> execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path);
if (queryParameters != null) {
uriBuilder.addParameters(convertParameters(queryParameters));
}
HttpResponse response = TransportUtil
.executePost(getHttpClient(), uriBuilder.build(), getHttpConsumer(), form);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED) {
@SuppressWarnings("unchecked")
ModificationResult<R> result = new ModificationResult<>(
getObjectReader(responseClass).readValue(response.getEntity().getContent()), true);
return result;
}
throw parseException(response);
}
}.wrap();
}
protected <T, R> BatchCreateResult<R> upsertMultiple(final List<T> forms,
final String path,
final TypeReference<BatchCreateResult<R>> typeReference) {
return new RequestExecutorWrapper<BatchCreateResult<R>>() {
@Override
BatchCreateResult<R> execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path);
HttpResponse response = TransportUtil.executePut(getHttpClient(), uriBuilder.build(),
getHttpConsumer(), forms);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
return getObjectReader(typeReference).readValue(response.getEntity().getContent());
}
throw parseException(response);
}
}.wrap();
}
<T> BatchCreateResult<T> createMultiple(final List<T> forms,
final String path,
final TypeReference<BatchCreateResult<T>> typeReference,
final RequestParameters requestParameters) {
return new RequestExecutorWrapper<BatchCreateResult<T>>() {
@Override
BatchCreateResult<T> execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path);
if (requestParameters != null) {
uriBuilder.addParameters(convertParameters(requestParameters.getQueryParameters()));
}
uriBuilder.addParameter(ASYNC_MODE_PARAMETER, Boolean.FALSE.toString());
HttpResponse response = TransportUtil
.executePost(getHttpClient(), uriBuilder.build(), getHttpConsumer(), forms);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED) {
return getObjectReader(typeReference).readValue(response.getEntity().getContent());
}
throw parseException(response);
}
}.wrap();
}
<T, O extends Operation> O createMultipleAsync(final Iterator<T> forms,
final String path,
final Class<O> opClass,
final RequestParameters requestParameters) {
return new RequestExecutorWrapper<O>() {
@SuppressWarnings("unchecked")
@Override
O execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path);
if (requestParameters != null) {
uriBuilder.addParameters(convertParameters(requestParameters.getQueryParameters()));
}
uriBuilder.addParameter(ASYNC_MODE_PARAMETER, Boolean.TRUE.toString());
try (final PipedInputStream in = new PipedInputStream(DEFAULT_BUFFER_SIZE);
final PipedOutputStream out = new PipedOutputStream(in)) {
executor.execute(readJsonForms(out, forms));
HttpResponse response = TransportUtil.executePost(getHttpClient(), uriBuilder.build(),
getHttpConsumer(), in);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_ACCEPTED) {
O operation = getObjectReader(opClass).readValue(response.getEntity().getContent());
Operation.setOperationClient(operation, getFactory().getOperationClient());
return operation;
}
throw parseException(response);
}
}
}.wrap();
}
protected <T> ModificationResult<T> update(final String resourceId, final T form, final String path,
final Class<T> formClass) {
return new RequestExecutorWrapper<ModificationResult<T>>() {
@Override
ModificationResult<T> execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path, resourceId).build();
HttpResponse response = TransportUtil.executePut(getHttpClient(), uri, getHttpConsumer(), form);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
@SuppressWarnings("unchecked")
T result = getObjectReader(formClass).readValue(response.getEntity().getContent());
return new ModificationResult<>(result, false);
}
throw parseException(response);
}
}.wrap();
}
protected <T, R> ModificationResult<R> upsert(final String resourceId, final T form, final String path,
final Class<R> formClass) {
return new RequestExecutorWrapper<ModificationResult<R>>() {
@Override
ModificationResult<R> execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path, resourceId).build();
HttpResponse response = TransportUtil.executePut(getHttpClient(), uri, getHttpConsumer(), form);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) {
R result = getObjectReader(formClass).readValue(response.getEntity().getContent());
return new ModificationResult<>(result, statusCode == HttpStatus.SC_CREATED);
}
throw parseException(response);
}
}.wrap();
}
protected <P, T> ModificationResult<T> patch(
final String resourceId,
final P patch,
final String path,
final Class<T> resourceClass,
final Map<String, Object> queryParameters
) {
return new RequestExecutorWrapper<ModificationResult<T>>() {
@Override
ModificationResult<T> execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path, resourceId);
if (queryParameters != null && !queryParameters.isEmpty()) {
uriBuilder.addParameters(convertParameters(queryParameters));
}
HttpResponse response = TransportUtil
.executePatch(getHttpClient(), uriBuilder.build(), getHttpConsumer(), patch);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
@SuppressWarnings("unchecked")
ModificationResult<T> result = new ModificationResult<>(
getObjectReader(resourceClass).readValue(response.getEntity().getContent()), false);
return result;
}
throw parseException(response);
}
}.wrap();
}
/**
* @return operation instance on 202 code, {@code null} on 204 - means that external resource is already in desired
* state, no operation required.
*/
protected <T extends Operation<?, ?>> T executeAction(final String resourceId,
final String path,
final String actionPath,
final Class<T> resourceClass) {
return new RequestExecutorWrapper<T>() {
@Override
T execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path, resourceId, actionPath).build();
HttpResponse response = TransportUtil.executePost(getHttpClient(), uri, getHttpConsumer());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_ACCEPTED) {
T operation = getObjectReader(resourceClass).readValue(response.getEntity().getContent());
PoolOpenOperation.setOperationClient(operation, getFactory().getOperationClient());
return operation;
}
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT) {
return null;
}
throw parseException(response);
}
}.wrap();
}
protected <T, R> ModificationResult<R> executeSyncAction(final T form,
final String path,
final String resourceId,
final String actionPath,
final Class<R> responseClass,
final Map<String, Object> queryParameters) {
return new RequestExecutorWrapper<ModificationResult<R>>() {
@Override
ModificationResult<R> execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path,
resourceId, actionPath);
if (queryParameters != null) {
uriBuilder.addParameters(convertParameters(queryParameters));
}
HttpResponse response = TransportUtil
.executePost(getHttpClient(), uriBuilder.build(), getHttpConsumer(), form);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
@SuppressWarnings("unchecked")
ModificationResult<R> result = new ModificationResult<>(
getObjectReader(responseClass).readValue(response.getEntity().getContent()), false);
return result;
}
throw parseException(response);
}
}.wrap();
}
/**
* Like create but means that return object is operation
*
* @return operation instance on 202 code
*/
protected <T extends Operation<?, ?>, O> T executeAsync(final O form,
final String path,
final Class<T> opClass) {
return new RequestExecutorWrapper<T>() {
@Override
T execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path).build();
HttpResponse response = TransportUtil.executePost(getHttpClient(), uri, getHttpConsumer(), form);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_ACCEPTED) {
T operation = getObjectReader(opClass).readValue(response.getEntity().getContent());
PoolOpenOperation.setOperationClient(operation, getFactory().getOperationClient());
return operation;
}
throw parseException(response);
}
}.wrap();
}
void delete(final String id, final String path) {
Assertions.checkArgNotNull(id, "Id may not be null");
new RequestExecutorWrapper() {
@Override
Object execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), path, id).build();
HttpResponse response = TransportUtil.executeDelete(getHttpClient(), uri, getHttpConsumer());
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {
throw parseException(response);
}
return null;
}
}.wrap();
}
TlkException parseException(HttpResponse response) throws IOException {
InputStream responseContent = response.getEntity().getContent();
TlkError<?> error;
try {
error = getObjectReader(TlkError.class).readValue(responseContent);
} catch (JsonProcessingException ex) {
Scanner s = new Scanner(responseContent).useDelimiter("\\A");
error = new TlkError(TlkError.NGINX_ERROR_CODE, s.hasNext() ? s.next() : null);
}
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 503 || statusCode == 502) {
return new ServiceUnavailableException(error, statusCode);
}
return parseException(error, statusCode);
}
private TlkException parseException(TlkError<?> error, int statusCode) {
if (error instanceof ValidationError) {
return new ValidationException((ValidationError) error, statusCode);
}
switch (error.getCode()) {
case TlkError.NOT_FOUND_CODE:
case TlkError.DOES_NOT_EXIST_CODE:
return new NotFoundException(error, statusCode);
default:
return new TlkException(error, statusCode);
}
}
private List<NameValuePair> convertParameters(Map<String, Object> mapParameters) {
List<NameValuePair> parameters = new ArrayList<>();
for (Map.Entry<String, Object> mapParam : mapParameters.entrySet()) {
if (mapParam.getValue() != null) {
parameters.add(new BasicNameValuePair(mapParam.getKey(), valueToString(mapParam.getValue())));
}
}
return parameters;
}
private String valueToString(Object value) {
if (value instanceof Date) {
return getTolokaDateFormat().format(value);
}
return value.toString();
}
private <T> Runnable readJsonForms(final PipedOutputStream out, final Iterator<T> forms) {
return new Runnable() {
@Override
public void run() {
try (final JsonGenerator generator =
getObjectReader().getFactory().createGenerator(out, JsonEncoding.UTF8)) {
generator.writeStartArray();
while (forms.hasNext()) {
generator.writeObject(forms.next());
}
generator.writeEndArray();
} catch (Exception ex) {
try {
out.close();
} catch (IOException e) {
e.addSuppressed(ex);
throw new RuntimeException(e);
}
throw new RuntimeException(ex);
}
}
};
}
protected abstract static class RequestExecutorWrapper<T> {
T wrap() {
try {
return execute();
} catch (URISyntaxException e) {
logger.error("Unable to initialize valid URL", e);
throw new RuntimeException(e);
} catch (IOException e) {
logger.error("Request error", e);
throw new TolokaRequestIOException(e);
}
}
abstract T execute() throws URISyntaxException, IOException;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/AggregatedSolutionClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.aggregatedsolutions.AggregatedSolution;
import ai.toloka.client.v1.aggregatedsolutions.AggregatedSolutionClient;
import ai.toloka.client.v1.aggregatedsolutions.AggregatedSolutionOperation;
import ai.toloka.client.v1.aggregatedsolutions.AggregatedSolutionSearchRequest;
import ai.toloka.client.v1.aggregatedsolutions.PoolAggregatedSolutionRequest;
import ai.toloka.client.v1.aggregatedsolutions.TaskAggregatedSolutionRequest;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
public class AggregatedSolutionClientImpl extends AbstractClientImpl implements AggregatedSolutionClient {
private static final String AGGREGATED_SOLUTIONS_PATH = "aggregated-solutions";
public AggregatedSolutionClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public AggregatedSolutionOperation aggregateSolutionsByPool(PoolAggregatedSolutionRequest request) {
Assertions.checkArgNotNull(request, "Request may not be null");
return (AggregatedSolutionOperation) executeAsync(request,
AGGREGATED_SOLUTIONS_PATH + "/aggregate-by-pool", Operation.class);
}
@Override
public ModificationResult<AggregatedSolution> aggregateSolutionsByTask(TaskAggregatedSolutionRequest request) {
Assertions.checkArgNotNull(request, "Request may not be null");
Assertions.checkArgNotNull(request.getTaskId(), "Task id may not be null");
return executeSyncAction(request, AGGREGATED_SOLUTIONS_PATH, null,
"aggregate-by-task", AggregatedSolution.class, null);
}
@Override
public SearchResult<AggregatedSolution> findAggregatedSolutions(String operationId,
AggregatedSolutionSearchRequest request) {
return find(request, AGGREGATED_SOLUTIONS_PATH + "/" + operationId,
new TypeReference<SearchResult<AggregatedSolution>>() {});
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/AssignmentClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.assignment.Assignment;
import ai.toloka.client.v1.assignment.AssignmentClient;
import ai.toloka.client.v1.assignment.AssignmentPatch;
import ai.toloka.client.v1.assignment.AssignmentSearchRequest;
import ai.toloka.client.v1.assignment.AssignmentStatus;
import ai.toloka.client.v1.impl.validation.Assertions;
public class AssignmentClientImpl extends AbstractClientImpl implements AssignmentClient {
private static final String ASSIGNMENTS_PATH = "assignments";
public AssignmentClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<Assignment> findAssignments(AssignmentSearchRequest request) {
return find(request, ASSIGNMENTS_PATH, new TypeReference<SearchResult<Assignment>>() {});
}
@Override
public Assignment getAssignment(final String assignmentId) {
return get(assignmentId, ASSIGNMENTS_PATH, Assignment.class);
}
@Override
public ModificationResult<Assignment> patchAssignment(final String assignmentId, final AssignmentPatch patch) {
Assertions.checkArgNotNull(assignmentId, "Id may not be null");
Assertions.checkArgNotNull(patch, "Patch may not be null");
return patch(assignmentId, patch, ASSIGNMENTS_PATH, Assignment.class, null);
}
@Override
public ModificationResult<Assignment> acceptAssignment(String assignmentId, String publicComment) {
return patchAssignment(assignmentId, new AssignmentPatch(AssignmentStatus.ACCEPTED, publicComment));
}
@Override
public ModificationResult<Assignment> rejectAssignment(String assignmentId, String publicComment) {
return patchAssignment(assignmentId, new AssignmentPatch(AssignmentStatus.REJECTED, publicComment));
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/AttachmentClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.attachment.Attachment;
import ai.toloka.client.v1.attachment.AttachmentClient;
import ai.toloka.client.v1.attachment.AttachmentDownload;
import ai.toloka.client.v1.attachment.AttachmentSearchRequest;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.impl.validation.Assertions;
public class AttachmentClientImpl extends AbstractClientImpl implements AttachmentClient {
private static final String ATTACHMENTS_PATH = "attachments";
private static final String DOWNLOAD_PATH = "download";
AttachmentClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<Attachment<?>> findAttachments(AttachmentSearchRequest request) {
return find(request, ATTACHMENTS_PATH, new TypeReference<SearchResult<Attachment>>() {});
}
@Override
public Attachment<?> getAttachment(String attachmentId) {
Assertions.checkArgNotNull(attachmentId, "Id may not be null");
return get(attachmentId, ATTACHMENTS_PATH, Attachment.class);
}
@Override
public AttachmentDownload downloadAttachment(final String attachmentId) {
Assertions.checkArgNotNull(attachmentId, "Id may not be null");
return new RequestExecutorWrapper<AttachmentDownload>() {
@Override
AttachmentDownload execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(
new URIBuilder(getTolokaApiUrl()), ATTACHMENTS_PATH, attachmentId, DOWNLOAD_PATH).build();
HttpResponse response = TransportUtil.executeGet(getHttpClient(), uri, getHttpConsumer());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
final String contentType = response.getFirstHeader("Content-Type").getValue();
final String contentLength = response.getFirstHeader("Content-Length") != null
? response.getFirstHeader("Content-Length").getValue() : null;
final String transferEncoding = response.getFirstHeader("Transfer-Encoding") != null
? response.getFirstHeader("Transfer-Encoding").getValue() : null;
final String contentDisposition = response.getFirstHeader("Content-Disposition") != null
? response.getFirstHeader("Content-Disposition").getValue() : null;
return new AttachmentDownload(response.getEntity().getContent(), contentType, contentLength,
transferEncoding, contentDisposition);
}
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
return null;
}
throw parseException(response);
}
}.wrap();
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/MessageThreadClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.messagethread.MessageThread;
import ai.toloka.client.v1.messagethread.MessageThreadClient;
import ai.toloka.client.v1.messagethread.MessageThreadCompose;
import ai.toloka.client.v1.messagethread.MessageThreadFolders;
import ai.toloka.client.v1.messagethread.MessageThreadReply;
import ai.toloka.client.v1.messagethread.MessageThreadSearchRequest;
public class MessageThreadClientImpl extends AbstractClientImpl implements MessageThreadClient {
private static final String MESSAGE_THREADS_PATH = "message-threads";
private static final String MESSAGE_THREADS_COMPOSE_ACTION_PATH = "compose";
private static final String MESSAGE_THREADS_REPLY_ACTION_PATH = "reply";
private static final String MESSAGE_THREADS_ADD_TO_FOLDERS_ACTION_PATH = "add-to-folders";
private static final String MESSAGE_THREADS_REMOVE_FROM_FOLDERS_ACTION_PATH = "remove-from-folders";
MessageThreadClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<MessageThread> findMessageThreads(MessageThreadSearchRequest request) {
return find(request, MESSAGE_THREADS_PATH, new TypeReference<SearchResult<MessageThread>>() {});
}
@Override
public ModificationResult<MessageThread> composeMessageThread(MessageThreadCompose compose) {
Assertions.checkArgNotNull(compose, "Compose may not be null");
String path = MESSAGE_THREADS_PATH + "/" + MESSAGE_THREADS_COMPOSE_ACTION_PATH;
return create(compose, path, MessageThread.class, null);
}
@Override
public ModificationResult<MessageThread> replyMessageThread(String messageThreadId, MessageThreadReply reply) {
Assertions.checkArgNotNull(messageThreadId, "Id may not be null");
Assertions.checkArgNotNull(reply, "Reply may not be null");
return executeSyncAction(reply, MESSAGE_THREADS_PATH, messageThreadId, MESSAGE_THREADS_REPLY_ACTION_PATH,
MessageThread.class, null);
}
@Override
public ModificationResult<MessageThread> addToFolders(String messageThreadId, MessageThreadFolders folders) {
return changeFolders(messageThreadId, folders, MESSAGE_THREADS_ADD_TO_FOLDERS_ACTION_PATH);
}
private ModificationResult<MessageThread> changeFolders(String messageThreadId, MessageThreadFolders folders,
String actionPath) {
Assertions.checkArgNotNull(messageThreadId, "Id may not be null");
Assertions.checkArgNotNull(folders, "Folders may not be null");
Assertions.checkArgNotNull(folders.getFolders(), "Folders set may not be null");
return executeSyncAction(folders, MESSAGE_THREADS_PATH, messageThreadId, actionPath, MessageThread.class,
null);
}
@Override
public ModificationResult<MessageThread> removeFromFolders(String messageThreadId, MessageThreadFolders folders) {
return changeFolders(messageThreadId, folders, MESSAGE_THREADS_REMOVE_FROM_FOLDERS_ACTION_PATH);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/OperationClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.operation.OperationClient;
import ai.toloka.client.v1.operation.OperationLogItem;
import ai.toloka.client.v1.operation.OperationSearchRequest;
import static ai.toloka.client.v1.impl.transport.MapperUtil.getObjectReader;
public class OperationClientImpl extends AbstractClientImpl implements OperationClient {
private static final String OPERATIONS_PATH = "operations";
private static final String LOG_PATH = "log";
OperationClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<Operation<?, ?>> findOperations(OperationSearchRequest request) {
SearchResult<Operation<?, ?>> result =
find(request, OPERATIONS_PATH, new TypeReference<SearchResult<Operation>>() {});
for (Operation operation : result.getItems()) {
Operation.setOperationClient(operation, this);
}
return result;
}
@Override
public <T extends Operation<?, ?>> T getOperation(final String operationId) {
Assertions.checkArgNotNull(operationId, "Id may not be null");
if (Operation.PSEUDO_OPERATION_ID.equals(operationId)) {
@SuppressWarnings("unchecked")
T pseudo = (T) Operation.createPseudo(new Date());
return pseudo;
}
return new RequestExecutorWrapper<T>() {
@SuppressWarnings("unchecked")
@Override
T execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), OPERATIONS_PATH, operationId).build();
HttpResponse response = TransportUtil.executeGet(getHttpClient(), uri, getHttpConsumer());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
T result = getObjectReader(Operation.class).readValue(response.getEntity().getContent());
Operation.setOperationClient(result, OperationClientImpl.this);
return result;
}
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
return null;
}
throw parseException(response);
}
}.wrap();
}
@SuppressWarnings("unchecked")
@Override
public <T extends Operation<?, ?>> T getOperation(String operationId, Class<T> c) {
Assertions.checkArgNotNull(c, "Requested class may not be null");
Operation<?, ?> operation = getOperation(operationId);
if (operation == null) {
return null;
}
if (!operation.getClass().equals(c)) {
throw new IllegalArgumentException("Requested class and actual operation type doesn't match");
}
return (T) operation;
}
@Override
public Iterator<OperationLogItem> getOperationLog(final String operationId) {
Assertions.checkArgNotNull(operationId, "Id may not be null");
if (Operation.PSEUDO_OPERATION_ID.equals(operationId)) {
return Collections.emptyIterator();
}
return new RequestExecutorWrapper<Iterator<OperationLogItem>>() {
@Override
Iterator<OperationLogItem> execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), OPERATIONS_PATH, operationId, LOG_PATH)
.build();
HttpResponse response = TransportUtil.executeGet(getHttpClient(), uri, getHttpConsumer());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
JsonParser parser = getObjectReader().getFactory().createParser(response.getEntity().getContent());
parser.nextToken(); // read start of array
JsonToken firstArrayToken = parser.nextToken();
if (firstArrayToken == JsonToken.END_ARRAY) {
return Collections.emptyIterator();
}
return parser.readValuesAs(OperationLogItem.class);
}
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
return null;
}
throw parseException(response);
}
}.wrap();
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/PoolClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.util.Date;
import com.fasterxml.jackson.core.type.TypeReference;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.pool.Pool;
import ai.toloka.client.v1.pool.PoolArchiveOperation;
import ai.toloka.client.v1.pool.PoolClient;
import ai.toloka.client.v1.pool.PoolCloneOperation;
import ai.toloka.client.v1.pool.PoolCloseOperation;
import ai.toloka.client.v1.pool.PoolOpenOperation;
import ai.toloka.client.v1.pool.PoolPatchRequest;
import ai.toloka.client.v1.pool.PoolSearchRequest;
public class PoolClientImpl extends AbstractClientImpl implements PoolClient {
private static final String POOLS_PATH = "pools";
private static final String POOLS_OPEN_ACTION_PATH = "open";
private static final String POOLS_CLOSE_ACTION_PATH = "close";
private static final String POOLS_CLOSE_FOR_UPDATE_ACTION_PATH = "close-for-update";
private static final String POOLS_ARCHIVE_ACTION_PATH = "archive";
private static final String POOLS_CLONE_ACTION_PATH = "clone";
PoolClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<Pool> findPools(final PoolSearchRequest request) {
return find(request, POOLS_PATH, new TypeReference<SearchResult<Pool>>() {});
}
@Override
public Pool getPool(final String id) {
return get(id, POOLS_PATH, Pool.class);
}
@Override
public ModificationResult<Pool> createPool(final Pool pool) {
Assertions.checkArgNotNull(pool, "Pool may not be null");
return create(pool, POOLS_PATH, Pool.class, null);
}
@Override
public ModificationResult<Pool> updatePool(String poolId, Pool pool) {
Assertions.checkArgNotNull(poolId, "Pool id may not be null");
Assertions.checkArgNotNull(pool, "Pool form may not be null");
return update(poolId, pool, POOLS_PATH, Pool.class);
}
@Override
public ModificationResult<Pool> patchPool(String poolId, PoolPatchRequest request) {
Assertions.checkArgNotNull(poolId, "Id may not be null");
Assertions.checkArgNotNull(request, "Patch request may not be null");
return patch(poolId, request, POOLS_PATH, Pool.class, null);
}
@Override
public PoolOpenOperation openPool(final String poolId) {
Assertions.checkArgNotNull(poolId, "Id may not be null");
PoolOpenOperation operation =
(PoolOpenOperation) executeAction(poolId, POOLS_PATH, POOLS_OPEN_ACTION_PATH, Operation.class);
if (operation == null) {
return PoolOpenOperation.createPseudo(new Date());
}
return operation;
}
@Override
public PoolCloseOperation closePool(final String poolId) {
Assertions.checkArgNotNull(poolId, "Id may not be null");
PoolCloseOperation operation =
(PoolCloseOperation) executeAction(poolId, POOLS_PATH, POOLS_CLOSE_ACTION_PATH, Operation.class);
if (operation == null) {
return PoolCloseOperation.createPseudo(new Date());
}
return operation;
}
@Override
public PoolCloseOperation closePoolForUpdate(String poolId) {
Assertions.checkArgNotNull(poolId, "Id may not be null");
PoolCloseOperation operation = (PoolCloseOperation) executeAction(poolId, POOLS_PATH,
POOLS_CLOSE_FOR_UPDATE_ACTION_PATH, Operation.class);
if (operation == null) {
return PoolCloseOperation.createPseudo(new Date());
}
return operation;
}
@Override
public PoolArchiveOperation archivePool(final String poolId) {
Assertions.checkArgNotNull(poolId, "Id may not be null");
PoolArchiveOperation operation =
(PoolArchiveOperation) executeAction(poolId, POOLS_PATH, POOLS_ARCHIVE_ACTION_PATH, Operation.class);
if (operation == null) {
return PoolArchiveOperation.createPseudo(new Date());
}
return operation;
}
@Override
public PoolCloneOperation clonePool(String poolId) {
Assertions.checkArgNotNull(poolId, "Id may not be null");
PoolCloneOperation operation =
(PoolCloneOperation) executeAction(poolId, POOLS_PATH, POOLS_CLONE_ACTION_PATH, Operation.class);
if (operation == null) {
return PoolCloneOperation.createPseudo(new Date());
}
return operation;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/ProjectClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.util.Date;
import com.fasterxml.jackson.core.type.TypeReference;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.project.Project;
import ai.toloka.client.v1.project.ProjectArchiveOperation;
import ai.toloka.client.v1.project.ProjectClient;
import ai.toloka.client.v1.project.ProjectSearchRequest;
public class ProjectClientImpl extends AbstractClientImpl implements ProjectClient {
private static final String PROJECTS_PATH = "projects";
private static final String ARCHIVE_ACTION_PATH = "archive";
ProjectClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<Project> findProjects(final ProjectSearchRequest request) {
return find(request, PROJECTS_PATH, new TypeReference<SearchResult<Project>>() {});
}
@Override
public Project getProject(final String projectId) {
return get(projectId, PROJECTS_PATH, Project.class);
}
@Override
public ModificationResult<Project> createProject(final Project project) {
Assertions.checkArgNotNull(project, "Project may not be null");
return create(project, PROJECTS_PATH, Project.class, null);
}
@Override
public ModificationResult<Project> updateProject(final String projectId, final Project project) {
Assertions.checkArgNotNull(projectId, "Project id may not be null");
Assertions.checkArgNotNull(project, "Project may not be null");
return update(projectId, project, PROJECTS_PATH, Project.class);
}
@Override
public ProjectArchiveOperation archiveProject(String projectId) {
Assertions.checkArgNotNull(projectId, "Id may not be null");
ProjectArchiveOperation operation =
(ProjectArchiveOperation) executeAction(projectId, PROJECTS_PATH, ARCHIVE_ACTION_PATH, Operation.class);
if (operation == null) {
return ProjectArchiveOperation.createPseudo(new Date());
}
return operation;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/RequesterClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import ai.toloka.client.v1.impl.transport.MapperUtil;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.requester.Requester;
import ai.toloka.client.v1.requester.RequesterClient;
public class RequesterClientImpl extends AbstractClientImpl implements RequesterClient {
private static final String REQUESTER_PATH = "requester";
RequesterClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public Requester getRequester() {
return new RequestExecutorWrapper<Requester>() {
@Override
Requester execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), REQUESTER_PATH).build();
HttpResponse response = TransportUtil.executeGet(getHttpClient(), uri, getHttpConsumer());
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw parseException(response);
}
return MapperUtil.getObjectReader(Requester.class).readValue(response.getEntity().getContent());
}
}.wrap();
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/SkillClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.skill.Skill;
import ai.toloka.client.v1.skill.SkillClient;
import ai.toloka.client.v1.skill.SkillSearchRequest;
import static ai.toloka.client.v1.impl.transport.MapperUtil.getObjectReader;
public class SkillClientImpl extends AbstractClientImpl implements SkillClient {
private static final String SKILLS_PATH = "skills";
SkillClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<Skill> findSkills(final SkillSearchRequest request) {
return find(request, SKILLS_PATH, new TypeReference<SearchResult<Skill>>() {});
}
@Override
public Skill getSkill(final String skillId) {
return get(skillId, SKILLS_PATH, Skill.class);
}
@Override
public ModificationResult<Skill> createSkill(final Skill skill) {
Assertions.checkArgNotNull(skill, "Skill may not be null");
return create(skill, SKILLS_PATH, Skill.class, null);
}
@Override
public ModificationResult<Skill> updateSkill(final String skillId, final Skill skill) {
Assertions.checkArgNotNull(skillId, "Skill id may not be null");
Assertions.checkArgNotNull(skill, "Skill may not be null");
return new RequestExecutorWrapper<ModificationResult<Skill>>() {
@Override
ModificationResult<Skill> execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), SKILLS_PATH, skillId).build();
HttpResponse response = TransportUtil.executePut(getHttpClient(), uri, getHttpConsumer(), skill);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
return new ModificationResult<>(
getObjectReader(Skill.class).readValue(response.getEntity().getContent()), false);
}
throw parseException(response);
}
}.wrap();
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/TaskClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import ai.toloka.client.v1.BatchCreateResult;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.task.Task;
import ai.toloka.client.v1.task.TaskClient;
import ai.toloka.client.v1.task.TaskCreateBatchOperation;
import ai.toloka.client.v1.task.TaskCreateRequestParameters;
import ai.toloka.client.v1.task.TaskOverlapPatch;
import ai.toloka.client.v1.task.TaskPatch;
import ai.toloka.client.v1.task.TaskPatchRequestParameters;
import ai.toloka.client.v1.task.TaskSearchRequest;
import static ai.toloka.client.v1.impl.transport.MapperUtil.getObjectReader;
public class TaskClientImpl extends AbstractClientImpl implements TaskClient {
private static final String TASKS_PATH = "tasks";
private static final String SET_OVERLAP_OR_MIN_PATH = "set-overlap-or-min";
TaskClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public ModificationResult<Task> createTask(Task task) {
return createTask(task, null);
}
@Override
public ModificationResult<Task> createTask(Task task, TaskCreateRequestParameters parameters) {
Assertions.checkArgNotNull(task, "Task may not be null");
return create(task, TASKS_PATH, Task.class, parameters != null ? parameters.getQueryParameters() : null);
}
@Override
public BatchCreateResult<Task> createTasks(List<Task> tasks) {
return createTasks(tasks, null);
}
@Override
public BatchCreateResult<Task> createTasks(List<Task> tasks, TaskCreateRequestParameters parameters) {
Assertions.checkArgNotNull(tasks, "Tasks may not be null");
return createMultiple(tasks, TASKS_PATH, new TypeReference<BatchCreateResult<Task>>() {}, parameters);
}
@Override
public TaskCreateBatchOperation createTasksAsync(Iterator<Task> tasks) {
return createTasksAsync(tasks, null);
}
@Override
public TaskCreateBatchOperation createTasksAsync(Iterator<Task> tasks, TaskCreateRequestParameters parameters) {
return (TaskCreateBatchOperation) createMultipleAsync(tasks, TASKS_PATH, Operation.class, parameters);
}
@Override
public SearchResult<Task> findTasks(TaskSearchRequest request) {
return find(request, TASKS_PATH, new TypeReference<SearchResult<Task>>() {});
}
@Override
public Task getTask(String taskId) {
return get(taskId, TASKS_PATH, Task.class);
}
@Override
public ModificationResult<Task> patchTask(String taskId, TaskPatch patch) {
return patchTask(taskId, patch, null);
}
@Override
public ModificationResult<Task> patchTask(String taskId, TaskPatch patch,
TaskPatchRequestParameters parameters) {
return patch(taskId, patch, TASKS_PATH, Task.class,
parameters != null ? parameters.getQueryParameters() : null);
}
@Override
public ModificationResult<Task> setOverlapOrMin(final String taskId, final TaskOverlapPatch overlapPatch) {
Assertions.checkArgNotNull(taskId, "Id may not be null");
Assertions.checkArgNotNull(overlapPatch, "Patch form may not be null");
return new RequestExecutorWrapper<ModificationResult<Task>>() {
@Override
ModificationResult<Task> execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), TASKS_PATH, taskId,
SET_OVERLAP_OR_MIN_PATH);
HttpResponse response = TransportUtil.executePatch(getHttpClient(), uriBuilder.build(),
getHttpConsumer(), overlapPatch);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
@SuppressWarnings("unchecked")
ModificationResult<Task> result = new ModificationResult<>(
getObjectReader(Task.class).readValue(response.getEntity().getContent()), false);
return result;
}
throw parseException(response);
}
}.wrap();
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/TaskSuiteClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import ai.toloka.client.v1.BatchCreateResult;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.tasksuite.TaskSuite;
import ai.toloka.client.v1.tasksuite.TaskSuiteClient;
import ai.toloka.client.v1.tasksuite.TaskSuiteCreateBatchOperation;
import ai.toloka.client.v1.tasksuite.TaskSuiteCreateRequestParameters;
import ai.toloka.client.v1.tasksuite.TaskSuiteOverlapPatch;
import ai.toloka.client.v1.tasksuite.TaskSuitePatch;
import ai.toloka.client.v1.tasksuite.TaskSuitePatchRequestParameters;
import ai.toloka.client.v1.tasksuite.TaskSuiteSearchRequest;
import static ai.toloka.client.v1.impl.transport.MapperUtil.getObjectReader;
public class TaskSuiteClientImpl extends AbstractClientImpl implements TaskSuiteClient {
private static final String TASK_SUITES_PATH = "task-suites";
private static final String SET_OVERLAP_OR_MIN_PATH = "set-overlap-or-min";
TaskSuiteClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public ModificationResult<TaskSuite> createTaskSuite(TaskSuite taskSuite) {
return createTaskSuite(taskSuite, null);
}
@Override
public ModificationResult<TaskSuite> createTaskSuite(final TaskSuite taskSuite,
final TaskSuiteCreateRequestParameters parameters) {
Assertions.checkArgNotNull(taskSuite, "Task suite may not be null");
return create(taskSuite, TASK_SUITES_PATH, TaskSuite.class,
parameters != null ? parameters.getQueryParameters() : null);
}
@Override
public BatchCreateResult<TaskSuite> createTaskSuites(List<TaskSuite> taskSuites) {
return createTaskSuites(taskSuites, null);
}
@Override
public BatchCreateResult<TaskSuite> createTaskSuites(final List<TaskSuite> taskSuites,
final TaskSuiteCreateRequestParameters parameters) {
Assertions.checkArgNotNull(taskSuites, "Task suites may not be null");
return createMultiple(
taskSuites, TASK_SUITES_PATH, new TypeReference<BatchCreateResult<TaskSuite>>() {}, parameters);
}
@Override
public TaskSuiteCreateBatchOperation createTaskSuitesAsync(Iterator<TaskSuite> taskSuites) {
return createTaskSuitesAsync(taskSuites, null);
}
@Override
public TaskSuiteCreateBatchOperation createTaskSuitesAsync(final Iterator<TaskSuite> taskSuites,
final TaskSuiteCreateRequestParameters parameters) {
Assertions.checkArgNotNull(taskSuites, "Task suites may not be null");
return (TaskSuiteCreateBatchOperation) createMultipleAsync(
taskSuites, TASK_SUITES_PATH, Operation.class, parameters);
}
@Override
public SearchResult<TaskSuite> findTaskSuites(TaskSuiteSearchRequest request) {
return find(request, TASK_SUITES_PATH, new TypeReference<SearchResult<TaskSuite>>() {});
}
@Override
public TaskSuite getTaskSuite(String taskSuiteId) {
Assertions.checkArgNotNull(taskSuiteId, "Id may not be null");
return get(taskSuiteId, TASK_SUITES_PATH, TaskSuite.class);
}
@Override
public ModificationResult<TaskSuite> patchTaskSuite(String taskSuiteId, TaskSuitePatch patch) {
return patchTaskSuite(taskSuiteId, patch, null);
}
@Override
public ModificationResult<TaskSuite> patchTaskSuite(String taskSuiteId,
TaskSuitePatch patch,
TaskSuitePatchRequestParameters parameters) {
Assertions.checkArgNotNull(taskSuiteId, "Id may not be null");
Assertions.checkArgNotNull(patch, "Patch form may not be null");
return patch(taskSuiteId, patch, TASK_SUITES_PATH, TaskSuite.class,
parameters != null ? parameters.getQueryParameters() : null);
}
@Override
public ModificationResult<TaskSuite> setOverlapOrMin(
final String taskSuiteId,
final TaskSuiteOverlapPatch overlapPatch
) {
Assertions.checkArgNotNull(taskSuiteId, "Id may not be null");
Assertions.checkArgNotNull(overlapPatch, "Overlap patch form may not be null");
return new RequestExecutorWrapper<ModificationResult<TaskSuite>>() {
@Override
ModificationResult<TaskSuite> execute() throws URISyntaxException, IOException {
URIBuilder uriBuilder = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), TASK_SUITES_PATH,
taskSuiteId, SET_OVERLAP_OR_MIN_PATH);
HttpResponse response = TransportUtil.executePatch(getHttpClient(), uriBuilder.build(),
getHttpConsumer(), overlapPatch);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
@SuppressWarnings("unchecked")
ModificationResult<TaskSuite> result = new ModificationResult<>(
getObjectReader(TaskSuite.class).readValue(response.getEntity().getContent()), false);
return result;
}
throw parseException(response);
}
}.wrap();
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/TolokaClientFactoryImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.net.URI;
import java.util.function.Consumer;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpRequestBase;
import ai.toloka.client.v1.TolokaClientFactory;
import ai.toloka.client.v1.aggregatedsolutions.AggregatedSolutionClient;
import ai.toloka.client.v1.assignment.AssignmentClient;
import ai.toloka.client.v1.attachment.AttachmentClient;
import ai.toloka.client.v1.impl.transport.DefaultHttpClientConfiguration;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.messagethread.MessageThreadClient;
import ai.toloka.client.v1.metadata.UserMetadataClient;
import ai.toloka.client.v1.operation.OperationClient;
import ai.toloka.client.v1.pool.PoolClient;
import ai.toloka.client.v1.project.ProjectClient;
import ai.toloka.client.v1.requester.RequesterClient;
import ai.toloka.client.v1.skill.SkillClient;
import ai.toloka.client.v1.task.TaskClient;
import ai.toloka.client.v1.tasksuite.TaskSuiteClient;
import ai.toloka.client.v1.training.TrainingClient;
import ai.toloka.client.v1.userbonus.UserBonusClient;
import ai.toloka.client.v1.userrestriction.UserRestrictionClient;
import ai.toloka.client.v1.userskill.UserSkillClient;
import ai.toloka.client.v1.webhooksubscription.WebhookSubscriptionClient;
public class TolokaClientFactoryImpl implements TolokaClientFactory {
private final HttpClient httpClient;
private final URI tolokaApiUrl;
private Consumer<HttpRequestBase> headersSupplier;
private RequesterClient requesterClient;
private ProjectClient projectClient;
private PoolClient poolClient;
private TrainingClient trainingClient;
private TaskClient taskClient;
private TaskSuiteClient taskSuiteClient;
private AssignmentClient assignmentClient;
private AggregatedSolutionClient aggregatedSolutionClient;
private UserSkillClient userSkillClient;
private UserRestrictionClient userRestrictionClient;
private AttachmentClient attachmentClient;
private OperationClient operationClient;
private SkillClient skillClient;
private UserBonusClient userBonusClient;
private MessageThreadClient messageThreadClient;
private WebhookSubscriptionClient webhookSubscriptionClient;
private UserMetadataClientImpl userMetadataClient;
public TolokaClientFactoryImpl(String tokenOrKey) {
Assertions.checkArgNotNull(tokenOrKey, "Token or Api Key must be null provided");
this.tolokaApiUrl = DefaultHttpClientConfiguration.DEFAULT_TOLOKA_SANDBOX_URI;
this.httpClient = DefaultHttpClientConfiguration.buildDefaultClient(tokenOrKey);
}
/**
* @param tolokaApiUrl path to Toloka API
* @param tokenOrKey Token or Api Key may be obtained from web UI
*/
public TolokaClientFactoryImpl(URI tolokaApiUrl, String tokenOrKey) {
Assertions.checkArgNotNull(tolokaApiUrl, "Toloka API URL may not be null");
Assertions.checkArgNotNull(tokenOrKey, "Token or Api Key must be provided");
this.tolokaApiUrl = tolokaApiUrl;
this.httpClient = DefaultHttpClientConfiguration.buildDefaultClient(tokenOrKey);
}
/**
* @param tolokaApiUrl path to Toloka API
* @param tokenOrKey Token or Api Key may be obtained from web UI
*/
public TolokaClientFactoryImpl(String tolokaApiUrl, String tokenOrKey) {
Assertions.checkArgNotNull(tolokaApiUrl, "Toloka API URL may not be null");
Assertions.checkArgNotNull(tokenOrKey, "Token or Api Key must be provided");
this.tolokaApiUrl = URI.create(tolokaApiUrl);
this.httpClient = DefaultHttpClientConfiguration.buildDefaultClient(tokenOrKey);
}
public TolokaClientFactoryImpl(URI tolokaApiUrl, HttpClient httpClient) {
Assertions.checkArgNotNull(tolokaApiUrl, "Toloka API URL may not be null");
Assertions.checkArgNotNull(httpClient, "Http Client may not be null");
this.tolokaApiUrl = tolokaApiUrl;
this.httpClient = httpClient;
}
public TolokaClientFactoryImpl(String tolokaApiUrl, HttpClient httpClient) {
Assertions.checkArgNotNull(tolokaApiUrl, "Toloka API URL may not be null");
Assertions.checkArgNotNull(httpClient, "Http Client may not be null");
this.tolokaApiUrl = URI.create(tolokaApiUrl);
this.httpClient = httpClient;
}
@Override
public RequesterClient getRequesterClient() {
if (requesterClient == null) {
this.requesterClient = new RequesterClientImpl(this);
}
return requesterClient;
}
@Override
public ProjectClient getProjectClient() {
if (projectClient == null) {
this.projectClient = new ProjectClientImpl(this);
}
return projectClient;
}
@Override
public PoolClient getPoolClient() {
if (poolClient == null) {
this.poolClient = new PoolClientImpl(this);
}
return poolClient;
}
@Override
public TrainingClient getTrainingClient() {
if (trainingClient == null) {
this.trainingClient = new TrainingClientImpl(this);
}
return trainingClient;
}
@Override
public TaskClient getTaskClient() {
if (taskClient == null) {
taskClient = new TaskClientImpl(this);
}
return taskClient;
}
@Override
public TaskSuiteClient getTaskSuiteClient() {
if (taskSuiteClient == null) {
this.taskSuiteClient = new TaskSuiteClientImpl(this);
}
return taskSuiteClient;
}
@Override
public AssignmentClient getAssignmentClient() {
if (this.assignmentClient == null) {
this.assignmentClient = new AssignmentClientImpl(this);
}
return assignmentClient;
}
@Override
public AggregatedSolutionClient getAggregatedSolutionClient() {
if (this.aggregatedSolutionClient == null) {
this.aggregatedSolutionClient = new AggregatedSolutionClientImpl(this);
}
return aggregatedSolutionClient;
}
@Override
public UserSkillClient getUserSkillClient() {
if (this.userSkillClient == null) {
this.userSkillClient = new UserSkillClientImpl(this);
}
return this.userSkillClient;
}
@Override
public UserRestrictionClient getUserRestrictionClient() {
if (this.userRestrictionClient == null) {
this.userRestrictionClient = new UserRestrictionClientImpl(this);
}
return this.userRestrictionClient;
}
@Override
public AttachmentClient getAttachmentClient() {
if (this.attachmentClient == null) {
this.attachmentClient = new AttachmentClientImpl(this);
}
return this.attachmentClient;
}
@Override
public OperationClient getOperationClient() {
if (operationClient == null) {
this.operationClient = new OperationClientImpl(this);
}
return operationClient;
}
@Override
public SkillClient getSkillClient() {
if (skillClient == null) {
this.skillClient = new SkillClientImpl(this);
}
return skillClient;
}
@Override
public UserBonusClient getUserBonusClient() {
if (userBonusClient == null) {
this.userBonusClient = new UserBonusClientImpl(this);
}
return userBonusClient;
}
@Override
public MessageThreadClient getMessageThreadClient() {
if (messageThreadClient == null) {
this.messageThreadClient = new MessageThreadClientImpl(this);
}
return messageThreadClient;
}
@Override
public WebhookSubscriptionClient getWebhookSubscriptionClient() {
if (webhookSubscriptionClient == null) {
this.webhookSubscriptionClient = new WebhookSubscriptionClientImpl(this);
}
return webhookSubscriptionClient;
}
@Override
public UserMetadataClient getUserMetadataClient() {
if (userMetadataClient == null) {
this.userMetadataClient = new UserMetadataClientImpl(this);
}
return userMetadataClient;
}
public URI getTolokaApiUrl() {
return tolokaApiUrl;
}
public HttpClient getHttpClient() {
return httpClient;
}
public Consumer<HttpRequestBase> getHeadersSupplier() {
return headersSupplier;
}
public TolokaClientFactoryImpl tune(Consumer<HttpRequestBase> httpConsumer) {
this.headersSupplier = httpConsumer;
return this;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/TrainingClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.util.Date;
import com.fasterxml.jackson.core.type.TypeReference;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.training.Training;
import ai.toloka.client.v1.training.TrainingArchiveOperation;
import ai.toloka.client.v1.training.TrainingClient;
import ai.toloka.client.v1.training.TrainingCloneOperation;
import ai.toloka.client.v1.training.TrainingCloseOperation;
import ai.toloka.client.v1.training.TrainingOpenOperation;
import ai.toloka.client.v1.training.TrainingSearchRequest;
public class TrainingClientImpl extends AbstractClientImpl implements TrainingClient {
private static final String TRAININGS_PATH = "trainings";
private static final String TRAININGS_OPEN_ACTION_PATH = "open";
private static final String TRAININGS_CLOSE_ACTION_PATH = "close";
private static final String TRAININGS_ARCHIVE_ACTION_PATH = "archive";
private static final String TRAININGS_CLONE_ACTION_PATH = "clone";
TrainingClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<Training> findTrainings(final TrainingSearchRequest request) {
return find(request, TRAININGS_PATH, new TypeReference<SearchResult<Training>>() {});
}
@Override
public Training getTraining(final String id) {
return get(id, TRAININGS_PATH, Training.class);
}
@Override
public ModificationResult<Training> createTraining(final Training training) {
Assertions.checkArgNotNull(training, "Training may not be null");
return create(training, TRAININGS_PATH, Training.class, null);
}
@Override
public ModificationResult<Training> updateTraining(String trainingId, Training training) {
Assertions.checkArgNotNull(trainingId, "Training id may not be null");
Assertions.checkArgNotNull(training, "Training form may not be null");
return update(trainingId, training, TRAININGS_PATH, Training.class);
}
@Override
public TrainingOpenOperation openTraining(final String trainingId) {
Assertions.checkArgNotNull(trainingId, "Id may not be null");
TrainingOpenOperation operation = (TrainingOpenOperation) executeAction(trainingId, TRAININGS_PATH,
TRAININGS_OPEN_ACTION_PATH, Operation.class);
if (operation == null) {
return TrainingOpenOperation.createPseudo(new Date());
}
return operation;
}
@Override
public TrainingCloseOperation closeTraining(final String trainingId) {
Assertions.checkArgNotNull(trainingId, "Id may not be null");
TrainingCloseOperation operation = (TrainingCloseOperation) executeAction(trainingId, TRAININGS_PATH,
TRAININGS_CLOSE_ACTION_PATH, Operation.class);
if (operation == null) {
return TrainingCloseOperation.createPseudo(new Date());
}
return operation;
}
@Override
public TrainingArchiveOperation archiveTraining(final String trainingId) {
Assertions.checkArgNotNull(trainingId, "Id may not be null");
TrainingArchiveOperation operation = (TrainingArchiveOperation) executeAction(trainingId, TRAININGS_PATH,
TRAININGS_ARCHIVE_ACTION_PATH, Operation.class);
if (operation == null) {
return TrainingArchiveOperation.createPseudo(new Date());
}
return operation;
}
@Override
public TrainingCloneOperation cloneTraining(String trainingId) {
Assertions.checkArgNotNull(trainingId, "Id may not be null");
TrainingCloneOperation operation = (TrainingCloneOperation) executeAction(trainingId, TRAININGS_PATH,
TRAININGS_CLONE_ACTION_PATH, Operation.class);
if (operation == null) {
return TrainingCloneOperation.createPseudo(new Date());
}
return operation;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/UserBonusClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.util.Iterator;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import ai.toloka.client.v1.BatchCreateResult;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.userbonus.UserBonus;
import ai.toloka.client.v1.userbonus.UserBonusClient;
import ai.toloka.client.v1.userbonus.UserBonusCreateBatchOperation;
import ai.toloka.client.v1.userbonus.UserBonusCreateRequestParameters;
import ai.toloka.client.v1.userbonus.UserBonusSearchRequest;
public class UserBonusClientImpl extends AbstractClientImpl implements UserBonusClient {
private static final String USER_BONUSES_PATH = "user-bonuses";
UserBonusClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public ModificationResult<UserBonus> createUserBonus(UserBonus userBonus) {
return createUserBonus(userBonus, null);
}
@Override
public ModificationResult<UserBonus> createUserBonus(UserBonus userBonus,
UserBonusCreateRequestParameters parameters) {
Assertions.checkArgNotNull(userBonus, "Form may not be null");
return create(userBonus, USER_BONUSES_PATH, UserBonus.class,
parameters != null ? parameters.getQueryParameters() : null);
}
@Override
public BatchCreateResult<UserBonus> createUserBonuses(List<UserBonus> userBonuses) {
return createUserBonuses(userBonuses, null);
}
@Override
public BatchCreateResult<UserBonus> createUserBonuses(List<UserBonus> userBonuses,
UserBonusCreateRequestParameters parameters) {
Assertions.checkArgNotNull(userBonuses, "Forms may not be null");
return createMultiple(
userBonuses, USER_BONUSES_PATH, new TypeReference<BatchCreateResult<UserBonus>>() {}, parameters);
}
@Override
public UserBonusCreateBatchOperation createUserBonusesAsync(Iterator<UserBonus> userBonuses) {
return createUserBonusesAsync(userBonuses, null);
}
@Override
public UserBonusCreateBatchOperation createUserBonusesAsync(Iterator<UserBonus> userBonuses,
UserBonusCreateRequestParameters parameters) {
Assertions.checkArgNotNull(userBonuses, "Forms may not be null");
return (UserBonusCreateBatchOperation) createMultipleAsync(
userBonuses, USER_BONUSES_PATH, Operation.class, parameters);
}
@Override
public SearchResult<UserBonus> findUserBonuses(UserBonusSearchRequest request) {
return find(request, USER_BONUSES_PATH, new TypeReference<SearchResult<UserBonus>>() {});
}
@Override
public UserBonus getUserBonus(String userBonusId) {
Assertions.checkArgNotNull(userBonusId, "Id may not be null");
return get(userBonusId, USER_BONUSES_PATH, UserBonus.class);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/UserMetadataClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.metadata.UserMetadata;
import ai.toloka.client.v1.metadata.UserMetadataClient;
public class UserMetadataClientImpl extends AbstractClientImpl implements UserMetadataClient {
private static final String USER_METADATA_PATH = "user-metadata";
UserMetadataClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public UserMetadata getUserMetadata(String userId) {
Assertions.checkArgNotNull(userId, "Id may not be null");
return get(userId, USER_METADATA_PATH, UserMetadata.class);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/UserRestrictionClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.transport.MapperUtil;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.userrestriction.UserRestriction;
import ai.toloka.client.v1.userrestriction.UserRestrictionClient;
import ai.toloka.client.v1.userrestriction.UserRestrictionSearchRequest;
public class UserRestrictionClientImpl extends AbstractClientImpl implements UserRestrictionClient {
private static final String USER_RESTRICTIONS_PATH = "user-restrictions";
UserRestrictionClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<UserRestriction> findUserRestrictions(final UserRestrictionSearchRequest request) {
return find(request, USER_RESTRICTIONS_PATH, new TypeReference<SearchResult<UserRestriction>>() {});
}
@Override
public UserRestriction getUserRestriction(final String userRestrictionId) {
return get(userRestrictionId, USER_RESTRICTIONS_PATH, UserRestriction.class);
}
@Override
public ModificationResult<UserRestriction> setUserRestriction(final UserRestriction userRestriction) {
Assertions.checkArgNotNull(userRestriction, "User restriction may not be null");
return new RequestExecutorWrapper<ModificationResult<UserRestriction>>() {
@Override
ModificationResult<UserRestriction> execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), USER_RESTRICTIONS_PATH).build();
HttpResponse response = TransportUtil
.executePut(getHttpClient(), uri, getHttpConsumer(), userRestriction);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK
|| response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED) {
return new ModificationResult<>(
MapperUtil.getObjectReader(UserRestriction.class)
.readValue(response.getEntity().getContent()),
response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED);
}
throw parseException(response);
}
}.wrap();
}
@Override
public void deleteUserRestriction(final String userRestrictionId) {
delete(userRestrictionId, USER_RESTRICTIONS_PATH);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/UserSkillClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.transport.TransportUtil;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.userskill.UserSkill;
import ai.toloka.client.v1.userskill.UserSkillClient;
import ai.toloka.client.v1.userskill.UserSkillSearchRequest;
import static ai.toloka.client.v1.impl.transport.MapperUtil.getObjectReader;
public class UserSkillClientImpl extends AbstractClientImpl implements UserSkillClient {
private static final String USER_SKILLS_PATH = "user-skills";
public UserSkillClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public SearchResult<UserSkill> findUsersSkills(UserSkillSearchRequest request) {
return find(request, USER_SKILLS_PATH, new TypeReference<SearchResult<UserSkill>>() {});
}
@Override
public UserSkill getUserSkill(final String userSkillId) {
return get(userSkillId, USER_SKILLS_PATH, UserSkill.class);
}
@Override
public ModificationResult<UserSkill> setUserSkill(final UserSkill userSkill) {
return setUserSkill(userSkill, null);
}
@Override
public ModificationResult<UserSkill> setUserSkill(final UserSkill userSkill, final String reason) {
Assertions.checkArgNotNull(userSkill, "User skill may not be null");
return new RequestExecutorWrapper<ModificationResult<UserSkill>>() {
@Override
ModificationResult<UserSkill> execute() throws URISyntaxException, IOException {
URI uri = addVersionPrefix(new URIBuilder(getTolokaApiUrl()), USER_SKILLS_PATH).build();
HttpResponse response = TransportUtil.executePut(getHttpClient(), uri, getHttpConsumer(),
new UserSkillUpdate(
userSkill.getId(),
userSkill.getSkillId(),
userSkill.getUserId(),
userSkill.getExactValue(),
reason
)
);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK
|| response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED) {
return new ModificationResult<>(
getObjectReader(UserSkill.class).readValue(response.getEntity().getContent()),
response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED);
}
throw parseException(response);
}
}.wrap();
}
@Override
public void deleteUserSkill(final String userSkillId) {
delete(userSkillId, USER_SKILLS_PATH);
}
private static class UserSkillUpdate {
public final String id;
public final String skill_id;
public final String user_id;
public final BigDecimal value;
public final String reason;
public UserSkillUpdate(String id, String skillId, String userId, BigDecimal exactValue, String reason) {
this.id = id;
this.skill_id = skillId;
this.user_id = userId;
this.value = exactValue;
this.reason = reason;
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/WebhookSubscriptionClientImpl.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import ai.toloka.client.v1.BatchCreateResult;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
import ai.toloka.client.v1.impl.validation.Assertions;
import ai.toloka.client.v1.webhooksubscription.WebhookPushResult;
import ai.toloka.client.v1.webhooksubscription.WebhookSubscription;
import ai.toloka.client.v1.webhooksubscription.WebhookSubscriptionClient;
import ai.toloka.client.v1.webhooksubscription.WebhookSubscriptionSearchRequest;
public class WebhookSubscriptionClientImpl extends AbstractClientImpl implements WebhookSubscriptionClient {
private static final String WEBHOOK_SUBSCRIPTIONS_PATH = "webhook-subscriptions/";
private static final String TEST_WEBHOOK_PATH = "test";
WebhookSubscriptionClientImpl(TolokaClientFactoryImpl factory) {
super(factory);
}
@Override
public ModificationResult<WebhookSubscription> upsertWebhookSubscription(WebhookSubscription webhookSubscription) {
Assertions.checkArgNotNull(webhookSubscription, "Form may not be null");
return upsert(null, webhookSubscription, WEBHOOK_SUBSCRIPTIONS_PATH, WebhookSubscription.class);
}
@Override
public BatchCreateResult<WebhookSubscription> upsertWebhookSubscriptions(List<WebhookSubscription> subscriptions) {
Assertions.checkArgNotNull(subscriptions, "Forms may not be null");
return upsertMultiple(subscriptions, WEBHOOK_SUBSCRIPTIONS_PATH,
new TypeReference<BatchCreateResult<WebhookSubscription>>() {});
}
@Override
public SearchResult<WebhookSubscription> findWebhookSubscriptions(WebhookSubscriptionSearchRequest request) {
return find(request, WEBHOOK_SUBSCRIPTIONS_PATH, new TypeReference<SearchResult<WebhookSubscription>>() {});
}
@Override
public WebhookSubscription getWebhookSubscription(String webhookSubscriptionId) {
Assertions.checkArgNotNull(webhookSubscriptionId, "Id may not be null");
return get(webhookSubscriptionId, WEBHOOK_SUBSCRIPTIONS_PATH, WebhookSubscription.class);
}
@Override
public void deleteWebhookSubscription(String webhookSubscriptionId) {
delete(webhookSubscriptionId, WEBHOOK_SUBSCRIPTIONS_PATH);
}
@Override
public ModificationResult<WebhookPushResult> sendTestWebhook(String webhookSubscriptionId) {
Assertions.checkArgNotNull(webhookSubscriptionId, "Id may not be null");
return executeSyncAction(null, WEBHOOK_SUBSCRIPTIONS_PATH, webhookSubscriptionId,
TEST_WEBHOOK_PATH, WebhookPushResult.class, null);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/transport/DefaultHttpClientConfiguration.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl.transport;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;
import org.apache.http.Header;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHeader;
import static java.util.Collections.singletonList;
public class DefaultHttpClientConfiguration {
public static final URI DEFAULT_TOLOKA_PROD_URI = URI.create("https://toloka.dev/api");
public static final URI DEFAULT_TOLOKA_SANDBOX_URI = URI.create("https://sandbox.toloka.dev/api");
public static final int DEFAULT_CONNECTION_TIMEOUT = 10 * 1000;
public static final int DEFAULT_SOCKET_TIMEOUT = 120 * 1000;
public static final int DEFAULT_MAX_CONNECTIONS = 100;
public static final String AUTHORIZATION_HEADER_NAME = "Authorization";
public static final String AUTHORIZATION_OAUTH_HEADER_FORMAT = "OAuth %s";
public static final String AUTHORIZATION_API_KEY_HEADER_FORMAT = "ApiKey %s";
public static final List<String> AUTHORIZATION_SUPPORTED_TYPES = List.of("ApiKey", "OAuth");
public static final String USER_AGENT_FORMAT = "toloka-java-sdk/%s";
public static HttpClient buildDefaultClient(String tokenOrKey) {
return HttpClientBuilder.create()
.setMaxConnTotal(DEFAULT_MAX_CONNECTIONS)
.setMaxConnPerRoute(DEFAULT_MAX_CONNECTIONS)
.setDefaultRequestConfig(getDefaultRequestConfig())
.setUserAgent(getUserAgent())
.setDefaultHeaders(singletonList(getDefaultAuthorizationHeader(tokenOrKey)))
.build();
}
public static RequestConfig getDefaultRequestConfig() {
return RequestConfig.custom()
.setConnectTimeout(DEFAULT_CONNECTION_TIMEOUT)
.setConnectionRequestTimeout(DEFAULT_CONNECTION_TIMEOUT)
.setSocketTimeout(DEFAULT_SOCKET_TIMEOUT)
.build();
}
public static Header getDefaultAuthorizationHeader(String tokenOrKey) {
return new BasicHeader(AUTHORIZATION_HEADER_NAME, recognizeAuthFormat(tokenOrKey));
}
public static String getUserAgent() {
return String.format(USER_AGENT_FORMAT, EncodeUtil.encodeNonAscii(getVersion()));
}
/**
* @param tokenOrKey different Authorization format. Check test for details.
* @return Authorization header value
*/
protected static String recognizeAuthFormat(String tokenOrKey) {
String cred = tokenOrKey.strip();
if (cred.contains(" ")) {
List<String> parsedCred = Arrays.stream(tokenOrKey.split(" "))
.map(String::strip)
.filter(part -> part.length() > 0)
.collect(Collectors.toList());
if (2 != parsedCred.size()) {
throw new IllegalArgumentException(
"Token or Api Key must contain only itself or be prefixed with its type. "
+ "Given value has next format: " + tokenOrKey.replaceAll("\\w", "X"));
}
if (!AUTHORIZATION_SUPPORTED_TYPES.contains(parsedCred.get(0))) {
throw new IllegalArgumentException("Unsupported Authorization type");
}
return String.format("%s %s", parsedCred.get(0), EncodeUtil.encodeNonAscii(parsedCred.get(1)));
}
if (isApiKey(cred)) {
return String.format(AUTHORIZATION_API_KEY_HEADER_FORMAT, EncodeUtil.encodeNonAscii(cred));
}
// fallback
return String.format(AUTHORIZATION_OAUTH_HEADER_FORMAT, EncodeUtil.encodeNonAscii(cred));
}
private static boolean isApiKey(String cred) {
long dotCount = cred.chars()
.filter(c -> '.' == c)
.count();
if (2 == dotCount) {
int dotIdx = cred.indexOf('.');
return dotIdx > 21 && dotIdx < 25;
}
return false;
}
private static String getVersion() {
String version = DefaultHttpClientConfiguration.class.getPackage().getImplementationVersion();
return null == version ? "undefined" : version;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/transport/EncodeUtil.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl.transport;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public final class EncodeUtil {
private static final List<String> TO_REPLACES = Arrays.asList(
"{",
"}",
":",
"\"",
",",
"[",
"]"
);
private static final Map<String, String> REPLACES = new HashMap<>();
static {
for (String raw : TO_REPLACES) {
try {
REPLACES.put(URLEncoder.encode(raw, "UTF8"), raw);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("really?", e);
}
}
}
private EncodeUtil() {
}
public static String encodeNonAscii(String string) {
try {
// just an URL encode, but keep some values in raw form for better looking json in headers
String s = URLEncoder.encode(string, "UTF8");
for (Map.Entry<String, String> replace : REPLACES.entrySet()) {
s = s.replaceAll(replace.getKey(), replace.getValue());
}
return s;
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("utf8 is gone - no way", e);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/transport/MapperUtil.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl.transport;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
public class MapperUtil {
private static final ObjectMapper OBJECT_MAPPER;
static {
OBJECT_MAPPER = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
.disable(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
public static DateFormat getTolokaDateFormat() {
return new TlkCustomDateFormat();
}
public static ObjectWriter getObjectWriter() {
return OBJECT_MAPPER.writer(new TlkCustomDateFormat());
}
public static ObjectReader getObjectReader() {
return formatReader(OBJECT_MAPPER.reader());
}
public static ObjectReader getObjectReader(Class<?> c) {
return formatReader(OBJECT_MAPPER.readerFor(c));
}
public static ObjectReader getObjectReader(TypeReference<?> type) {
return formatReader(OBJECT_MAPPER.readerFor(type));
}
private static ObjectReader formatReader(ObjectReader reader) {
return reader.with(OBJECT_MAPPER.getDeserializationConfig().with(new TlkCustomDateFormat()));
}
private static class TlkCustomDateFormat extends DateFormat {
private static final int DATE_FORMAT_LENGTH = 19;
private final SimpleDateFormat defaultDateFormat;
private final SimpleDateFormat dateFormatWithMillis;
private TlkCustomDateFormat() {
defaultDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
defaultDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
dateFormatWithMillis = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
dateFormatWithMillis.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String withMillisFormat = dateFormatWithMillis.format(date);
return withMillisFormat.endsWith("000")
? defaultDateFormat.format(date, toAppendTo, fieldPosition)
: dateFormatWithMillis.format(date, toAppendTo, fieldPosition);
}
@Override
public Date parse(String source, ParsePosition pos) {
return source.length() == DATE_FORMAT_LENGTH
? defaultDateFormat.parse(source, pos) : dateFormatWithMillis.parse(source, pos);
}
@Override
public Object clone() {
return new TlkCustomDateFormat();
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/transport/TransportUtil.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl.transport;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.function.Consumer;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPatch;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.entity.StringEntity;
public class TransportUtil {
public static HttpResponse executeGet(
HttpClient client,
URI uri,
Consumer<HttpRequestBase> consumer
) throws IOException {
HttpGet get = new HttpGet(uri);
applyConsumer(get, consumer);
return client.execute(get);
}
public static HttpResponse executePost(
HttpClient client,
URI uri,
Consumer<HttpRequestBase> consumer
) throws IOException {
HttpPost post = new HttpPost(uri);
post.addHeader("Content-Type", ContentType.APPLICATION_JSON.toString());
applyConsumer(post, consumer);
return client.execute(post);
}
public static HttpResponse executePost(
HttpClient client,
URI uri,
Consumer<HttpRequestBase> consumer,
Object body
) throws IOException {
HttpPost post = new HttpPost(uri);
applyConsumer(post, consumer);
post.setEntity(new StringEntity(MapperUtil.getObjectWriter().writeValueAsString(body),
ContentType.APPLICATION_JSON));
return client.execute(post);
}
public static HttpResponse executePost(HttpClient client, URI uri, Consumer<HttpRequestBase> consumer,
InputStream bodyStream) throws IOException {
HttpPost post = new HttpPost(uri);
applyConsumer(post, consumer);
post.setEntity(new InputStreamEntity(bodyStream, ContentType.APPLICATION_JSON));
return client.execute(post);
}
public static HttpResponse executePut(
HttpClient client,
URI uri,
Consumer<HttpRequestBase> consumer,
Object body
) throws IOException {
HttpPut put = new HttpPut(uri);
applyConsumer(put, consumer);
put.setEntity(new StringEntity(MapperUtil.getObjectWriter().writeValueAsString(body),
ContentType.APPLICATION_JSON));
return client.execute(put);
}
public static HttpResponse executePatch(
HttpClient client,
URI uri,
Consumer<HttpRequestBase> consumer,
Object body
) throws IOException {
HttpPatch patch = new HttpPatch(uri);
applyConsumer(patch, consumer);
patch.setEntity(new StringEntity(MapperUtil.getObjectWriter().writeValueAsString(body),
ContentType.APPLICATION_JSON));
return client.execute(patch);
}
public static HttpResponse executeDelete(
HttpClient client,
URI uri,
Consumer<HttpRequestBase> consumer
) throws IOException {
HttpDelete delete = new HttpDelete(uri);
applyConsumer(delete, consumer);
return client.execute(delete);
}
private static void applyConsumer(HttpRequestBase httpRequest, Consumer<HttpRequestBase> httpConsumer) {
if (httpConsumer != null) {
httpConsumer.accept(httpRequest);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/impl/validation/Assertions.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.impl.validation;
public class Assertions {
public static void checkArgNotNull(Object arg, String message) {
if (arg == null) {
throw new IllegalArgumentException(message);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/ComposeDetails.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import ai.toloka.client.v1.pool.filter.Condition;
import ai.toloka.client.v1.pool.filter.Connective;
public class ComposeDetails {
@JsonProperty("recipients_select_type")
private RecipientsSelectType recipientsSelectType;
@JsonProperty("recipients_ids")
private List<String> recipientsIds;
@JsonProperty("recipients_filter")
@JsonDeserialize(using = Condition.ConditionDeserializer.class)
private Connective recipientsFilter;
public RecipientsSelectType getRecipientsSelectType() {
return recipientsSelectType;
}
public List<String> getRecipientsIds() {
return recipientsIds;
}
public Connective getRecipientsFilter() {
return recipientsFilter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/Folder.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public final class Folder extends FlexibleEnum<Folder> {
private Folder(String name) {
super(name);
}
public static final Folder INBOX = new Folder("INBOX");
public static final Folder OUTBOX = new Folder("OUTBOX");
public static final Folder AUTOMATIC_NOTIFICATION = new Folder("AUTOMATIC_NOTIFICATION");
public static final Folder IMPORTANT = new Folder("IMPORTANT");
public static final Folder UNREAD = new Folder("UNREAD");
private static final Folder[] VALUES = {INBOX, OUTBOX, AUTOMATIC_NOTIFICATION, IMPORTANT, UNREAD};
private static final ConcurrentMap<String, Folder> DISCOVERED_VALUES = new ConcurrentHashMap<>();
public static Folder[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), Folder.class);
}
@JsonCreator
public static Folder valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<Folder>() {
@Override public Folder create(String name) {
return new Folder(name);
}
});
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/Interlocutor.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
public class Interlocutor {
private String id;
private InterlocutorRole role;
private Boolean myself;
public String getId() {
return id;
}
public InterlocutorRole getRole() {
return role;
}
public boolean isMyself() {
return myself != null ? myself : false;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/InterlocutorRole.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.concurrent.ConcurrentHashMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public class InterlocutorRole extends FlexibleEnum<InterlocutorRole> {
public static InterlocutorRole USER = new InterlocutorRole("USER");
public static InterlocutorRole REQUESTER = new InterlocutorRole("REQUESTER");
public static InterlocutorRole ADMINISTRATOR = new InterlocutorRole("ADMINISTRATOR");
public static InterlocutorRole SYSTEM = new InterlocutorRole("SYSTEM");
private static final InterlocutorRole[] VALUES = {USER, REQUESTER, ADMINISTRATOR, SYSTEM};
private static final ConcurrentHashMap<String, InterlocutorRole> DISCOVERED_VALUES = new ConcurrentHashMap<>();
public static InterlocutorRole[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), InterlocutorRole.class);
}
@JsonCreator
public static InterlocutorRole valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<InterlocutorRole>() {
@Override public InterlocutorRole create(String name) {
return new InterlocutorRole(name);
}
});
}
private InterlocutorRole(String name) {
super(name);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/Message.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.Date;
import java.util.Map;
import ai.toloka.client.v1.LangIso639;
public class Message {
private Map<LangIso639, String> text;
private Interlocutor from;
private Date created;
public Map<LangIso639, String> getText() {
return text;
}
public Interlocutor getFrom() {
return from;
}
public Date getCreated() {
return created;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThread.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonProperty;
import ai.toloka.client.v1.LangIso639;
public class MessageThread {
private String id;
private Map<LangIso639, String> topic;
@JsonProperty("interlocutors_inlined")
private boolean interlocutorsInlined;
private List<Interlocutor> interlocutors;
@JsonProperty("messages_inlined")
private boolean messagesInlined;
private List<Message> messages;
@JsonProperty("compose_details")
private ComposeDetails composeDetails;
private Meta meta;
private Boolean answerable;
private Date created;
private Set<Folder> folders;
public String getId() {
return id;
}
public Map<LangIso639, String> getTopic() {
return topic;
}
public boolean isInterlocutorsInlined() {
return interlocutorsInlined;
}
public List<Interlocutor> getInterlocutors() {
return interlocutors;
}
public boolean isMessagesInlined() {
return messagesInlined;
}
public List<Message> getMessages() {
return messages;
}
public ComposeDetails getComposeDetails() {
return composeDetails;
}
public Boolean getAnswerable() {
return answerable;
}
public Date getCreated() {
return created;
}
public Set<Folder> getFolders() {
return folders;
}
public Meta getMeta() {
return meta;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThreadClient.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
public interface MessageThreadClient {
SearchResult<MessageThread> findMessageThreads(MessageThreadSearchRequest request);
ModificationResult<MessageThread> composeMessageThread(MessageThreadCompose compose);
ModificationResult<MessageThread> replyMessageThread(String messageThreadId, MessageThreadReply reply);
ModificationResult<MessageThread> addToFolders(String messageThreadId, MessageThreadFolders folders);
ModificationResult<MessageThread> removeFromFolders(String messageThreadId, MessageThreadFolders folders);
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThreadCompose.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import ai.toloka.client.v1.LangIso639;
import ai.toloka.client.v1.pool.filter.Condition;
import ai.toloka.client.v1.pool.filter.Connective;
public class MessageThreadCompose {
private Map<LangIso639, String> topic;
private Boolean answerable;
private Map<LangIso639, String> text;
@JsonProperty("recipients_select_type")
private RecipientsSelectType recipientsSelectType;
@JsonProperty("recipients_ids")
private List<String> recipientsIds;
@JsonProperty("recipients_filter")
@JsonDeserialize(using = Condition.ConditionDeserializer.class)
private Connective recipientsFilter;
public MessageThreadCompose(Map<LangIso639, String> topic, Map<LangIso639, String> text) {
this.topic = topic;
this.text = text;
this.recipientsSelectType = RecipientsSelectType.ALL;
}
public MessageThreadCompose(Map<LangIso639, String> topic, Map<LangIso639, String> text,
List<String> recipientsIds) {
this.topic = topic;
this.text = text;
this.recipientsSelectType = RecipientsSelectType.DIRECT;
this.recipientsIds = recipientsIds;
}
public MessageThreadCompose(Map<LangIso639, String> topic, Map<LangIso639, String> text,
Connective recipientsFilter) {
this.topic = topic;
this.text = text;
this.recipientsSelectType = RecipientsSelectType.FILTER;
this.recipientsFilter = recipientsFilter;
}
public MessageThreadCompose(Map<LangIso639, String> topic, Map<LangIso639, String> text, boolean answerable) {
this.topic = topic;
this.text = text;
this.recipientsSelectType = RecipientsSelectType.ALL;
this.answerable = answerable;
}
public MessageThreadCompose(Map<LangIso639, String> topic, Map<LangIso639, String> text,
List<String> recipientsIds, boolean answerable) {
this.topic = topic;
this.text = text;
this.recipientsSelectType = RecipientsSelectType.DIRECT;
this.recipientsIds = recipientsIds;
this.answerable = answerable;
}
public MessageThreadCompose(Map<LangIso639, String> topic, Map<LangIso639, String> text,
Connective recipientsFilter, boolean answerable) {
this.topic = topic;
this.text = text;
this.recipientsSelectType = RecipientsSelectType.FILTER;
this.recipientsFilter = recipientsFilter;
this.answerable = answerable;
}
public Map<LangIso639, String> getTopic() {
return topic;
}
public Boolean getAnswerable() {
return answerable;
}
public Map<LangIso639, String> getText() {
return text;
}
public RecipientsSelectType getRecipientsSelectType() {
return recipientsSelectType;
}
public List<String> getRecipientsIds() {
return recipientsIds;
}
public Connective getRecipientsFilter() {
return recipientsFilter;
}
public void setAnswerable(Boolean answerable) {
this.answerable = answerable;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThreadFilterParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import ai.toloka.client.v1.FilterParam;
public enum MessageThreadFilterParam implements FilterParam {
folder(MessageThreadSearchRequest.FOLDER_PARAMETER),
folder_ne(MessageThreadSearchRequest.FOLDER_NE_PARAMETER);
private String parameter;
MessageThreadFilterParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThreadFolders.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.Set;
public class MessageThreadFolders {
private Set<Folder> folders;
public MessageThreadFolders(Set<Folder> folders) {
this.folders = folders;
}
public Set<Folder> getFolders() {
return folders;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThreadRangeParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import ai.toloka.client.v1.RangeParam;
public enum MessageThreadRangeParam implements RangeParam {
id(MessageThreadSearchRequest.ID_PARAMETER),
created(MessageThreadSearchRequest.CREATED_PARAMETER);
private String parameter;
MessageThreadRangeParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThreadReply.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.Map;
import ai.toloka.client.v1.LangIso639;
public class MessageThreadReply {
private Map<LangIso639, String> text;
public MessageThreadReply(Map<LangIso639, String> text) {
this.text = text;
}
public Map<LangIso639, String> getText() {
return text;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThreadSearchRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.Date;
import java.util.Map;
import ai.toloka.client.v1.SearchRequest;
public class MessageThreadSearchRequest extends SearchRequest {
static final String FOLDER_PARAMETER = "folder";
static final String FOLDER_NE_PARAMETER = "folder_ne";
static final String ID_PARAMETER = "id";
static final String CREATED_PARAMETER = "created";
public MessageThreadSearchRequest(Map<String, Object> filterParameters, Map<String, Object> rangeParameters,
String sortParameter, Integer limit) {
super(filterParameters, rangeParameters, sortParameter, limit);
}
public static MessageThreadBuilder make() {
return new MessageThreadBuilder(
new MessageThreadFilterBuilder(), new MessageThreadRangeBuilder(), new MessageThreadSortBuilder());
}
public static class MessageThreadBuilder extends Builder
<MessageThreadSearchRequest, MessageThreadBuilder, MessageThreadFilterBuilder, MessageThreadRangeBuilder,
MessageThreadSortBuilder> {
public MessageThreadBuilder(MessageThreadFilterBuilder filterBuilder, MessageThreadRangeBuilder rangeBuilder,
MessageThreadSortBuilder sortBuilder) {
super(filterBuilder, rangeBuilder, sortBuilder);
}
@Override public MessageThreadSearchRequest done() {
return new MessageThreadSearchRequest(filterBuilder.getFilterParameters(),
rangeBuilder.getRangeParameters(), sortBuilder.getSortParameter(), getLimit());
}
}
public static class MessageThreadFilterBuilder
extends FilterBuilder<MessageThreadFilterBuilder, MessageThreadBuilder, MessageThreadFilterParam> {
public MessageThreadFilterBuilder byFolder(Folder folder) {
return by(MessageThreadFilterParam.folder, folder);
}
public MessageThreadFilterBuilder byFolderNe(Folder folder) {
return by(MessageThreadFilterParam.folder_ne, folder);
}
}
public static class MessageThreadRangeBuilder
extends RangeBuilder<MessageThreadRangeBuilder, MessageThreadBuilder, MessageThreadRangeParam> {
public RangeItemBuilder<MessageThreadRangeBuilder> byId(String id) {
return by(MessageThreadRangeParam.id, id);
}
public RangeItemBuilder<MessageThreadRangeBuilder> byCreated(Date created) {
return by(MessageThreadRangeParam.created, created);
}
}
public static class MessageThreadSortBuilder
extends SortBuilder<MessageThreadSortBuilder, MessageThreadBuilder, MessageThreadSortParam> {
public SortItem<MessageThreadSortBuilder> byId() {
return by(MessageThreadSortParam.id);
}
public SortItem<MessageThreadSortBuilder> byCreated() {
return by(MessageThreadSortParam.created);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/MessageThreadSortParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import ai.toloka.client.v1.SortParam;
public enum MessageThreadSortParam implements SortParam {
id(MessageThreadSearchRequest.ID_PARAMETER),
created(MessageThreadSearchRequest.CREATED_PARAMETER);
private String parameter;
MessageThreadSortParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/Meta.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Meta {
@JsonProperty("pool_id")
private String poolId;
@JsonProperty("project_id")
private String projectId;
@JsonProperty("assignment_id")
private String assignmentId;
public String getPoolId() {
return poolId;
}
public String getProjectId() {
return projectId;
}
public String getAssignmentId() {
return assignmentId;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/messagethread/RecipientsSelectType.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.messagethread;
import java.util.concurrent.ConcurrentHashMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public final class RecipientsSelectType extends FlexibleEnum<RecipientsSelectType> {
public static RecipientsSelectType DIRECT = new RecipientsSelectType("DIRECT");
public static RecipientsSelectType FILTER = new RecipientsSelectType("FILTER");
public static RecipientsSelectType ALL = new RecipientsSelectType("ALL");
private static final RecipientsSelectType[] VALUES = {DIRECT, FILTER, ALL};
private static final ConcurrentHashMap<String, RecipientsSelectType> DISCOVERED_VALUES = new ConcurrentHashMap<>();
public static RecipientsSelectType[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), RecipientsSelectType.class);
}
@JsonCreator
public static RecipientsSelectType valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<RecipientsSelectType>() {
@Override public RecipientsSelectType create(String name) {
return new RecipientsSelectType(name);
}
});
}
private RecipientsSelectType(String name) {
super(name);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/metadata/UserMetadata.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.metadata;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class UserMetadata {
private String id;
private String country;
private List<String> languages;
private UserMetadataAttributes attributes;
@JsonProperty("adult_allowed")
private Boolean adultAllowed;
@JsonCreator
public UserMetadata(@JsonProperty("country") String country,
@JsonProperty("languages") List<String> languages,
@JsonProperty("attributes") UserMetadataAttributes attributes,
@JsonProperty("adult_allowed") Boolean adultAllowed) {
this.country = country;
this.languages = languages;
this.attributes = attributes;
this.adultAllowed = adultAllowed;
}
public String getId() {
return id;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public List<String> getLanguages() {
return languages;
}
public void setLanguages(List<String> languages) {
this.languages = languages;
}
public Boolean getAdultAllowed() {
return adultAllowed;
}
public void setAdultAllowed(Boolean adultAllowed) {
this.adultAllowed = adultAllowed;
}
public UserMetadataAttributes getAttributes() {
return attributes;
}
public void setAttributes(UserMetadataAttributes attributes) {
this.attributes = attributes;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/metadata/UserMetadataAttributes.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.metadata;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class UserMetadataAttributes {
@JsonProperty("country_by_phone")
private String countryByPhone;
@JsonProperty("country_by_ip")
private String countryByIp;
@JsonProperty("client_type")
private String clientType;
@JsonProperty("user_agent_type")
private String userAgentType;
@JsonProperty("device_category")
private String deviceCategory;
@JsonProperty("os_family")
private String osFamily;
@JsonProperty("os_version")
private Double osVersion;
@JsonProperty("os_version_major")
private Long osVersionMajor;
@JsonProperty("os_version_minor")
private Long osVersionMinor;
@JsonProperty("os_version_bugfix")
private Long osVersionBugfix;
@JsonCreator
public UserMetadataAttributes(@JsonProperty("country_by_phone") String countryByPhone,
@JsonProperty("country_by_ip") String countryByIp,
@JsonProperty("client_type") String clientType,
@JsonProperty("user_agent_type") String userAgentType,
@JsonProperty("device_category") String deviceCategory,
@JsonProperty("os_family") String osFamily,
@JsonProperty("os_version") Double osVersion,
@JsonProperty("os_version_major") Long osVersionMajor,
@JsonProperty("os_version_minor") Long osVersionMinor,
@JsonProperty("os_version_bugfix") Long osVersionBugfix) {
this.countryByPhone = countryByPhone;
this.countryByIp = countryByIp;
this.clientType = clientType;
this.userAgentType = userAgentType;
this.deviceCategory = deviceCategory;
this.osFamily = osFamily;
this.osVersion = osVersion;
this.osVersionMajor = osVersionMajor;
this.osVersionMinor = osVersionMinor;
this.osVersionBugfix = osVersionBugfix;
}
public String getCountryByPhone() {
return countryByPhone;
}
public void setCountryByPhone(String countryByPhone) {
this.countryByPhone = countryByPhone;
}
public String getUserAgentType() {
return userAgentType;
}
public void setUserAgentType(String userAgentType) {
this.userAgentType = userAgentType;
}
public Long getOsVersionMinor() {
return osVersionMinor;
}
public void setOsVersionMinor(Long osVersionMinor) {
this.osVersionMinor = osVersionMinor;
}
public String getClientType() {
return clientType;
}
public void setClientType(String clientType) {
this.clientType = clientType;
}
public Double getOsVersion() {
return osVersion;
}
public void setOsVersion(Double osVersion) {
this.osVersion = osVersion;
}
public String getOsFamily() {
return osFamily;
}
public void setOsFamily(String osFamily) {
this.osFamily = osFamily;
}
public String getDeviceCategory() {
return deviceCategory;
}
public void setDeviceCategory(String deviceCategory) {
this.deviceCategory = deviceCategory;
}
public Long getOsVersionMajor() {
return osVersionMajor;
}
public void setOsVersionMajor(Long osVersionMajor) {
this.osVersionMajor = osVersionMajor;
}
public Long getOsVersionBugfix() {
return osVersionBugfix;
}
public void setOsVersionBugfix(Long osVersionBugfix) {
this.osVersionBugfix = osVersionBugfix;
}
public String getCountryByIp() {
return countryByIp;
}
public void setCountryByIp(String countryByIp) {
this.countryByIp = countryByIp;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/metadata/UserMetadataClient.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.metadata;
public interface UserMetadataClient {
UserMetadata getUserMetadata(String userId);
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/Operation.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.JsonNode;
import ai.toloka.client.v1.aggregatedsolutions.AggregatedSolutionOperation;
import ai.toloka.client.v1.impl.transport.MapperUtil;
import ai.toloka.client.v1.pool.PoolArchiveOperation;
import ai.toloka.client.v1.pool.PoolCloneOperation;
import ai.toloka.client.v1.pool.PoolCloseOperation;
import ai.toloka.client.v1.pool.PoolOpenOperation;
import ai.toloka.client.v1.project.ProjectArchiveOperation;
import ai.toloka.client.v1.task.KnownSolutionsGenerateOperation;
import ai.toloka.client.v1.task.TaskCreateBatchOperation;
import ai.toloka.client.v1.tasksuite.TaskSuiteCreateBatchOperation;
import ai.toloka.client.v1.training.TrainingArchiveOperation;
import ai.toloka.client.v1.training.TrainingCloneOperation;
import ai.toloka.client.v1.training.TrainingCloseOperation;
import ai.toloka.client.v1.training.TrainingOpenOperation;
import ai.toloka.client.v1.userbonus.UserBonusCreateBatchOperation;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type",
visible = true, defaultImpl = Operation.UnknownOperation.class)
@JsonSubTypes({
@JsonSubTypes.Type(value = ProjectArchiveOperation.class, name = "PROJECT.ARCHIVE"),
@JsonSubTypes.Type(value = PoolOpenOperation.class, name = "POOL.OPEN"),
@JsonSubTypes.Type(value = PoolCloseOperation.class, name = "POOL.CLOSE"),
@JsonSubTypes.Type(value = PoolArchiveOperation.class, name = "POOL.ARCHIVE"),
@JsonSubTypes.Type(value = PoolCloneOperation.class, name = "POOL.CLONE"),
@JsonSubTypes.Type(value = TrainingOpenOperation.class, name = "TRAINING.OPEN"),
@JsonSubTypes.Type(value = TrainingCloseOperation.class, name = "TRAINING.CLOSE"),
@JsonSubTypes.Type(value = TrainingArchiveOperation.class, name = "TRAINING.ARCHIVE"),
@JsonSubTypes.Type(value = TrainingCloneOperation.class, name = "TRAINING.CLONE"),
@JsonSubTypes.Type(value = TaskCreateBatchOperation.class, name = "TASK.BATCH_CREATE"),
@JsonSubTypes.Type(value = TaskSuiteCreateBatchOperation.class, name = "TASK_SUITE.BATCH_CREATE"),
@JsonSubTypes.Type(value = UserBonusCreateBatchOperation.class, name = "USER_BONUS.BATCH_CREATE"),
@JsonSubTypes.Type(value = AggregatedSolutionOperation.class, name = "SOLUTION.AGGREGATE"),
@JsonSubTypes.Type(value = KnownSolutionsGenerateOperation.class, name = "KNOWN_SOLUTIONS.GENERATE")
})
public abstract class Operation<P, T extends Operation<P, T>> {
public static final String PSEUDO_OPERATION_ID = "PSEUDO_ID";
public static final OperationType DEFAULT_PSEUDO_OPERATION_TYPE = OperationType.PSEUDO;
protected String id;
protected OperationType type;
protected OperationStatus status;
protected Date submitted;
protected Date started;
protected Date finished;
protected Integer progress;
protected P parameters;
@JsonProperty
protected JsonNode details;
@JsonIgnore
private Map<String, Object> detailsMap;
@JsonIgnore
protected OperationClient operationClient;
public Operation() {}
/**
* Constructor for manual creation of pseudo operations.
*/
protected Operation(Date currentDateTime) {
this.id = PSEUDO_OPERATION_ID;
this.type = OperationType.PSEUDO;
this.status = OperationStatus.SUCCESS;
this.submitted = currentDateTime;
this.started = currentDateTime;
this.finished = currentDateTime;
this.progress = 100;
}
public String getId() {
return id;
}
public OperationType getType() {
return type;
}
public OperationStatus getStatus() {
return status;
}
public Date getSubmitted() {
return submitted;
}
public Date getStarted() {
return started;
}
public Date getFinished() {
return finished;
}
public Integer getProgress() {
return progress;
}
public P getParameters() {
return parameters;
}
public Map<String, Object> getDetailsAsMap() {
if (details == null) {
return Collections.emptyMap();
}
if (detailsMap == null) {
try {
this.detailsMap = MapperUtil.getObjectReader(Map.class).readValue(details);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return detailsMap;
}
public boolean isCompleted() {
return getStatus().isTerminal();
}
public boolean isSuccess() {
return getStatus() == OperationStatus.SUCCESS;
}
@SuppressWarnings("unchecked")
public T refresh() {
if (isPseudo()) {
return (T) this;
} else {
return operationClient.getOperation(id);
}
}
@SuppressWarnings("unchecked")
public T waitToComplete() throws InterruptedException {
if (isPseudo()) {
return (T) this;
} else {
return OperationUtil.waitToComplete((T) this, operationClient);
}
}
@SuppressWarnings("unchecked")
public T waitToCompleteUninterrupted() {
if (isPseudo()) {
return (T) this;
} else {
return OperationUtil.waitToCompleteUninterrupted((T) this, operationClient);
}
}
@SuppressWarnings("unchecked")
public T waitAndGetSuccessful() throws InterruptedException {
if (isPseudo()) {
return (T) this;
} else {
return OperationUtil.waitAndGetSuccessful((T) this, operationClient);
}
}
@SuppressWarnings("unchecked")
public T waitAndGetSuccessfulUninterrupted() {
if (isPseudo()) {
return (T) this;
} else {
return OperationUtil.waitAndGetSuccessfulUninterrupted((T) this, operationClient);
}
}
public boolean isPseudo() {
return getId().equals(PSEUDO_OPERATION_ID);
}
public static void setOperationClient(Operation<?, ?> operation, OperationClient operationClient) {
operation.operationClient = operationClient;
}
public static Operation createPseudo(Date currentDateTime) {
return new Operation(currentDateTime) {};
}
public static class UnknownOperation extends Operation {}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationClient.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import java.util.Iterator;
import ai.toloka.client.v1.SearchResult;
public interface OperationClient {
SearchResult<Operation<?, ?>> findOperations(OperationSearchRequest request);
<T extends Operation<?, ?>> T getOperation(String operationId);
<T extends Operation<?, ?>> T getOperation(String operationId, Class<T> c);
Iterator<OperationLogItem> getOperationLog(String operationId);
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationFailedException.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import java.util.Map;
public class OperationFailedException extends RuntimeException {
private Map<String, Object> details;
public OperationFailedException(Map<String, Object> details) {
this.details = details;
}
public Map<String, Object> getDetails() {
return details;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationFilterParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import ai.toloka.client.v1.FilterParam;
public enum OperationFilterParam implements FilterParam {
type(OperationSearchRequest.TYPE_PARAMETER),
status(OperationSearchRequest.STATUS_PARAMETER);
private String parameter;
OperationFilterParam(String parameter) {
this.parameter = parameter;
}
@Override public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationLogItem.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import java.io.IOException;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.node.ObjectNode;
import ai.toloka.client.v1.impl.transport.MapperUtil;
public class OperationLogItem {
private String type;
private Boolean success;
@JsonProperty
private ObjectNode input;
@JsonIgnore
private Map<String, Object> inputMap;
@JsonProperty
private ObjectNode output;
@JsonIgnore
private Map<String, Object> outputMap;
public String getType() {
return type;
}
public Boolean getSuccess() {
return success;
}
public Map<String, Object> getInputAsMap() {
if (inputMap == null) {
try {
inputMap = MapperUtil.getObjectReader(Map.class).readValue(this.input);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return inputMap;
}
public Map<String, Object> getOutputAsMap() {
if (outputMap == null) {
try {
outputMap = MapperUtil.getObjectReader(Map.class).readValue(this.output);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return outputMap;
}
@Override public String toString() {
return "OperationLogItem{"
+ "type='" + type + '\''
+ ", success=" + success
+ ", input=" + getInputAsMap()
+ ", output=" + getOutputAsMap()
+ '}';
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationRangeParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import ai.toloka.client.v1.RangeParam;
public enum OperationRangeParam implements RangeParam {
id(OperationSearchRequest.ID_PARAMETER),
submitted(OperationSearchRequest.SUBMITTED_PARAMETER),
finished(OperationSearchRequest.FINISHED_PARAMETER);
private String parameter;
OperationRangeParam(String parameter) {
this.parameter = parameter;
}
@Override public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationSearchRequest.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import java.util.Date;
import java.util.Map;
import ai.toloka.client.v1.SearchRequest;
public class OperationSearchRequest extends SearchRequest {
public static final String TYPE_PARAMETER = "type";
public static final String STATUS_PARAMETER = "status";
public static final String ID_PARAMETER = "id";
public static final String SUBMITTED_PARAMETER = "submitted";
public static final String FINISHED_PARAMETER = "finished";
private OperationSearchRequest(Map<String, Object> filterParameters, Map<String, Object> rangeParameters,
String sortParameter, Integer limit) {
super(filterParameters, rangeParameters, sortParameter, limit);
}
public static OperationBuilder make() {
return new OperationBuilder(
new OperationFilterBuilder(), new OperationRangeBuilder(), new OperationSortBuilder());
}
public static class OperationBuilder extends Builder<
OperationSearchRequest,
OperationBuilder,
OperationFilterBuilder,
OperationRangeBuilder,
OperationSortBuilder> {
private OperationBuilder(OperationFilterBuilder filterBuilder, OperationRangeBuilder rangeBuilder,
OperationSortBuilder sortBuilder) {
super(filterBuilder, rangeBuilder, sortBuilder);
}
@Override public OperationSearchRequest done() {
return new OperationSearchRequest(filterBuilder.getFilterParameters(), rangeBuilder.getRangeParameters(),
sortBuilder.getSortParameter(), getLimit());
}
}
public static class OperationFilterBuilder
extends FilterBuilder<OperationFilterBuilder, OperationBuilder, OperationFilterParam> {
public OperationFilterBuilder byType(OperationType type) {
return by(OperationFilterParam.type, type);
}
public OperationFilterBuilder byStatus(OperationStatus status) {
return by(OperationFilterParam.status, status);
}
}
public static class OperationRangeBuilder
extends RangeBuilder<OperationRangeBuilder, OperationBuilder, OperationRangeParam> {
public RangeItemBuilder<OperationRangeBuilder> byId(String id) {
return by(OperationRangeParam.id, id);
}
public RangeItemBuilder<OperationRangeBuilder> bySubmitted(Date submitted) {
return by(OperationRangeParam.submitted, submitted);
}
public RangeItemBuilder<OperationRangeBuilder> byFinished(Date finished) {
return by(OperationRangeParam.finished, finished);
}
}
public static class OperationSortBuilder
extends SortBuilder<OperationSortBuilder, OperationBuilder, OperationSortParam> {
public SortItem<OperationSortBuilder> byId() {
return by(OperationSortParam.id);
}
public SortItem<OperationSortBuilder> bySubmitted() {
return by(OperationSortParam.submitted);
}
public SortItem<OperationSortBuilder> byFinished() {
return by(OperationSortParam.finished);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationSortParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import ai.toloka.client.v1.SortParam;
public enum OperationSortParam implements SortParam {
id(OperationSearchRequest.ID_PARAMETER),
submitted(OperationSearchRequest.SUBMITTED_PARAMETER),
finished(OperationSearchRequest.FINISHED_PARAMETER);
private String parameter;
OperationSortParam(String parameter) {
this.parameter = parameter;
}
@Override public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationStatus.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public final class OperationStatus extends FlexibleEnum<OperationStatus> {
private final boolean terminal;
private OperationStatus(String name, boolean terminal) {
super(name);
this.terminal = terminal;
}
public static final OperationStatus PENDING = new OperationStatus("PENDING", false);
public static final OperationStatus RUNNING = new OperationStatus("RUNNING", false);
public static final OperationStatus SUCCESS = new OperationStatus("SUCCESS", true);
public static final OperationStatus FAIL = new OperationStatus("FAIL", true);
public boolean isTerminal() {
return terminal;
}
private static final OperationStatus[] VALUES = {PENDING, RUNNING, SUCCESS, FAIL};
private static final ConcurrentMap<String, OperationStatus> DISCOVERED_VALUES = new ConcurrentHashMap<>();
public static OperationStatus[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), OperationStatus.class);
}
@JsonCreator
public static OperationStatus valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<OperationStatus>() {
@Override public OperationStatus create(String name) {
return new OperationStatus(name, false);
}
});
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationTimeoutException.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
public class OperationTimeoutException extends RuntimeException {}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationType.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public class OperationType extends FlexibleEnum<OperationType> {
public static final OperationType PSEUDO = new OperationType("PSEUDO.PSEUDO");
public static final OperationType PROJECT_ARCHIVE = new OperationType("PROJECT.ARCHIVE");
public static final OperationType POOL_OPEN = new OperationType("POOL.OPEN");
public static final OperationType POOL_CLOSE = new OperationType("POOL.CLOSE");
public static final OperationType POOL_ARCHIVE = new OperationType("POOL.ARCHIVE");
public static final OperationType POOL_CLONE = new OperationType("POOL.CLONE");
public static final OperationType TRAINING_OPEN = new OperationType("TRAINING.OPEN");
public static final OperationType TRAINING_CLOSE = new OperationType("TRAINING.CLOSE");
public static final OperationType TRAINING_ARCHIVE = new OperationType("TRAINING.ARCHIVE");
public static final OperationType TRAINING_CLONE = new OperationType("TRAINING.CLONE");
public static final OperationType TASK_BATCH_CREATE = new OperationType("TASK.BATCH_CREATE");
public static final OperationType TASK_SUITE_BATCH_CREATE = new OperationType("TASK_SUITE.BATCH_CREATE");
public static final OperationType USER_BONUS_BATCH_CREATE = new OperationType("USER_BONUS.BATCH_CREATE");
public static final OperationType ANALYTICS = new OperationType("ANALYTICS");
public static final OperationType SOLUTION_AGGREGATE = new OperationType("SOLUTION.AGGREGATE");
public static final OperationType KNOWN_SOLUTIONS_GENERATE = new OperationType("KNOWN_SOLUTIONS.GENERATE");
private static final OperationType[] VALUES = {
PROJECT_ARCHIVE,
POOL_OPEN, POOL_CLOSE, POOL_ARCHIVE, POOL_CLONE,
TRAINING_OPEN, TRAINING_CLOSE, TRAINING_ARCHIVE, TRAINING_CLONE,
TASK_BATCH_CREATE,
TASK_SUITE_BATCH_CREATE,
USER_BONUS_BATCH_CREATE,
ANALYTICS,
SOLUTION_AGGREGATE,
KNOWN_SOLUTIONS_GENERATE,
PSEUDO
};
private static final ConcurrentMap<String, OperationType> DISCOVERED_VALUES = new ConcurrentHashMap<>();
public static OperationType[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), OperationType.class);
}
@JsonCreator
public static OperationType valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<OperationType>() {
@Override public OperationType create(String name) {
return new OperationType(name);
}
});
}
private OperationType(String name) {
super(name);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/operation/OperationUtil.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.operation;
class OperationUtil {
public static final int DEFAULT_TIME_TO_WAIT_MILLIS = 1000;
public static final int DEFAULT_TIMEOUT_MILLIS = 10 * 60 * 1000;
public static final int DEFAULT_INITIAL_DELAY_MILLIS = 500;
@SuppressWarnings("unchecked")
static <P, T extends Operation<P, T>> T waitToComplete(T operation, OperationClient client)
throws InterruptedException {
if (operation == null || operation.getStatus().isTerminal()) {
return operation;
}
long now = System.currentTimeMillis();
long timeoutMillis = now + DEFAULT_TIMEOUT_MILLIS;
if (operation.getStarted() == null || now - operation.getStarted().getTime() < DEFAULT_INITIAL_DELAY_MILLIS) {
// if this method called immediately after watcher was created then it's better to wait a little before
// first check
Thread.sleep(DEFAULT_INITIAL_DELAY_MILLIS);
}
while (true) {
Operation<?, ?> newOperation = client.getOperation(operation.getId());
if (newOperation.isCompleted()) {
return (T) newOperation;
}
Thread.sleep(DEFAULT_TIME_TO_WAIT_MILLIS);
if (System.currentTimeMillis() > timeoutMillis) {
throw new OperationTimeoutException();
}
}
}
static <P, T extends Operation<P, T>> T waitToCompleteUninterrupted(T operation, OperationClient client) {
try {
return waitToComplete(operation, client);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
static <P, T extends Operation<P, T>> T waitAndGetSuccessful(T operation, OperationClient client)
throws InterruptedException {
T completed = waitToComplete(operation, client);
if (!completed.isSuccess()) {
throw new OperationFailedException(completed.getDetailsAsMap());
}
return completed;
}
static <P, T extends Operation<P, T>> T waitAndGetSuccessfulUninterrupted(T operation, OperationClient client) {
try {
return waitAndGetSuccessful(operation, client);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/AbstractSpeedQualityBalance.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY, visible = true, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = TopPercentageSpeedQualityBalance.class, name =
"TOP_PERCENTAGE_BY_QUALITY"),
@JsonSubTypes.Type(value = BestConcurrentSpeedQualityBalance.class, name =
"BEST_CONCURRENT_USERS_BY_QUALITY")
})
public abstract class AbstractSpeedQualityBalance {
protected Type type;
public AbstractSpeedQualityBalance(Type type) {
this.type = type;
}
public Type getType() {
return type;
}
public enum Type {
TOP_PERCENTAGE_BY_QUALITY,
BEST_CONCURRENT_USERS_BY_QUALITY
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AbstractSpeedQualityBalance that = (AbstractSpeedQualityBalance) o;
return type == that.type;
}
@Override
public int hashCode() {
return type.hashCode();
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/AssignmentsIssuingConfig.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class AssignmentsIssuingConfig {
@JsonProperty("issue_task_suites_in_creation_order")
private Boolean issueTaskSuitesInCreationOrder;
@JsonCreator
public AssignmentsIssuingConfig() {
}
public AssignmentsIssuingConfig(Boolean issueTaskSuitesInCreationOrder) {
this.issueTaskSuitesInCreationOrder = issueTaskSuitesInCreationOrder;
}
public void setIssueTaskSuitesInCreationOrder(Boolean issueTaskSuitesInCreationOrder) {
this.issueTaskSuitesInCreationOrder = issueTaskSuitesInCreationOrder;
}
public Boolean getIssueTaskSuitesInCreationOrder() {
return issueTaskSuitesInCreationOrder;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/BestConcurrentSpeedQualityBalance.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
public class BestConcurrentSpeedQualityBalance extends AbstractSpeedQualityBalance {
@JsonProperty("count")
private Long count;
public BestConcurrentSpeedQualityBalance(@JsonProperty("count") Long count) {
super(Type.BEST_CONCURRENT_USERS_BY_QUALITY);
this.count = count;
}
public Long getCount() {
return count;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
BestConcurrentSpeedQualityBalance that = (BestConcurrentSpeedQualityBalance) o;
return Objects.equals(count, that.count);
}
@Override
public int hashCode() {
return count.hashCode();
}
@Override
public String toString() {
return "BestConcurrentUsersCherryPickingConfig{"
+ "type=" + type
+ ", count=" + count
+ '}';
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/DynamicPricingConfig.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import ai.toloka.client.v1.FlexibleEnum;
public class DynamicPricingConfig {
private Type type;
@JsonProperty("skill_id")
private String skillId;
private List<Interval> intervals;
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public String getSkillId() {
return skillId;
}
public void setSkillId(String skillId) {
this.skillId = skillId;
}
public List<Interval> getIntervals() {
return intervals;
}
public void setIntervals(List<Interval> intervals) {
this.intervals = intervals;
}
public static class Type extends FlexibleEnum<Type> {
public static final Type SKILL = new Type("SKILL");
private static final Type[] VALUES = {SKILL};
private static final ConcurrentMap<String, Type> DISCOVERED_VALUES = new ConcurrentHashMap<>();
private Type(String name) {
super(name);
}
public static Type[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), Type.class);
}
public static Type valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<Type>() {
@Override public Type create(String name) {
return new Type(name);
}
});
}
}
public static class Interval {
private Long from;
private Long to;
@JsonProperty("reward_per_assignment")
private BigDecimal rewardPerAssignment;
@JsonCreator
public Interval(@JsonProperty("from") Long from,
@JsonProperty("to") Long to,
@JsonProperty("reward_per_assignment") BigDecimal rewardPerAssignment) {
this.from = from;
this.to = to;
this.rewardPerAssignment = rewardPerAssignment;
}
public Long getFrom() {
return from;
}
public void setFrom(Long from) {
this.from = from;
}
public Long getTo() {
return to;
}
public void setTo(Long to) {
this.to = to;
}
public BigDecimal getRewardPerAssignment() {
return rewardPerAssignment;
}
public void setRewardPerAssignment(BigDecimal rewardPerAssignment) {
this.rewardPerAssignment = rewardPerAssignment;
}
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/MixerConfig.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class MixerConfig {
@JsonProperty("real_tasks_count")
private Integer realTasksCount;
@JsonProperty("golden_tasks_count")
private Integer goldenTasksCount;
@JsonProperty("training_tasks_count")
private Integer trainingTasksCount;
@JsonProperty("min_real_tasks_count")
private Integer minRealTasksCount;
@JsonProperty("min_golden_tasks_count")
private Integer minGoldenTasksCount;
@JsonProperty("min_training_tasks_count")
private Integer minTrainingTasksCount;
@JsonProperty("force_last_assignment")
private Boolean forceLastAssignment;
@JsonProperty("force_last_assignment_delay_seconds")
private Integer forceLastAssignmentDelaySeconds;
@JsonProperty("mix_tasks_in_creation_order")
private Boolean mixTasksInCreationOrder;
@JsonProperty("shuffle_tasks_in_task_suite")
private Boolean shuffleTasksInTaskSuite;
@JsonProperty("golden_task_distribution_function")
private TaskDistributionFunction goldenTaskDistributionFunction;
@JsonProperty("training_task_distribution_function")
private TaskDistributionFunction trainingTaskDistributionFunction;
@JsonCreator
public MixerConfig(@JsonProperty("real_tasks_count") Integer realTasksCount,
@JsonProperty("golden_tasks_count") Integer goldenTasksCount,
@JsonProperty("training_tasks_count") Integer trainingTasksCount) {
this.realTasksCount = realTasksCount;
this.goldenTasksCount = goldenTasksCount;
this.trainingTasksCount = trainingTasksCount;
}
public Integer getRealTasksCount() {
return realTasksCount;
}
public void setRealTasksCount(Integer realTasksCount) {
this.realTasksCount = realTasksCount;
}
public Integer getGoldenTasksCount() {
return goldenTasksCount;
}
public void setGoldenTasksCount(Integer goldenTasksCount) {
this.goldenTasksCount = goldenTasksCount;
}
public Integer getTrainingTasksCount() {
return trainingTasksCount;
}
public void setTrainingTasksCount(Integer trainingTasksCount) {
this.trainingTasksCount = trainingTasksCount;
}
public Integer getMinRealTasksCount() {
return minRealTasksCount;
}
public void setMinRealTasksCount(Integer minRealTasksCount) {
this.minRealTasksCount = minRealTasksCount;
}
public Integer getMinGoldenTasksCount() {
return minGoldenTasksCount;
}
public void setMinGoldenTasksCount(Integer minGoldenTasksCount) {
this.minGoldenTasksCount = minGoldenTasksCount;
}
public Integer getMinTrainingTasksCount() {
return minTrainingTasksCount;
}
public void setMinTrainingTasksCount(Integer minTrainingTasksCount) {
this.minTrainingTasksCount = minTrainingTasksCount;
}
public Boolean getForceLastAssignment() {
return forceLastAssignment;
}
public void setForceLastAssignment(Boolean forceLastAssignment) {
this.forceLastAssignment = forceLastAssignment;
}
public Boolean getMixTasksInCreationOrder() {
return mixTasksInCreationOrder;
}
public void setMixTasksInCreationOrder(Boolean mixTasksInCreationOrder) {
this.mixTasksInCreationOrder = mixTasksInCreationOrder;
}
public Boolean getShuffleTasksInTaskSuite() {
return shuffleTasksInTaskSuite;
}
public void setShuffleTasksInTaskSuite(Boolean shuffleTasksInTaskSuite) {
this.shuffleTasksInTaskSuite = shuffleTasksInTaskSuite;
}
public TaskDistributionFunction getGoldenTaskDistributionFunction() {
return goldenTaskDistributionFunction;
}
public void setGoldenTaskDistributionFunction(TaskDistributionFunction goldenTaskDistributionFunction) {
this.goldenTaskDistributionFunction = goldenTaskDistributionFunction;
}
public TaskDistributionFunction getTrainingTaskDistributionFunction() {
return trainingTaskDistributionFunction;
}
public void setTrainingTaskDistributionFunction(TaskDistributionFunction trainingTaskDistributionFunction) {
this.trainingTaskDistributionFunction = trainingTaskDistributionFunction;
}
public Integer getForceLastAssignmentDelaySeconds() {
return forceLastAssignmentDelaySeconds;
}
public void setForceLastAssignmentDelaySeconds(Integer forceLastAssignmentDelaySeconds) {
this.forceLastAssignmentDelaySeconds = forceLastAssignmentDelaySeconds;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/Pool.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import ai.toloka.client.v1.Owner;
import ai.toloka.client.v1.pool.dynamicoverlap.AbstractDynamicOverlapConfig;
import ai.toloka.client.v1.pool.filter.Condition;
import ai.toloka.client.v1.pool.filter.Connective;
import ai.toloka.client.v1.pool.qualitycontrol.QualityControl;
public class Pool {
private String id;
private Owner owner;
private PoolType type;
@JsonProperty("project_id")
private String projectId;
@JsonProperty("private_name")
private String privateName;
@JsonProperty("private_comment")
private String privateComment;
@JsonProperty("public_description")
private String publicDescription;
@JsonProperty("public_instructions")
private String publicInstructions;
@JsonProperty("may_contain_adult_content")
private Boolean mayContainAdultContent;
@JsonProperty("will_expire")
private Date willExpire;
@JsonProperty("auto_close_after_complete_delay_seconds")
private Long autoCloseAfterCompleteDelaySeconds;
@JsonProperty("reward_per_assignment")
private BigDecimal rewardPerAssignment;
@JsonProperty("dynamic_pricing_config")
private DynamicPricingConfig dynamicPricingConfig;
private Map<String, List<String>> metadata;
@JsonProperty("dynamic_overlap_config")
private AbstractDynamicOverlapConfig dynamicOverlapConfig;
@JsonProperty("assignment_max_duration_seconds")
private Integer assignmentMaxDurationSeconds;
@JsonProperty("auto_accept_solutions")
private Boolean autoAcceptSolutions;
@JsonProperty("auto_accept_period_day")
private Integer autoAcceptPeriodDay;
private Long priority;
@JsonProperty("assignments_issuing_config")
private AssignmentsIssuingConfig assignmentsIssuingConfig;
@JsonDeserialize(using = Condition.ConditionDeserializer.class)
private Connective filter;
@JsonProperty("quality_control")
private QualityControl qualityControl;
private PoolDefaults defaults;
@JsonProperty("mixer_config")
private MixerConfig mixerConfig;
@JsonProperty("training_config")
private PoolTrainingConfig trainingConfig;
private PoolStatus status;
private Date created;
@JsonProperty("last_started")
private Date lastStarted;
@JsonProperty("last_stopped")
private Date lastStopped;
@JsonProperty("last_close_reason")
private PoolCloseReason lastCloseReason;
@JsonProperty("speed_quality_balance")
private AbstractSpeedQualityBalance speedQualityBalance;
@JsonCreator
public Pool(@JsonProperty("project_id") String projectId,
@JsonProperty("private_name") String privateName,
@JsonProperty("may_contain_adult_content") Boolean mayContainAdultContent,
@JsonProperty("will_expire") Date willExpire,
@JsonProperty("reward_per_assignment") BigDecimal rewardPerAssignment,
@JsonProperty("assignment_max_duration_seconds") Integer assignmentMaxDurationSeconds,
@JsonProperty("auto_accept_solutions") Boolean autoAcceptSolutions,
@JsonProperty("defaults") PoolDefaults defaults) {
this.projectId = projectId;
this.privateName = privateName;
this.mayContainAdultContent = mayContainAdultContent;
this.willExpire = willExpire;
this.rewardPerAssignment = rewardPerAssignment;
this.assignmentMaxDurationSeconds = assignmentMaxDurationSeconds;
this.autoAcceptSolutions = autoAcceptSolutions;
this.defaults = defaults;
}
public void setPrivateName(String privateName) {
this.privateName = privateName;
}
public void setPrivateComment(String privateComment) {
this.privateComment = privateComment;
}
public void setPublicDescription(String publicDescription) {
this.publicDescription = publicDescription;
}
public void setMayContainAdultContent(Boolean mayContainAdultContent) {
this.mayContainAdultContent = mayContainAdultContent;
}
public void setWillExpire(Date willExpire) {
this.willExpire = willExpire;
}
public void setRewardPerAssignment(BigDecimal rewardPerAssignment) {
this.rewardPerAssignment = rewardPerAssignment;
}
public void setDynamicPricingConfig(DynamicPricingConfig dynamicPricingConfig) {
this.dynamicPricingConfig = dynamicPricingConfig;
}
public void setDynamicOverlapConfig(AbstractDynamicOverlapConfig dynamicOverlapConfig) {
this.dynamicOverlapConfig = dynamicOverlapConfig;
}
public void setAssignmentMaxDurationSeconds(Integer assignmentMaxDurationSeconds) {
this.assignmentMaxDurationSeconds = assignmentMaxDurationSeconds;
}
public void setAutoAcceptSolutions(Boolean autoAcceptSolutions) {
this.autoAcceptSolutions = autoAcceptSolutions;
}
public Integer getAutoAcceptPeriodDay() {
return autoAcceptPeriodDay;
}
public void setAutoAcceptPeriodDay(Integer autoAcceptPeriodDay) {
this.autoAcceptPeriodDay = autoAcceptPeriodDay;
}
public void setPriority(Long priority) {
this.priority = priority;
}
public void setAssignmentsIssuingConfig(AssignmentsIssuingConfig assignmentsIssuingConfig) {
this.assignmentsIssuingConfig = assignmentsIssuingConfig;
}
public void setFilter(Connective filter) {
this.filter = filter;
}
public void setQualityControl(QualityControl qualityControl) {
this.qualityControl = qualityControl;
}
public void setDefaults(PoolDefaults defaults) {
this.defaults = defaults;
}
public String getId() {
return id;
}
public Owner getOwner() {
return owner;
}
public String getProjectId() {
return projectId;
}
public String getPrivateName() {
return privateName;
}
public String getPrivateComment() {
return privateComment;
}
public String getPublicDescription() {
return publicDescription;
}
public Boolean getMayContainAdultContent() {
return mayContainAdultContent;
}
public Date getWillExpire() {
return willExpire;
}
public BigDecimal getRewardPerAssignment() {
return rewardPerAssignment;
}
public DynamicPricingConfig getDynamicPricingConfig() {
return dynamicPricingConfig;
}
public AbstractDynamicOverlapConfig getDynamicOverlapConfig() {
return dynamicOverlapConfig;
}
public Map<String, List<String>> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, List<String>> metadata) {
this.metadata = metadata;
}
public Integer getAssignmentMaxDurationSeconds() {
return assignmentMaxDurationSeconds;
}
public Boolean getAutoAcceptSolutions() {
return autoAcceptSolutions;
}
public Long getPriority() {
return priority;
}
public AssignmentsIssuingConfig getAssignmentsIssuingConfig() {
return assignmentsIssuingConfig;
}
public Connective getFilter() {
return filter;
}
public QualityControl getQualityControl() {
return qualityControl;
}
public PoolDefaults getDefaults() {
return defaults;
}
public MixerConfig getMixerConfig() {
return mixerConfig;
}
public void setMixerConfig(MixerConfig mixerConfig) {
this.mixerConfig = mixerConfig;
}
public PoolStatus getStatus() {
return status;
}
public Date getCreated() {
return created;
}
public Date getLastStarted() {
return lastStarted;
}
public Date getLastStopped() {
return lastStopped;
}
public PoolCloseReason getLastCloseReason() {
return lastCloseReason;
}
public Long getAutoCloseAfterCompleteDelaySeconds() {
return autoCloseAfterCompleteDelaySeconds;
}
public void setAutoCloseAfterCompleteDelaySeconds(Long autoCloseAfterCompleteDelaySeconds) {
this.autoCloseAfterCompleteDelaySeconds = autoCloseAfterCompleteDelaySeconds;
}
public PoolType getType() {
return type;
}
public String getPublicInstructions() {
return publicInstructions;
}
public PoolTrainingConfig getTrainingConfig() {
return trainingConfig;
}
public AbstractSpeedQualityBalance getSpeedQualityBalance() {
return speedQualityBalance;
}
public void setSpeedQualityBalance(AbstractSpeedQualityBalance speedQualityBalance) {
this.speedQualityBalance = speedQualityBalance;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/PoolArchiveOperation.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.operation.OperationType;
public class PoolArchiveOperation extends Operation<PoolArchiveOperation.Parameters, PoolArchiveOperation> {
public static final OperationType TYPE = OperationType.POOL_ARCHIVE;
public PoolArchiveOperation() {}
private PoolArchiveOperation(Date currentDateTime) {
super(currentDateTime);
}
public static class Parameters {
@JsonProperty("pool_id")
private String poolId;
public String getPoolId() {
return poolId;
}
}
public static PoolArchiveOperation createPseudo(Date currentDateTime) {
return new PoolArchiveOperation(currentDateTime);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/PoolClient.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import ai.toloka.client.v1.ModificationResult;
import ai.toloka.client.v1.SearchResult;
public interface PoolClient {
SearchResult<Pool> findPools(PoolSearchRequest request);
Pool getPool(String id);
ModificationResult<Pool> createPool(Pool pool);
ModificationResult<Pool> updatePool(String poolId, Pool pool);
ModificationResult<Pool> patchPool(String poolId, PoolPatchRequest request);
PoolOpenOperation openPool(String poolId);
PoolCloseOperation closePool(String poolId);
PoolCloseOperation closePoolForUpdate(String poolId);
PoolArchiveOperation archivePool(String poolId);
PoolCloneOperation clonePool(String poolId);
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/PoolCloneOperation.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.operation.OperationType;
public class PoolCloneOperation extends Operation<PoolCloneOperation.Parameters, PoolCloneOperation> {
public static final OperationType TYPE = OperationType.POOL_CLONE;
public PoolCloneOperation() {
}
private PoolCloneOperation(Date currentDateTime) {
super(currentDateTime);
}
public static class Parameters {
@JsonProperty("pool_id")
private String poolId;
public String getPoolId() {
return poolId;
}
}
public static PoolCloneOperation createPseudo(Date currentDateTime) {
return new PoolCloneOperation(currentDateTime);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/PoolCloseOperation.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.operation.OperationType;
public class PoolCloseOperation extends Operation<PoolCloseOperation.Parameters, PoolCloseOperation> {
public static final OperationType TYPE = OperationType.POOL_CLOSE;
public PoolCloseOperation() {}
private PoolCloseOperation(Date currentDateTime) {
super(currentDateTime);
}
public static class Parameters {
@JsonProperty("pool_id")
private String poolId;
public String getPoolId() {
return poolId;
}
}
public static PoolCloseOperation createPseudo(Date currentDateTime) {
return new PoolCloseOperation(currentDateTime);
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/PoolCloseReason.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import ai.toloka.client.v1.FlexibleEnum;
public final class PoolCloseReason extends FlexibleEnum<PoolCloseReason> {
public static final PoolCloseReason MANUAL = new PoolCloseReason("MANUAL");
public static final PoolCloseReason EXPIRED = new PoolCloseReason("EXPIRED");
public static final PoolCloseReason COMPLETED = new PoolCloseReason("COMPLETED");
public static final PoolCloseReason NOT_ENOUGH_BALANCE = new PoolCloseReason("NOT_ENOUGH_BALANCE");
public static final PoolCloseReason ASSIGNMENTS_LIMIT_EXCEEDED = new PoolCloseReason("ASSIGNMENTS_LIMIT_EXCEEDED");
public static final PoolCloseReason BLOCKED = new PoolCloseReason("BLOCKED");
public static final PoolCloseReason FOR_UPDATE = new PoolCloseReason("FOR_UPDATE");
private static final PoolCloseReason[] VALUES = {MANUAL, EXPIRED, COMPLETED,
NOT_ENOUGH_BALANCE, ASSIGNMENTS_LIMIT_EXCEEDED, BLOCKED, FOR_UPDATE};
private static final ConcurrentMap<String, PoolCloseReason> DISCOVERED_VALUES = new ConcurrentHashMap<>();
private PoolCloseReason(String name) {
super(name);
}
public static PoolCloseReason[] values() {
return values(VALUES, DISCOVERED_VALUES.values(), PoolCloseReason.class);
}
@JsonCreator
public static PoolCloseReason valueOf(String name) {
return valueOf(VALUES, DISCOVERED_VALUES, name, new NewEnumCreator<PoolCloseReason>() {
@Override public PoolCloseReason create(String name) {
return new PoolCloseReason(name);
}
});
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/PoolDefaults.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class PoolDefaults {
@JsonProperty("default_overlap_for_new_task_suites")
private Integer defaultOverlapForNewTaskSuites;
@JsonProperty("default_overlap_for_new_tasks")
private Integer defaultOverlapForNewTasks;
@JsonCreator
public PoolDefaults(@JsonProperty("default_overlap_for_new_task_suites") Integer defaultOverlapForNewTaskSuites) {
this.defaultOverlapForNewTaskSuites = defaultOverlapForNewTaskSuites;
}
public void setDefaultOverlapForNewTaskSuites(Integer defaultOverlapForNewTaskSuites) {
this.defaultOverlapForNewTaskSuites = defaultOverlapForNewTaskSuites;
}
public Integer getDefaultOverlapForNewTaskSuites() {
return defaultOverlapForNewTaskSuites;
}
public Integer getDefaultOverlapForNewTasks() {
return defaultOverlapForNewTasks;
}
public void setDefaultOverlapForNewTasks(Integer defaultOverlapForNewTasks) {
this.defaultOverlapForNewTasks = defaultOverlapForNewTasks;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/PoolFilterParam.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import ai.toloka.client.v1.FilterParam;
public enum PoolFilterParam implements FilterParam {
ownerId(PoolSearchRequest.OWNER_ID_PARAMETER),
ownerCompanyId(PoolSearchRequest.OWNER_COMPANY_ID_PARAMETER),
status(PoolSearchRequest.STATUS_PARAMETER),
projectId(PoolSearchRequest.PROJECT_ID_PARAMETER);
private String parameter;
PoolFilterParam(String parameter) {
this.parameter = parameter;
}
@Override
public String parameter() {
return parameter;
}
}
|
0 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1 | java-sources/ai/toloka/toloka-java-sdk/0.0.7/ai/toloka/client/v1/pool/PoolOpenOperation.java | /*
* Copyright 2021 YANDEX LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.toloka.client.v1.pool;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
import ai.toloka.client.v1.operation.Operation;
import ai.toloka.client.v1.operation.OperationType;
public class PoolOpenOperation extends Operation<PoolOpenOperation.Parameters, PoolOpenOperation> {
public static final OperationType TYPE = OperationType.POOL_OPEN;
public PoolOpenOperation() {}
private PoolOpenOperation(Date currentDateTime) {
super(currentDateTime);
}
public static class Parameters {
@JsonProperty("pool_id")
private String poolId;
public String getPoolId() {
return poolId;
}
}
public static PoolOpenOperation createPseudo(Date currentDateTime) {
return new PoolOpenOperation(currentDateTime);
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.