provider/azurerm: Event Hub Namespaces (#9297)

Add support for EventHub NameSpaces
This commit is contained in:
Tom Harvey 2016-10-25 16:50:07 +02:00 committed by Paul Stack
parent 4b72349215
commit 59a81da74e
15 changed files with 2956 additions and 7 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/cdn"
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/eventhub"
"github.com/Azure/azure-sdk-for-go/arm/keyvault"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
@ -58,6 +59,8 @@ type ArmClient struct {
cdnProfilesClient cdn.ProfilesClient
cdnEndpointsClient cdn.EndpointsClient
eventHubNamespacesClient eventhub.NamespacesClient
providers resources.ProvidersClient
resourceGroupClient resources.GroupsClient
tagsClient resources.TagsClient
@ -209,6 +212,12 @@ func (c *Config) getArmClient() (*ArmClient, error) {
agc.Sender = autorest.CreateSender(withRequestLogging())
client.appGatewayClient = agc
ehnc := eventhub.NewNamespacesClient(c.SubscriptionID)
setUserAgent(&ehnc.Client)
ehnc.Authorizer = spt
ehnc.Sender = autorest.CreateSender(withRequestLogging())
client.eventHubNamespacesClient = ehnc
ifc := network.NewInterfacesClient(c.SubscriptionID)
setUserAgent(&ifc.Client)
ifc.Authorizer = spt

View File

@ -0,0 +1,33 @@
package azurerm
import (
"testing"
"fmt"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMEventHubNamespace_importBasic(t *testing.T) {
resourceName := "azurerm_eventhub_namespace.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMEventHubNamespace_basic, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMEventHubNamespaceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -54,6 +54,8 @@ func Provider() terraform.ResourceProvider {
"azurerm_cdn_endpoint": resourceArmCdnEndpoint(),
"azurerm_cdn_profile": resourceArmCdnProfile(),
"azurerm_eventhub_namespace": resourceArmEventHubNamespace(),
"azurerm_lb": resourceArmLoadBalancer(),
"azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(),
"azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(),
@ -193,7 +195,7 @@ func registerAzureResourceProvidersWithSubscription(client *riviera.Client) erro
var err error
providerRegistrationOnce.Do(func() {
// We register Microsoft.Compute during client initialization
providers := []string{"Microsoft.Network", "Microsoft.Cdn", "Microsoft.Storage", "Microsoft.Sql", "Microsoft.Search", "Microsoft.Resources", "Microsoft.ServiceBus", "Microsoft.KeyVault"}
providers := []string{"Microsoft.Network", "Microsoft.Cdn", "Microsoft.Storage", "Microsoft.Sql", "Microsoft.Search", "Microsoft.Resources", "Microsoft.ServiceBus", "Microsoft.KeyVault", "Microsoft.EventHub"}
var wg sync.WaitGroup
wg.Add(len(providers))

View File

@ -0,0 +1,211 @@
package azurerm
import (
"fmt"
"log"
"strings"
"github.com/Azure/azure-sdk-for-go/arm/eventhub"
"github.com/hashicorp/terraform/helper/schema"
"net/http"
)
// Default Authorization Rule/Policy created by Azure, used to populate the
// default connection strings and keys
var eventHubNamespaceDefaultAuthorizationRule = "RootManageSharedAccessKey"
func resourceArmEventHubNamespace() *schema.Resource {
return &schema.Resource{
Create: resourceArmEventHubNamespaceCreate,
Read: resourceArmEventHubNamespaceRead,
Update: resourceArmEventHubNamespaceCreate,
Delete: resourceArmEventHubNamespaceDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"location": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: azureRMNormalizeLocation,
},
"resource_group_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"sku": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateEventHubNamespaceSku,
},
"capacity": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
ValidateFunc: validateEventHubNamespaceCapacity,
},
"default_primary_connection_string": {
Type: schema.TypeString,
Computed: true,
},
"default_secondary_connection_string": {
Type: schema.TypeString,
Computed: true,
},
"default_primary_key": {
Type: schema.TypeString,
Computed: true,
},
"default_secondary_key": {
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(),
},
}
}
func resourceArmEventHubNamespaceCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient)
namespaceClient := client.eventHubNamespacesClient
log.Printf("[INFO] preparing arguments for Azure ARM EventHub Namespace creation.")
name := d.Get("name").(string)
location := d.Get("location").(string)
resGroup := d.Get("resource_group_name").(string)
sku := d.Get("sku").(string)
capacity := int32(d.Get("capacity").(int))
tags := d.Get("tags").(map[string]interface{})
parameters := eventhub.NamespaceCreateOrUpdateParameters{
Location: &location,
Sku: &eventhub.Sku{
Name: eventhub.SkuName(sku),
Tier: eventhub.SkuTier(sku),
Capacity: &capacity,
},
Tags: expandTags(tags),
}
_, err := namespaceClient.CreateOrUpdate(resGroup, name, parameters, make(chan struct{}))
if err != nil {
return err
}
read, err := namespaceClient.Get(resGroup, name)
if err != nil {
return err
}
if read.ID == nil {
return fmt.Errorf("Cannot read EventHub Namespace %s (resource group %s) ID", name, resGroup)
}
d.SetId(*read.ID)
return resourceArmEventHubNamespaceRead(d, meta)
}
func resourceArmEventHubNamespaceRead(d *schema.ResourceData, meta interface{}) error {
namespaceClient := meta.(*ArmClient).eventHubNamespacesClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
resGroup := id.ResourceGroup
name := id.Path["namespaces"]
resp, err := namespaceClient.Get(resGroup, name)
if err != nil {
return fmt.Errorf("Error making Read request on Azure EventHub Namespace %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}
d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resGroup)
d.Set("sku", string(resp.Sku.Name))
d.Set("capacity", resp.Sku.Capacity)
keys, err := namespaceClient.ListKeys(resGroup, name, eventHubNamespaceDefaultAuthorizationRule)
if err != nil {
log.Printf("[ERROR] Unable to List default keys for Namespace %s: %s", name, err)
} else {
d.Set("default_primary_connection_string", keys.PrimaryConnectionString)
d.Set("default_secondary_connection_string", keys.SecondaryConnectionString)
d.Set("default_primary_key", keys.PrimaryKey)
d.Set("default_secondary_key", keys.SecondaryKey)
}
flattenAndSetTags(d, resp.Tags)
return nil
}
func resourceArmEventHubNamespaceDelete(d *schema.ResourceData, meta interface{}) error {
namespaceClient := meta.(*ArmClient).eventHubNamespacesClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
resGroup := id.ResourceGroup
name := id.Path["namespaces"]
resp, err := namespaceClient.Delete(resGroup, name, make(chan struct{}))
if resp.StatusCode != http.StatusNotFound {
return fmt.Errorf("Error issuing Azure ARM delete request of EventHub Namespace'%s': %s", name, err)
}
return nil
}
func validateEventHubNamespaceSku(v interface{}, k string) (ws []string, errors []error) {
value := strings.ToLower(v.(string))
skus := map[string]bool{
"basic": true,
"standard": true,
}
if !skus[value] {
errors = append(errors, fmt.Errorf("EventHub Namespace SKU can only be Basic or Standard"))
}
return
}
func validateEventHubNamespaceCapacity(v interface{}, k string) (ws []string, errors []error) {
value := v.(int)
capacities := map[int]bool{
1: true,
2: true,
4: true,
}
if !capacities[value] {
errors = append(errors, fmt.Errorf("EventHub Namespace Capacity can only be 1, 2 or 4"))
}
return
}

View File

@ -0,0 +1,194 @@
package azurerm
import (
"fmt"
"net/http"
"regexp"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccAzureRMEventHubNamespaceCapacity_validation(t *testing.T) {
cases := []struct {
Value int
ErrCount int
}{
{
Value: 17,
ErrCount: 1,
},
{
Value: 1,
ErrCount: 0,
},
{
Value: 2,
ErrCount: 0,
},
{
Value: 3,
ErrCount: 1,
},
{
Value: 4,
ErrCount: 0,
},
}
for _, tc := range cases {
_, errors := validateEventHubNamespaceCapacity(tc.Value, "azurerm_eventhub_namespace")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected the Azure RM EventHub Namespace Capacity to trigger a validation error")
}
}
}
func TestAccAzureRMEventHubNamespaceSku_validation(t *testing.T) {
cases := []struct {
Value string
ErrCount int
}{
{
Value: "Basic",
ErrCount: 0,
},
{
Value: "Standard",
ErrCount: 0,
},
{
Value: "Premium",
ErrCount: 1,
},
{
Value: "Random",
ErrCount: 1,
},
}
for _, tc := range cases {
_, errors := validateEventHubNamespaceSku(tc.Value, "azurerm_eventhub_namespace")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected the Azure RM EventHub Namespace Sku to trigger a validation error")
}
}
}
func TestAccAzureRMEventHubNamespace_basic(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMEventHubNamespace_basic, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMEventHubNamespaceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMEventHubNamespaceExists("azurerm_eventhub_namespace.test"),
),
},
},
})
}
func TestAccAzureRMEventHubNamespace_readDefaultKeys(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMEventHubNamespace_basic, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMEventHubNamespaceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMEventHubNamespaceExists("azurerm_eventhub_namespace.test"),
resource.TestMatchResourceAttr(
"azurerm_eventhub_namespace.test", "default_primary_connection_string", regexp.MustCompile("Endpoint=.+")),
resource.TestMatchResourceAttr(
"azurerm_eventhub_namespace.test", "default_secondary_connection_string", regexp.MustCompile("Endpoint=.+")),
resource.TestMatchResourceAttr(
"azurerm_eventhub_namespace.test", "default_primary_key", regexp.MustCompile(".+")),
resource.TestMatchResourceAttr(
"azurerm_eventhub_namespace.test", "default_secondary_key", regexp.MustCompile(".+")),
),
},
},
})
}
func testCheckAzureRMEventHubNamespaceDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*ArmClient).eventHubNamespacesClient
for _, rs := range s.RootModule().Resources {
if rs.Type != "azurerm_eventhub_namespace" {
continue
}
name := rs.Primary.Attributes["name"]
resourceGroup := rs.Primary.Attributes["resource_group_name"]
resp, err := conn.Get(resourceGroup, name)
if err != nil {
return nil
}
if resp.StatusCode != http.StatusNotFound {
return fmt.Errorf("EventHub Namespace still exists:\n%#v", resp.Properties)
}
}
return nil
}
func testCheckAzureRMEventHubNamespaceExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
// Ensure we have enough information in state to look up in API
rs, ok := s.RootModule().Resources[name]
if !ok {
return fmt.Errorf("Not found: %s", name)
}
namespaceName := rs.Primary.Attributes["name"]
resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
if !hasResourceGroup {
return fmt.Errorf("Bad: no resource group found in state for Event Hub Namespace: %s", namespaceName)
}
conn := testAccProvider.Meta().(*ArmClient).eventHubNamespacesClient
resp, err := conn.Get(resourceGroup, namespaceName)
if err != nil {
return fmt.Errorf("Bad: Get on eventHubNamespacesClient: %s", err)
}
if resp.StatusCode == http.StatusNotFound {
return fmt.Errorf("Bad: Event Hub Namespace %q (resource group: %q) does not exist", namespaceName, resourceGroup)
}
return nil
}
}
var testAccAzureRMEventHubNamespace_basic = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
resource "azurerm_eventhub_namespace" "test" {
name = "acctesteventhubnamespace-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Basic"
}
`

View File

@ -158,7 +158,7 @@ func testCheckAzureRMServiceBusNamespaceExists(name string) resource.TestCheckFu
namespaceName := rs.Primary.Attributes["name"]
resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
if !hasResourceGroup {
return fmt.Errorf("Bad: no resource group found in state for public ip: %s", namespaceName)
return fmt.Errorf("Bad: no resource group found in state for Service Bus Namespace: %s", namespaceName)
}
conn := testAccProvider.Meta().(*ArmClient).serviceBusNamespacesClient
@ -169,7 +169,7 @@ func testCheckAzureRMServiceBusNamespaceExists(name string) resource.TestCheckFu
}
if resp.StatusCode == http.StatusNotFound {
return fmt.Errorf("Bad: Public IP %q (resource group: %q) does not exist", namespaceName, resourceGroup)
return fmt.Errorf("Bad: Service Bus Namespace %q (resource group: %q) does not exist", namespaceName, resourceGroup)
}
return nil

View File

@ -0,0 +1,58 @@
// Package eventhub implements the Azure ARM Eventhub service API version
// 2015-08-01.
//
// Azure EventHub client
package eventhub
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
)
const (
// APIVersion is the version of the Eventhub
APIVersion = "2015-08-01"
// DefaultBaseURI is the default URI used for the service Eventhub
DefaultBaseURI = "https://management.azure.com"
)
// ManagementClient is the base client for Eventhub.
type ManagementClient struct {
autorest.Client
BaseURI string
APIVersion string
SubscriptionID string
}
// New creates an instance of the ManagementClient client.
func New(subscriptionID string) ManagementClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the ManagementClient client.
func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID,
}
}

View File

@ -0,0 +1,340 @@
package eventhub
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// ConsumerGroupsClient is the azure EventHub client
type ConsumerGroupsClient struct {
ManagementClient
}
// NewConsumerGroupsClient creates an instance of the ConsumerGroupsClient
// client.
func NewConsumerGroupsClient(subscriptionID string) ConsumerGroupsClient {
return NewConsumerGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewConsumerGroupsClientWithBaseURI creates an instance of the
// ConsumerGroupsClient client.
func NewConsumerGroupsClientWithBaseURI(baseURI string, subscriptionID string) ConsumerGroupsClient {
return ConsumerGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate creates/Updates a consumer group as a nested resource within
// a namespace.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the EventHub name. consumerGroupName is
// the Consumer Group name. parameters is parameters supplied to create a
// Consumer Group Resource.
func (client ConsumerGroupsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string, parameters ConsumerGroupCreateOrUpdateParameters) (result ConsumerGroupResource, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", resp, "Failure sending request")
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client ConsumerGroupsClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string, parameters ConsumerGroupCreateOrUpdateParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"consumerGroupName": autorest.Encode("path", consumerGroupName),
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/consumergroups/{consumerGroupName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client ConsumerGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client ConsumerGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ConsumerGroupResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes an ConsumerGroup from the specified EventHub and resource
// group.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the EventHub name. consumerGroupName is
// the Consumer Group name.
func (client ConsumerGroupsClient) Delete(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", nil, "Failure preparing request")
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", resp, "Failure sending request")
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client ConsumerGroupsClient) DeletePreparer(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"consumerGroupName": autorest.Encode("path", consumerGroupName),
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/consumergroups/{consumerGroupName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client ConsumerGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client ConsumerGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Get returns an Consumer Group description for the specified Consumer Group.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the EventHub name. consumerGroupName is
// the Consumer Group name.
func (client ConsumerGroupsClient) Get(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (result ConsumerGroupResource, err error) {
req, err := client.GetPreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", nil, "Failure preparing request")
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", resp, "Failure sending request")
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client ConsumerGroupsClient) GetPreparer(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"consumerGroupName": autorest.Encode("path", consumerGroupName),
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/consumergroups/{consumerGroupName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client ConsumerGroupsClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client ConsumerGroupsClient) GetResponder(resp *http.Response) (result ConsumerGroupResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListAll enumerates the consumer groups in a namespace. An empty feed is
// returned if no consumer group exists in the namespace.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the EventHub name.
func (client ConsumerGroupsClient) ListAll(resourceGroupName string, namespaceName string, eventHubName string) (result ConsumerGroupListResult, err error) {
req, err := client.ListAllPreparer(resourceGroupName, namespaceName, eventHubName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", nil, "Failure preparing request")
}
resp, err := client.ListAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure sending request")
}
result, err = client.ListAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure responding to request")
}
return
}
// ListAllPreparer prepares the ListAll request.
func (client ConsumerGroupsClient) ListAllPreparer(resourceGroupName string, namespaceName string, eventHubName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/consumergroups", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListAllSender sends the ListAll request. The method will close the
// http.Response Body if it receives an error.
func (client ConsumerGroupsClient) ListAllSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListAllResponder handles the response to the ListAll request. The method always
// closes the http.Response Body.
func (client ConsumerGroupsClient) ListAllResponder(resp *http.Response) (result ConsumerGroupListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListAllNextResults retrieves the next set of results, if any.
func (client ConsumerGroupsClient) ListAllNextResults(lastResults ConsumerGroupListResult) (result ConsumerGroupListResult, err error) {
req, err := lastResults.ConsumerGroupListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure sending next results request")
}
result, err = client.ListAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure responding to next results request")
}
return
}

View File

@ -0,0 +1,764 @@
package eventhub
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// EventHubsClient is the azure EventHub client
type EventHubsClient struct {
ManagementClient
}
// NewEventHubsClient creates an instance of the EventHubsClient client.
func NewEventHubsClient(subscriptionID string) EventHubsClient {
return NewEventHubsClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewEventHubsClientWithBaseURI creates an instance of the EventHubsClient
// client.
func NewEventHubsClientWithBaseURI(baseURI string, subscriptionID string) EventHubsClient {
return EventHubsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate creates/Updates a new Event Hub as a nested resource within
// a namespace.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the EventHub name. parameters is
// parameters supplied to create a EventHub Resource.
func (client EventHubsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, eventHubName string, parameters CreateOrUpdateParameters) (result ResourceType, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, eventHubName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", nil, "Failure preparing request")
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", resp, "Failure sending request")
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client EventHubsClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, eventHubName string, parameters CreateOrUpdateParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client EventHubsClient) CreateOrUpdateResponder(resp *http.Response) (result ResourceType, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateOrUpdateAuthorizationRule creates an authorization rule for the
// specified Event Hub.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the Event Hub name. authorizationRuleName
// is aauthorization Rule Name. parameters is the shared access authorization
// rule.
func (client EventHubsClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Properties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule")
}
req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request")
}
resp, err := client.CreateOrUpdateAuthorizationRuleSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request")
}
result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure responding to request")
}
return
}
// CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request.
func (client EventHubsClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/authorizationRules/{authorizationRuleName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// CreateOrUpdateAuthorizationRuleSender sends the CreateOrUpdateAuthorizationRule request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) CreateOrUpdateAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always
// closes the http.Response Body.
func (client EventHubsClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes an Event hub from the specified namespace and resource group.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the EventHub name.
func (client EventHubsClient) Delete(resourceGroupName string, namespaceName string, eventHubName string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, namespaceName, eventHubName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", nil, "Failure preparing request")
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", resp, "Failure sending request")
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client EventHubsClient) DeletePreparer(resourceGroupName string, namespaceName string, eventHubName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client EventHubsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// DeleteAuthorizationRule deletes a EventHub authorization rule
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the Eventhub name. authorizationRuleName
// is authorization Rule Name.
func (client EventHubsClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result autorest.Response, err error) {
req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", nil, "Failure preparing request")
}
resp, err := client.DeleteAuthorizationRuleSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", resp, "Failure sending request")
}
result, err = client.DeleteAuthorizationRuleResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", resp, "Failure responding to request")
}
return
}
// DeleteAuthorizationRulePreparer prepares the DeleteAuthorizationRule request.
func (client EventHubsClient) DeleteAuthorizationRulePreparer(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/authorizationRules/{authorizationRuleName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteAuthorizationRuleSender sends the DeleteAuthorizationRule request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) DeleteAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteAuthorizationRuleResponder handles the response to the DeleteAuthorizationRule request. The method always
// closes the http.Response Body.
func (client EventHubsClient) DeleteAuthorizationRuleResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Get returns an Event Hub description for the specified Event Hub.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the EventHub name.
func (client EventHubsClient) Get(resourceGroupName string, namespaceName string, eventHubName string) (result ResourceType, err error) {
req, err := client.GetPreparer(resourceGroupName, namespaceName, eventHubName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", nil, "Failure preparing request")
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", resp, "Failure sending request")
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client EventHubsClient) GetPreparer(resourceGroupName string, namespaceName string, eventHubName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client EventHubsClient) GetResponder(resp *http.Response) (result ResourceType, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetAuthorizationRule authorization rule for a EventHub by name.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name eventHubName is the Event Hub name. authorizationRuleName
// is authorization rule name.
func (client EventHubsClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, err error) {
req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", nil, "Failure preparing request")
}
resp, err := client.GetAuthorizationRuleSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", resp, "Failure sending request")
}
result, err = client.GetAuthorizationRuleResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", resp, "Failure responding to request")
}
return
}
// GetAuthorizationRulePreparer prepares the GetAuthorizationRule request.
func (client EventHubsClient) GetAuthorizationRulePreparer(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/authorizationRules/{authorizationRuleName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetAuthorizationRuleSender sends the GetAuthorizationRule request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) GetAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always
// closes the http.Response Body.
func (client EventHubsClient) GetAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListAll enumerates the Event Hubs in a namespace.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name.
func (client EventHubsClient) ListAll(resourceGroupName string, namespaceName string) (result ListResult, err error) {
req, err := client.ListAllPreparer(resourceGroupName, namespaceName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", nil, "Failure preparing request")
}
resp, err := client.ListAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure sending request")
}
result, err = client.ListAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure responding to request")
}
return
}
// ListAllPreparer prepares the ListAll request.
func (client EventHubsClient) ListAllPreparer(resourceGroupName string, namespaceName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListAllSender sends the ListAll request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) ListAllSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListAllResponder handles the response to the ListAll request. The method always
// closes the http.Response Body.
func (client EventHubsClient) ListAllResponder(resp *http.Response) (result ListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListAllNextResults retrieves the next set of results, if any.
func (client EventHubsClient) ListAllNextResults(lastResults ListResult) (result ListResult, err error) {
req, err := lastResults.ListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure sending next results request")
}
result, err = client.ListAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure responding to next results request")
}
return
}
// ListAuthorizationRules authorization rules for a EventHub.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// NameSpace name eventHubName is the EventHub name.
func (client EventHubsClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, eventHubName string) (result SharedAccessAuthorizationRuleListResult, err error) {
req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName, eventHubName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", nil, "Failure preparing request")
}
resp, err := client.ListAuthorizationRulesSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure sending request")
}
result, err = client.ListAuthorizationRulesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure responding to request")
}
return
}
// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request.
func (client EventHubsClient) ListAuthorizationRulesPreparer(resourceGroupName string, namespaceName string, eventHubName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/authorizationRules", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always
// closes the http.Response Body.
func (client EventHubsClient) ListAuthorizationRulesResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListAuthorizationRulesNextResults retrieves the next set of results, if any.
func (client EventHubsClient) ListAuthorizationRulesNextResults(lastResults SharedAccessAuthorizationRuleListResult) (result SharedAccessAuthorizationRuleListResult, err error) {
req, err := lastResults.SharedAccessAuthorizationRuleListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListAuthorizationRulesSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure sending next results request")
}
result, err = client.ListAuthorizationRulesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure responding to next results request")
}
return
}
// ListKeys returns the ACS and SAS connection strings for the Event Hub.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the event hub name. authorizationRuleName
// is the connection string of the namespace for the specified
// authorizationRule.
func (client EventHubsClient) ListKeys(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result ResourceListKeys, err error) {
req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", nil, "Failure preparing request")
}
resp, err := client.ListKeysSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", resp, "Failure sending request")
}
result, err = client.ListKeysResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", resp, "Failure responding to request")
}
return
}
// ListKeysPreparer prepares the ListKeys request.
func (client EventHubsClient) ListKeysPreparer(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/authorizationRules/{authorizationRuleName}/ListKeys", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListKeysSender sends the ListKeys request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) ListKeysSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListKeysResponder handles the response to the ListKeys request. The method always
// closes the http.Response Body.
func (client EventHubsClient) ListKeysResponder(resp *http.Response) (result ResourceListKeys, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// RegenerateKeys regenerates the ACS and SAS connection strings for the Event
// Hub.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. eventHubName is the event hub name. authorizationRuleName
// is the connection string of the EventHub for the specified
// authorizationRule. parameters is parameters supplied to regenerate Auth
// Rule.
func (client EventHubsClient) RegenerateKeys(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, err error) {
req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", nil, "Failure preparing request")
}
resp, err := client.RegenerateKeysSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", resp, "Failure sending request")
}
result, err = client.RegenerateKeysResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", resp, "Failure responding to request")
}
return
}
// RegenerateKeysPreparer prepares the RegenerateKeys request.
func (client EventHubsClient) RegenerateKeysPreparer(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters RegenerateKeysParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"eventHubName": autorest.Encode("path", eventHubName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/authorizationRules/{authorizationRuleName}/regenerateKeys", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// RegenerateKeysSender sends the RegenerateKeys request. The method will close the
// http.Response Body if it receives an error.
func (client EventHubsClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always
// closes the http.Response Body.
func (client EventHubsClient) RegenerateKeysResponder(resp *http.Response) (result ResourceListKeys, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}

View File

@ -0,0 +1,366 @@
package eventhub
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/to"
"net/http"
)
// AccessRights enumerates the values for access rights.
type AccessRights string
const (
// Listen specifies the listen state for access rights.
Listen AccessRights = "Listen"
// Manage specifies the manage state for access rights.
Manage AccessRights = "Manage"
// Send specifies the send state for access rights.
Send AccessRights = "Send"
)
// EntityStatus enumerates the values for entity status.
type EntityStatus string
const (
// Active specifies the active state for entity status.
Active EntityStatus = "Active"
// Creating specifies the creating state for entity status.
Creating EntityStatus = "Creating"
// Deleting specifies the deleting state for entity status.
Deleting EntityStatus = "Deleting"
// Disabled specifies the disabled state for entity status.
Disabled EntityStatus = "Disabled"
// ReceiveDisabled specifies the receive disabled state for entity status.
ReceiveDisabled EntityStatus = "ReceiveDisabled"
// Renaming specifies the renaming state for entity status.
Renaming EntityStatus = "Renaming"
// Restoring specifies the restoring state for entity status.
Restoring EntityStatus = "Restoring"
// SendDisabled specifies the send disabled state for entity status.
SendDisabled EntityStatus = "SendDisabled"
// Unknown specifies the unknown state for entity status.
Unknown EntityStatus = "Unknown"
)
// NamespaceState enumerates the values for namespace state.
type NamespaceState string
const (
// NamespaceStateActivating specifies the namespace state activating state
// for namespace state.
NamespaceStateActivating NamespaceState = "Activating"
// NamespaceStateActive specifies the namespace state active state for
// namespace state.
NamespaceStateActive NamespaceState = "Active"
// NamespaceStateCreated specifies the namespace state created state for
// namespace state.
NamespaceStateCreated NamespaceState = "Created"
// NamespaceStateCreating specifies the namespace state creating state for
// namespace state.
NamespaceStateCreating NamespaceState = "Creating"
// NamespaceStateDisabled specifies the namespace state disabled state for
// namespace state.
NamespaceStateDisabled NamespaceState = "Disabled"
// NamespaceStateDisabling specifies the namespace state disabling state
// for namespace state.
NamespaceStateDisabling NamespaceState = "Disabling"
// NamespaceStateEnabling specifies the namespace state enabling state for
// namespace state.
NamespaceStateEnabling NamespaceState = "Enabling"
// NamespaceStateFailed specifies the namespace state failed state for
// namespace state.
NamespaceStateFailed NamespaceState = "Failed"
// NamespaceStateRemoved specifies the namespace state removed state for
// namespace state.
NamespaceStateRemoved NamespaceState = "Removed"
// NamespaceStateRemoving specifies the namespace state removing state for
// namespace state.
NamespaceStateRemoving NamespaceState = "Removing"
// NamespaceStateSoftDeleted specifies the namespace state soft deleted
// state for namespace state.
NamespaceStateSoftDeleted NamespaceState = "SoftDeleted"
// NamespaceStateSoftDeleting specifies the namespace state soft deleting
// state for namespace state.
NamespaceStateSoftDeleting NamespaceState = "SoftDeleting"
// NamespaceStateUnknown specifies the namespace state unknown state for
// namespace state.
NamespaceStateUnknown NamespaceState = "Unknown"
)
// Policykey enumerates the values for policykey.
type Policykey string
const (
// PrimaryKey specifies the primary key state for policykey.
PrimaryKey Policykey = "PrimaryKey"
// SecondaryKey specifies the secondary key state for policykey.
SecondaryKey Policykey = "SecondaryKey"
)
// SkuName enumerates the values for sku name.
type SkuName string
const (
// Basic specifies the basic state for sku name.
Basic SkuName = "Basic"
// Premium specifies the premium state for sku name.
Premium SkuName = "Premium"
// Standard specifies the standard state for sku name.
Standard SkuName = "Standard"
)
// SkuTier enumerates the values for sku tier.
type SkuTier string
const (
// SkuTierBasic specifies the sku tier basic state for sku tier.
SkuTierBasic SkuTier = "Basic"
// SkuTierPremium specifies the sku tier premium state for sku tier.
SkuTierPremium SkuTier = "Premium"
// SkuTierStandard specifies the sku tier standard state for sku tier.
SkuTierStandard SkuTier = "Standard"
)
// ConsumerGroupCreateOrUpdateParameters is parameters supplied to the
// CreateOrUpdate Consumer Group operation.
type ConsumerGroupCreateOrUpdateParameters struct {
Location *string `json:"location,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
Properties *ConsumerGroupProperties `json:"properties,omitempty"`
}
// ConsumerGroupListResult is the response of the List Consumer Group
// operation.
type ConsumerGroupListResult struct {
autorest.Response `json:"-"`
Value *[]ConsumerGroupResource `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// ConsumerGroupListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client ConsumerGroupListResult) ConsumerGroupListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// ConsumerGroupProperties is
type ConsumerGroupProperties struct {
CreatedAt *date.Time `json:"createdAt,omitempty"`
EventHubPath *string `json:"eventHubPath,omitempty"`
UpdatedAt *date.Time `json:"updatedAt,omitempty"`
UserMetadata *string `json:"userMetadata,omitempty"`
}
// ConsumerGroupResource is description of Consumer Group Resource.
type ConsumerGroupResource struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Properties *ConsumerGroupProperties `json:"properties,omitempty"`
}
// CreateOrUpdateParameters is parameters supplied to the CreateOrUpdate
// EventHub operation.
type CreateOrUpdateParameters struct {
Location *string `json:"location,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
Properties *Properties `json:"properties,omitempty"`
}
// ListResult is the response of the List EventHub operation.
type ListResult struct {
autorest.Response `json:"-"`
Value *[]ResourceType `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// ListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client ListResult) ListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// NamespaceCreateOrUpdateParameters is parameters supplied to the
// CreateOrUpdate Namespace operation.
type NamespaceCreateOrUpdateParameters struct {
Location *string `json:"location,omitempty"`
Sku *Sku `json:"sku,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Properties *NamespaceProperties `json:"properties,omitempty"`
}
// NamespaceListResult is the response of the List Namespace operation.
type NamespaceListResult struct {
autorest.Response `json:"-"`
Value *[]NamespaceResource `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// NamespaceListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client NamespaceListResult) NamespaceListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// NamespaceProperties is properties of the Namespace.
type NamespaceProperties struct {
ProvisioningState *string `json:"provisioningState,omitempty"`
Status NamespaceState `json:"status,omitempty"`
CreatedAt *date.Time `json:"createdAt,omitempty"`
UpdatedAt *date.Time `json:"updatedAt,omitempty"`
ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"`
CreateACSNamespace *bool `json:"createACSNamespace,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
// NamespaceResource is description of a Namespace resource.
type NamespaceResource struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Sku *Sku `json:"sku,omitempty"`
Properties *NamespaceProperties `json:"properties,omitempty"`
}
// Properties is
type Properties struct {
CreatedAt *date.Time `json:"createdAt,omitempty"`
MessageRetentionInDays *int64 `json:"messageRetentionInDays,omitempty"`
PartitionCount *int64 `json:"partitionCount,omitempty"`
PartitionIds *[]int32 `json:"partitionIds,omitempty"`
Status EntityStatus `json:"status,omitempty"`
UpdatedAt *date.Time `json:"updatedAt,omitempty"`
}
// RegenerateKeysParameters is parameters supplied to the Regenerate Auth Rule.
type RegenerateKeysParameters struct {
Policykey Policykey `json:"Policykey,omitempty"`
}
// Resource is
type Resource struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
}
// ResourceListKeys is namespace/EventHub Connection String
type ResourceListKeys struct {
autorest.Response `json:"-"`
PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"`
SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"`
PrimaryKey *string `json:"primaryKey,omitempty"`
SecondaryKey *string `json:"secondaryKey,omitempty"`
KeyName *string `json:"keyName,omitempty"`
}
// ResourceType is description of EventHub Resource.
type ResourceType struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Properties *Properties `json:"properties,omitempty"`
}
// SharedAccessAuthorizationRuleCreateOrUpdateParameters is parameters
// supplied to the CreateOrUpdate AuthorizationRules.
type SharedAccessAuthorizationRuleCreateOrUpdateParameters struct {
Location *string `json:"location,omitempty"`
Name *string `json:"name,omitempty"`
Properties *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"`
}
// SharedAccessAuthorizationRuleListResult is the response of the List
// Namespace operation.
type SharedAccessAuthorizationRuleListResult struct {
autorest.Response `json:"-"`
Value *[]SharedAccessAuthorizationRuleResource `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// SharedAccessAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client SharedAccessAuthorizationRuleListResult) SharedAccessAuthorizationRuleListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// SharedAccessAuthorizationRuleProperties is sharedAccessAuthorizationRule
// properties.
type SharedAccessAuthorizationRuleProperties struct {
Rights *[]AccessRights `json:"rights,omitempty"`
}
// SharedAccessAuthorizationRuleResource is description of a Namespace
// AuthorizationRules.
type SharedAccessAuthorizationRuleResource struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Properties *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"`
}
// Sku is sku of the Namespace.
type Sku struct {
Name SkuName `json:"name,omitempty"`
Tier SkuTier `json:"tier,omitempty"`
Capacity *int32 `json:"capacity,omitempty"`
}

