Skip to content

Commit

Permalink
Merge pull request #1 from Azure/master
Browse files Browse the repository at this point in the history
Fetching upstream
  • Loading branch information
pednekarprajakta committed Apr 12, 2016
2 parents 1232c76 + 36b3768 commit a1b8d2a
Show file tree
Hide file tree
Showing 11 changed files with 773 additions and 50 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Copyright Microsoft Corporation
*
*
* 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.
Expand All @@ -27,14 +27,19 @@

import com.microsoft.windowsazure.services.servicebus.ServiceBusContract;
import com.microsoft.windowsazure.services.servicebus.models.BrokeredMessage;
import com.microsoft.windowsazure.services.servicebus.models.CreateEventHubResult;
import com.microsoft.windowsazure.services.servicebus.models.CreateQueueResult;
import com.microsoft.windowsazure.services.servicebus.models.CreateRuleResult;
import com.microsoft.windowsazure.services.servicebus.models.CreateSubscriptionResult;
import com.microsoft.windowsazure.services.servicebus.models.CreateTopicResult;
import com.microsoft.windowsazure.services.servicebus.models.EventHubInfo;
import com.microsoft.windowsazure.services.servicebus.models.GetEventHubResult;
import com.microsoft.windowsazure.services.servicebus.models.GetQueueResult;
import com.microsoft.windowsazure.services.servicebus.models.GetRuleResult;
import com.microsoft.windowsazure.services.servicebus.models.GetSubscriptionResult;
import com.microsoft.windowsazure.services.servicebus.models.GetTopicResult;
import com.microsoft.windowsazure.services.servicebus.models.ListEventHubsOptions;
import com.microsoft.windowsazure.services.servicebus.models.ListEventHubsResult;
import com.microsoft.windowsazure.services.servicebus.models.ListQueuesOptions;
import com.microsoft.windowsazure.services.servicebus.models.ListQueuesResult;
import com.microsoft.windowsazure.services.servicebus.models.ListRulesOptions;
Expand Down Expand Up @@ -260,6 +265,63 @@ public QueueInfo updateQueue(QueueInfo queueInfo) throws ServiceException {
}
}

@Override
public CreateEventHubResult createEventHub(EventHubInfo eventHub)
throws ServiceException {
try {
return next.createEventHub(eventHub);
} catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
} catch (ClientHandlerException e) {
throw processCatch(new ServiceException(e));
}
}

@Override
public void deleteEventHub(String eventHubPath) throws ServiceException {
try {
next.deleteEventHub(eventHubPath);
} catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
} catch (ClientHandlerException e) {
throw processCatch(new ServiceException(e));
}
}

@Override
public GetEventHubResult getEventHub(String eventHubPath) throws ServiceException {
try {
return next.getEventHub(eventHubPath);
} catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
} catch (ClientHandlerException e) {
throw processCatch(new ServiceException(e));
}
}

@Override
public ListEventHubsResult listEventHubs() throws ServiceException {
try {
return next.listEventHubs();
} catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
} catch (ClientHandlerException e) {
throw processCatch(new ServiceException(e));
}
}

@Override
public ListEventHubsResult listEventHubs(ListEventHubsOptions options)
throws ServiceException {
try {
return next.listEventHubs(options);
} catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
} catch (ClientHandlerException e) {
throw processCatch(new ServiceException(e));
}
}

