Skip to content

Commit

Permalink
Replace CR characters with newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
jboynes committed Jun 3, 2015
1 parent 0cd6f98 commit 3d83517
Show file tree
Hide file tree
Showing 12 changed files with 1,249 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
/* * Copyright 2015 Google Inc. All Rights Reserved. * * 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 com.google.gcloud;public abstract class BaseService<O extends ServiceOptions> implements Service<O> { private final O options; protected BaseService(O options) { this.options = options; } @Override public O options() { return options; }}
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* 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 com.google.gcloud;

public abstract class BaseService<O extends ServiceOptions> implements Service<O> {

private final O options;

protected BaseService(O options) {
this.options = options;
}

@Override
public O options() {
return options;
}
}
22 changes: 21 additions & 1 deletion gcloud-java-core/src/main/java/com/google/gcloud/Service.java
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
/* * Copyright 2015 Google Inc. All Rights Reserved. * * 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 com.google.gcloud;public interface Service<O extends ServiceOptions> { O options();}
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* 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 com.google.gcloud;

public interface Service<O extends ServiceOptions> {
O options();
}
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
/* * Copyright 2015 Google Inc. All Rights Reserved. * * 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 com.google.gcloud.spi;import com.google.gcloud.ServiceOptions;import java.io.Serializable;/** * A base interface for all service RPC factories. * Loading of a factory implementation is done via {@link java.util.ServiceLoader}. */public interface ServiceRpcFactory<S, O extends ServiceOptions> extends Serializable { S create(O options);}
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* 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 com.google.gcloud.spi;

import com.google.gcloud.ServiceOptions;

import java.io.Serializable;

/**
* A base interface for all service RPC factories.
* Loading of a factory implementation is done via {@link java.util.ServiceLoader}.
*/
public interface ServiceRpcFactory<S, O extends ServiceOptions> extends Serializable {

S create(O options);
}
Original file line number Diff line number Diff line change
@@ -1 +1,117 @@
/* * Copyright 2015 Google Inc. All Rights Reserved. * * 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 com.google.gcloud.spi;import com.google.api.services.datastore.DatastoreV1.AllocateIdsRequest;import com.google.api.services.datastore.DatastoreV1.AllocateIdsResponse;import com.google.api.services.datastore.DatastoreV1.BeginTransactionRequest;import com.google.api.services.datastore.DatastoreV1.BeginTransactionResponse;import com.google.api.services.datastore.DatastoreV1.CommitRequest;import com.google.api.services.datastore.DatastoreV1.CommitResponse;import com.google.api.services.datastore.DatastoreV1.LookupRequest;import com.google.api.services.datastore.DatastoreV1.LookupResponse;import com.google.api.services.datastore.DatastoreV1.RollbackRequest;import com.google.api.services.datastore.DatastoreV1.RollbackResponse;import com.google.api.services.datastore.DatastoreV1.RunQueryRequest;import com.google.api.services.datastore.DatastoreV1.RunQueryResponse;/** * Provides access to the remote Datastore service. */public interface DatastoreRpc { public class DatastoreRpcException extends Exception { /** * The reason for the exception. * * @see <a href="https://cloud.google.com/datastore/docs/concepts/errors#Error_Codes">Google Cloud Datastore error codes</a> */ public enum Reason { ABORTED(true, "Request aborted", 409), DEADLINE_EXCEEDED(true, "Deadline exceeded", 403), FAILED_PRECONDITION(false, "Invalid request", 412), INTERNAL(false, "Server returned an error", 500), INVALID_ARGUMENT(false, "Request parameter has an invalid value", 400), PERMISSION_DENIED(false, "Unauthorized request", 403), RESOURCE_EXHAUSTED(false, "Quota exceeded", 402), UNAVAILABLE(true, "Could not reach service", 503); private final boolean retryable; private final String description; private final int httpStatus; private Reason(boolean retryable, String description, int httpStatus) { this.retryable = retryable; this.description = description; this.httpStatus = httpStatus; } public boolean retryable() { return retryable; } public String description() { return description; } public int httpStatus() { return httpStatus; } } private final String reason; private final int httpStatus; private final boolean retryable; public DatastoreRpcException(Reason reason) { this(reason.name(), reason.httpStatus, reason.retryable, reason.description); } public DatastoreRpcException(String reason, int httpStatus, boolean retryable, String message) { super(message); this.reason = reason; this.httpStatus = httpStatus; this.retryable = retryable; } public String reason() { return reason; } public int httpStatus() { return httpStatus; } public boolean retryable() { return retryable; } } AllocateIdsResponse allocateIds(AllocateIdsRequest request) throws DatastoreRpcException; BeginTransactionResponse beginTransaction(BeginTransactionRequest request) throws DatastoreRpcException; CommitResponse commit(CommitRequest request) throws DatastoreRpcException; LookupResponse lookup(LookupRequest request) throws DatastoreRpcException; RollbackResponse rollback(RollbackRequest request) throws DatastoreRpcException; RunQueryResponse runQuery(RunQueryRequest request) throws DatastoreRpcException;}
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* 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 com.google.gcloud.spi;