View File

@ -0,0 +1,839 @@
package eventhub
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// NamespacesClient is the azure EventHub client
type NamespacesClient struct {
ManagementClient
}
// NewNamespacesClient creates an instance of the NamespacesClient client.
func NewNamespacesClient(subscriptionID string) NamespacesClient {
return NewNamespacesClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewNamespacesClientWithBaseURI creates an instance of the NamespacesClient
// client.
func NewNamespacesClientWithBaseURI(baseURI string, subscriptionID string) NamespacesClient {
return NamespacesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate creates Updates namespace. Once created, this namespace's
// resource manifest is immutable. This operation is idempotent. This method
// may poll for completion. Polling can be canceled by passing the cancel
// channel argument. The channel will be used to cancel polling and any
// outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. parameters is parameters supplied to create a Namespace
// Resource.
func (client NamespacesClient) CreateOrUpdate(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request")
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure sending request")
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client NamespacesClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client NamespacesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// CreateOrUpdateAuthorizationRule creates an authorization rule for a
// namespace
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. authorizationRuleName is namespace Aauthorization Rule
// Name. parameters is the shared access authorization rule.
func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Properties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule")
}
req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request")
}
resp, err := client.CreateOrUpdateAuthorizationRuleSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request")
}
result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure responding to request")
}
return
}
// CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request.
func (client NamespacesClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// CreateOrUpdateAuthorizationRuleSender sends the CreateOrUpdateAuthorizationRule request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) CreateOrUpdateAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always
// closes the http.Response Body.
func (client NamespacesClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes an existing namespace. This operation also removes all
// associated resources under the namespace. This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name.
func (client NamespacesClient) Delete(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, namespaceName, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", nil, "Failure preparing request")
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure sending request")
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client NamespacesClient) DeletePreparer(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client NamespacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
// DeleteAuthorizationRule deletes a namespace authorization rule
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. authorizationRuleName is authorization Rule Name.
func (client NamespacesClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string) (result autorest.Response, err error) {
req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request")
}
resp, err := client.DeleteAuthorizationRuleSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure sending request")
}
result, err = client.DeleteAuthorizationRuleResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure responding to request")
}
return
}
// DeleteAuthorizationRulePreparer prepares the DeleteAuthorizationRule request.
func (client NamespacesClient) DeleteAuthorizationRulePreparer(resourceGroupName string, namespaceName string, authorizationRuleName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteAuthorizationRuleSender sends the DeleteAuthorizationRule request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) DeleteAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteAuthorizationRuleResponder handles the response to the DeleteAuthorizationRule request. The method always
// closes the http.Response Body.
func (client NamespacesClient) DeleteAuthorizationRuleResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Get returns the description for the specified namespace.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name.
func (client NamespacesClient) Get(resourceGroupName string, namespaceName string) (result NamespaceResource, err error) {
req, err := client.GetPreparer(resourceGroupName, namespaceName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", nil, "Failure preparing request")
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", resp, "Failure sending request")
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client NamespacesClient) GetPreparer(resourceGroupName string, namespaceName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client NamespacesClient) GetResponder(resp *http.Response) (result NamespaceResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetAuthorizationRule authorization rule for a namespace by name.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name authorizationRuleName is authorization rule name.
func (client NamespacesClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, err error) {
req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request")
}
resp, err := client.GetAuthorizationRuleSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", resp, "Failure sending request")
}
result, err = client.GetAuthorizationRuleResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", resp, "Failure responding to request")
}
return
}
// GetAuthorizationRulePreparer prepares the GetAuthorizationRule request.
func (client NamespacesClient) GetAuthorizationRulePreparer(resourceGroupName string, namespaceName string, authorizationRuleName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetAuthorizationRuleSender sends the GetAuthorizationRule request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) GetAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always
// closes the http.Response Body.
func (client NamespacesClient) GetAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListAuthorizationRules authorization rules for a namespace.
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name
func (client NamespacesClient) ListAuthorizationRules(resourceGroupName string, namespaceName string) (result SharedAccessAuthorizationRuleListResult, err error) {
req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request")
}
resp, err := client.ListAuthorizationRulesSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending request")
}
result, err = client.ListAuthorizationRulesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure responding to request")
}
return
}
// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request.
func (client NamespacesClient) ListAuthorizationRulesPreparer(resourceGroupName string, namespaceName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always
// closes the http.Response Body.
func (client NamespacesClient) ListAuthorizationRulesResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListAuthorizationRulesNextResults retrieves the next set of results, if any.
func (client NamespacesClient) ListAuthorizationRulesNextResults(lastResults SharedAccessAuthorizationRuleListResult) (result SharedAccessAuthorizationRuleListResult, err error) {
req, err := lastResults.SharedAccessAuthorizationRuleListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListAuthorizationRulesSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending next results request")
}
result, err = client.ListAuthorizationRulesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure responding to next results request")
}
return
}
// ListByResourceGroup lists the available namespaces within a resourceGroup.
//
// resourceGroupName is the name of the resource group.
func (client NamespacesClient) ListByResourceGroup(resourceGroupName string) (result NamespaceListResult, err error) {
req, err := client.ListByResourceGroupPreparer(resourceGroupName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request")
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure sending request")
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure responding to request")
}
return
}
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
func (client NamespacesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
// closes the http.Response Body.
func (client NamespacesClient) ListByResourceGroupResponder(resp *http.Response) (result NamespaceListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListByResourceGroupNextResults retrieves the next set of results, if any.
func (client NamespacesClient) ListByResourceGroupNextResults(lastResults NamespaceListResult) (result NamespaceListResult, err error) {
req, err := lastResults.NamespaceListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure sending next results request")
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure responding to next results request")
}
return
}
// ListBySubscription lists all the available namespaces within the
// subscription irrespective of the resourceGroups.
func (client NamespacesClient) ListBySubscription() (result NamespaceListResult, err error) {
req, err := client.ListBySubscriptionPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", nil, "Failure preparing request")
}
resp, err := client.ListBySubscriptionSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure sending request")
}
result, err = client.ListBySubscriptionResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure responding to request")
}
return
}
// ListBySubscriptionPreparer prepares the ListBySubscription request.
func (client NamespacesClient) ListBySubscriptionPreparer() (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventHub/namespaces", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
// closes the http.Response Body.
func (client NamespacesClient) ListBySubscriptionResponder(resp *http.Response) (result NamespaceListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListBySubscriptionNextResults retrieves the next set of results, if any.
func (client NamespacesClient) ListBySubscriptionNextResults(lastResults NamespaceListResult) (result NamespaceListResult, err error) {
req, err := lastResults.NamespaceListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListBySubscriptionSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure sending next results request")
}
result, err = client.ListBySubscriptionResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure responding to next results request")
}
return
}
// ListKeys primary and Secondary ConnectionStrings to the namespace
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. authorizationRuleName is the authorizationRule name.
func (client NamespacesClient) ListKeys(resourceGroupName string, namespaceName string, authorizationRuleName string) (result ResourceListKeys, err error) {
req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, authorizationRuleName)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", nil, "Failure preparing request")
}
resp, err := client.ListKeysSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", resp, "Failure sending request")
}
result, err = client.ListKeysResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", resp, "Failure responding to request")
}
return
}
// ListKeysPreparer prepares the ListKeys request.
func (client NamespacesClient) ListKeysPreparer(resourceGroupName string, namespaceName string, authorizationRuleName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListKeysSender sends the ListKeys request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) ListKeysSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListKeysResponder handles the response to the ListKeys request. The method always
// closes the http.Response Body.
func (client NamespacesClient) ListKeysResponder(resp *http.Response) (result ResourceListKeys, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// RegenerateKeys regenerats the Primary or Secondary ConnectionStrings to the
// namespace
//
// resourceGroupName is the name of the resource group. namespaceName is the
// namespace name. authorizationRuleName is the authorizationRule name.
// parameters is parameters supplied to regenerate Auth Rule.
func (client NamespacesClient) RegenerateKeys(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, err error) {
req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, authorizationRuleName, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request")
}
resp, err := client.RegenerateKeysSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", resp, "Failure sending request")
}
result, err = client.RegenerateKeysResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", resp, "Failure responding to request")
}
return
}
// RegenerateKeysPreparer prepares the RegenerateKeys request.
func (client NamespacesClient) RegenerateKeysPreparer(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters RegenerateKeysParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
"namespaceName": autorest.Encode("path", namespaceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// RegenerateKeysSender sends the RegenerateKeys request. The method will close the
// http.Response Body if it receives an error.
func (client NamespacesClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always
// closes the http.Response Body.
func (client NamespacesClient) RegenerateKeysResponder(resp *http.Response) (result ResourceListKeys, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}

View File

@ -0,0 +1,43 @@
package eventhub
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"fmt"
)
const (
major = "5"
minor = "0"
patch = "0"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
)
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "eventhub", "2015-08-01")
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag)
}