@Override
public CreateTopicResult createTopic(TopicInfo topic)
throws ServiceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@
import com.microsoft.windowsazure.services.servicebus.ServiceBusContract;
import com.microsoft.windowsazure.services.servicebus.models.AbstractListOptions;
import com.microsoft.windowsazure.services.servicebus.models.BrokeredMessage;
import com.microsoft.windowsazure.services.servicebus.models.CreateEventHubResult;
import com.microsoft.windowsazure.services.servicebus.models.CreateQueueResult;
import com.microsoft.windowsazure.services.servicebus.models.CreateRuleResult;
import com.microsoft.windowsazure.services.servicebus.models.CreateSubscriptionResult;
import com.microsoft.windowsazure.services.servicebus.models.CreateTopicResult;
import com.microsoft.windowsazure.services.servicebus.models.EventHubInfo;
import com.microsoft.windowsazure.services.servicebus.models.GetEventHubResult;
import com.microsoft.windowsazure.services.servicebus.models.GetQueueResult;
import com.microsoft.windowsazure.services.servicebus.models.GetRuleResult;
import com.microsoft.windowsazure.services.servicebus.models.GetSubscriptionResult;
import com.microsoft.windowsazure.services.servicebus.models.GetTopicResult;
import com.microsoft.windowsazure.services.servicebus.models.ListEventHubsOptions;
import com.microsoft.windowsazure.services.servicebus.models.ListEventHubsResult;
import com.microsoft.windowsazure.services.servicebus.models.ListQueuesOptions;
import com.microsoft.windowsazure.services.servicebus.models.ListQueuesResult;
import com.microsoft.windowsazure.services.servicebus.models.ListRulesOptions;
Expand Down Expand Up @@ -163,8 +168,12 @@ public void setChannel(Client channel) {
}

private WebResource getResource() {
return getResourceWithApiVersion("2013-07");
}

private WebResource getResourceWithApiVersion(String version) {
WebResource resource = getChannel().resource(uri).queryParam(
"api-version", "2013-07");
"api-version", version);
for (ClientFilter filter : filters) {
resource.addFilter(filter);
}
Expand Down Expand Up @@ -400,6 +409,44 @@ private WebResource listOptions(AbstractListOptions<?> options,
return path;
}

@Override
public CreateEventHubResult createEventHub(EventHubInfo entry)
throws ServiceException {
return new CreateEventHubResult(getResourceWithApiVersion("2014-01").path(entry.getPath())
.type("application/atom+xml;type=entry;charset=utf-8")
.put(EventHubInfo.class, entry));
}

@Override
public void deleteEventHub(String eventHubPath) throws ServiceException {
getResourceWithApiVersion("2014-01").path(eventHubPath).delete();
}

@Override
public GetEventHubResult getEventHub(String eventHubPath) throws ServiceException {
return new GetEventHubResult(getResourceWithApiVersion("2014-01").path(eventHubPath).get(
EventHubInfo.class));
}

@Override
public ListEventHubsResult listEventHubs(ListEventHubsOptions options)
throws ServiceException {
Feed feed = listOptions(options,
getResourceWithApiVersion("2014-01").path("$Resources/EventHubs")).get(Feed.class);
ArrayList<EventHubInfo> eventHubs = new ArrayList<EventHubInfo>();
for (Entry entry : feed.getEntries()) {
eventHubs.add(new EventHubInfo(entry));
}
ListEventHubsResult result = new ListEventHubsResult();
result.setItems(eventHubs);
return result;
}

@Override
public ListEventHubsResult listEventHubs() throws ServiceException {
return listEventHubs(ListEventHubsOptions.DEFAULT);
}

@Override
public CreateTopicResult createTopic(TopicInfo entry)
throws ServiceException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
*
* Copyright (c) Microsoft and contributors. 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.microsoft.windowsazure.services.servicebus.models;

/**
* Represents the result of a <code>createTopic</code> operation.
*/
public class CreateEventHubResult {

private EventHubInfo value;

/**
* Creates an instance of the <code>CreateEventHubResult</code> class.
*
* @param value
* A {@link EventHubInfo} object assigned as the value of the
* result.
*/
public CreateEventHubResult(EventHubInfo value) {
this.setValue(value);
}

/**
* Specfies the value of the result.
*
* @param value
* A {@link EventHubInfo} object assigned as the value of the
* result.
*/
public void setValue(EventHubInfo value) {
this.value = value;
}

/**
* Returns the value of the result.
*
* @return A {@link EventHubInfo} object that represents the value of the
* result.
*/
public EventHubInfo getValue() {
return value;
}

}

0 comments on commit a1b8d2a

Please sign in to comment.