import com.google.api.services.datastore.DatastoreV1.AllocateIdsRequest;
import com.google.api.services.datastore.DatastoreV1.AllocateIdsResponse;
import com.google.api.services.datastore.DatastoreV1.BeginTransactionRequest;
import com.google.api.services.datastore.DatastoreV1.BeginTransactionResponse;
import com.google.api.services.datastore.DatastoreV1.CommitRequest;
import com.google.api.services.datastore.DatastoreV1.CommitResponse;
import com.google.api.services.datastore.DatastoreV1.LookupRequest;
import com.google.api.services.datastore.DatastoreV1.LookupResponse;
import com.google.api.services.datastore.DatastoreV1.RollbackRequest;
import com.google.api.services.datastore.DatastoreV1.RollbackResponse;
import com.google.api.services.datastore.DatastoreV1.RunQueryRequest;
import com.google.api.services.datastore.DatastoreV1.RunQueryResponse;

/**
* Provides access to the remote Datastore service.
*/
public interface DatastoreRpc {

public class DatastoreRpcException extends Exception {

/**
* The reason for the exception.
*
* @see <a href="https://cloud.google.com/datastore/docs/concepts/errors#Error_Codes">Google Cloud Datastore error codes</a>
*/
public enum Reason {

ABORTED(true, "Request aborted", 409),
DEADLINE_EXCEEDED(true, "Deadline exceeded", 403),
FAILED_PRECONDITION(false, "Invalid request", 412),
INTERNAL(false, "Server returned an error", 500),
INVALID_ARGUMENT(false, "Request parameter has an invalid value", 400),
PERMISSION_DENIED(false, "Unauthorized request", 403),
RESOURCE_EXHAUSTED(false, "Quota exceeded", 402),
UNAVAILABLE(true, "Could not reach service", 503);

private final boolean retryable;
private final String description;
private final int httpStatus;

private Reason(boolean retryable, String description, int httpStatus) {
this.retryable = retryable;
this.description = description;
this.httpStatus = httpStatus;
}

public boolean retryable() {
return retryable;
}

public String description() {
return description;
}

public int httpStatus() {
return httpStatus;
}
}

private final String reason;
private final int httpStatus;
private final boolean retryable;

public DatastoreRpcException(Reason reason) {
this(reason.name(), reason.httpStatus, reason.retryable, reason.description);
}

public DatastoreRpcException(String reason, int httpStatus, boolean retryable, String message) {
super(message);
this.reason = reason;
this.httpStatus = httpStatus;
this.retryable = retryable;
}

public String reason() {
return reason;
}

public int httpStatus() {
return httpStatus;
}

public boolean retryable() {
return retryable;
}
}

AllocateIdsResponse allocateIds(AllocateIdsRequest request) throws DatastoreRpcException;

BeginTransactionResponse beginTransaction(BeginTransactionRequest request)
throws DatastoreRpcException;

CommitResponse commit(CommitRequest request) throws DatastoreRpcException;

LookupResponse lookup(LookupRequest request) throws DatastoreRpcException;

RollbackResponse rollback(RollbackRequest request) throws DatastoreRpcException;

RunQueryResponse runQuery(RunQueryRequest request) throws DatastoreRpcException;
}
Loading

0 comments on commit 3d83517

Please sign in to comment.