16
vendor/vendor.json vendored
View File

@ -21,10 +21,22 @@
"versionExact": "v5.0.0-beta"
},
{
"checksumSHA1": "twJBMkI9NiMeQbPFmw4ehZQAPaE=",
"checksumSHA1": "ndoTo9HTATazQPZiPzq5rFYJhHM=",
"comment": "v2.1.1-beta-8-gca4d906",
"path": "github.com/Azure/azure-sdk-for-go/arm/eventhub",
"revision": "91f3d4a4d024e3c0d4d9412916d05cf84504a616",
"revisionTime": "2016-10-05T01:22:46Z",
"version": "v5.0.0-beta",
"versionExact": "v5.0.0-beta"
},
{
"checksumSHA1": "ndoTo9HTATazQPZiPzq5rFYJhHM=",
"comment": "v2.1.1-beta-8-gca4d906",
"path": "github.com/Azure/azure-sdk-for-go/arm/keyvault",
"revision": "91f3d4a4d024e3c0d4d9412916d05cf84504a616",
"revisionTime": "2016-10-05T01:22:46Z"
"revisionTime": "2016-10-05T01:22:46Z",
"version": "v5.0.0-beta",
"versionExact": "v5.0.0-beta"
},
{
"checksumSHA1": "33Eny6aOVU6MjMYlfzufuo9OdCk=",

View File

@ -0,0 +1,69 @@
---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_eventhub_namespace"
sidebar_current: "docs-azurerm-resource-eventhub-namespace"
description: |-
Create an EventHub Namespace.
---
# azurerm\_eventhub\_namespace
Create an EventHub Namespace.
## Example Usage
```
resource "azurerm_resource_group" "test" {
name = "resourceGroup1"
location = "West US"
}
resource "azurerm_eventhub_namespace" "test" {
name = "acceptanceTestEventHubNamespace"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Basic"
capacity = 2
tags {
environment = "Production"
}
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) Specifies the name of the EventHub Namespace resource . Changing this forces a
new resource to be created.
* `resource_group_name` - (Required) The name of the resource group in which to
create the namespace.
* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
* `sku` - (Required) Defines which tier to use. Options are basic or standard.
* `capacity` - (Optional) Specifies the capacity of a premium namespace. Can be 1, 2 or 4
* `tags` - (Optional) A mapping of tags to assign to the resource.
## Attributes Reference
The following attributes are exported:
* `id` - The EventHub Namespace ID.
The following attributes are exported only if there is an authorization rule named
`RootManageSharedAccessKey` which is created automatically by Azure.
* `default_primary_connection_string` - The primary connection string for the authorization
rule `RootManageSharedAccessKey`.
* `default_secondary_connection_string` - The secondary connection string for the
authorization rule `RootManageSharedAccessKey`.
* `default_primary_key` - The primary access key for the authorization rule `RootManageSharedAccessKey`.
* `default_secondary_key` - The secondary access key for the authorization rule `RootManageSharedAccessKey`.

View File

@ -83,6 +83,16 @@
</ul>
</li>
<li<%= sidebar_current(/^docs-azurerm-resource-eventhub/) %>>
<a href="#">Event Hubs</a>
<ul class="nav nav-visible">
<li<%= sidebar_current("docs-azurerm-resource-eventhub-namespace") %>>
<a href="/docs/providers/azurerm/r/eventhub_namespace.html">azurerm_eventhub_namespace</a>
</li>
</ul>
</li>
<li<%= sidebar_current(/^docs-azurerm-resource-key-vault/) %>>
<a href="#">Key Vault Resources</a>
<ul class="nav nav-visible">
@ -90,7 +100,6 @@
<li<%= sidebar_current("docs-azurerm-resource-key-vault") %>>
<a href="/docs/providers/azurerm/r/key_vault.html">azurerm_key_vault</a>
</li>
</ul>
</li>
@ -224,7 +233,7 @@
</ul>
</li>
<li<%= sidebar_current(/^docs-azurerm-resource-storage/) %>>
<a href="#">Storage Resources</a>
<ul class="nav nav-visible">