Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto PR: Regenerating the Go SDK (700e1e42bb09459d874bbffd75c20f631e800248) #564

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 19 additions & 11 deletions resource-manager/deviceprovisioningservices/2022-02-05/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,34 @@ package v2022_02_05
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

import (
"github.com/Azure/go-autorest/autorest"
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate"
"github.com/hashicorp/go-azure-sdk/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"github.com/hashicorp/go-azure-sdk/sdk/environments"
)

type Client struct {
DpsCertificate *dpscertificate.DpsCertificateClient
IotDpsResource *iotdpsresource.IotDpsResourceClient
}

func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client {

dpsCertificateClient := dpscertificate.NewDpsCertificateClientWithBaseURI(endpoint)
configureAuthFunc(&dpsCertificateClient.Client)

iotDpsResourceClient := iotdpsresource.NewIotDpsResourceClientWithBaseURI(endpoint)
configureAuthFunc(&iotDpsResourceClient.Client)
func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) {
dpsCertificateClient, err := dpscertificate.NewDpsCertificateClientWithBaseURI(api)
if err != nil {
return nil, fmt.Errorf("building DpsCertificate client: %+v", err)
}
configureFunc(dpsCertificateClient.Client)

return Client{
DpsCertificate: &dpsCertificateClient,
IotDpsResource: &iotDpsResourceClient,
iotDpsResourceClient, err := iotdpsresource.NewIotDpsResourceClientWithBaseURI(api)
if err != nil {
return nil, fmt.Errorf("building IotDpsResource client: %+v", err)
}
configureFunc(iotDpsResourceClient.Client)

return &Client{
DpsCertificate: dpsCertificateClient,
IotDpsResource: iotDpsResourceClient,
}, nil
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package dpscertificate

import "github.com/Azure/go-autorest/autorest"
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"github.com/hashicorp/go-azure-sdk/sdk/environments"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type DpsCertificateClient struct {
Client autorest.Client
baseUri string
Client *resourcemanager.Client
}

func NewDpsCertificateClientWithBaseURI(endpoint string) DpsCertificateClient {
return DpsCertificateClient{
Client: autorest.NewClientWithUserAgent(userAgent()),
baseUri: endpoint,
func NewDpsCertificateClientWithBaseURI(api environments.Api) (*DpsCertificateClient, error) {
client, err := resourcemanager.NewResourceManagerClient(api, "dpscertificate", defaultApiVersion)
if err != nil {
return nil, fmt.Errorf("instantiating DpsCertificateClient: %+v", err)
}

return &DpsCertificateClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package dpscertificate

import "strings"
import (
"encoding/json"
"fmt"
"strings"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
Expand All @@ -19,6 +23,19 @@ func PossibleValuesForCertificatePurpose() []string {
}
}

func (s *CertificatePurpose) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseCertificatePurpose(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseCertificatePurpose(input string) (*CertificatePurpose, error) {
vals := map[string]CertificatePurpose{
"clientauthentication": CertificatePurposeClientAuthentication,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package dpscertificate

import (
"context"
"fmt"
"net/http"

"github.com/hashicorp/go-azure-sdk/sdk/client"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type CreateOrUpdateOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *CertificateResponse
}

type CreateOrUpdateOperationOptions struct {
IfMatch *string
}

func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions {
return CreateOrUpdateOperationOptions{}
}

func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers {
out := client.Headers{}
if o.IfMatch != nil {
out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch))
}
return &out
}

func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query {
out := odata.Query{}
return &out
}

func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams {
out := client.QueryParams{}

return &out
}

// CreateOrUpdate ...
func (c DpsCertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateResponse, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json",
ExpectedStatusCodes: []int{
http.StatusOK,
},
HttpMethod: http.MethodPut,
Path: id.ID(),
OptionsObject: options,
}

req, err := c.Client.NewRequest(ctx, opts)
if err != nil {
return
}

if err = req.Marshal(input); err != nil {
return
}

var resp *client.Response
resp, err = req.Execute(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
}
if err != nil {
return
}

if err = resp.Unmarshal(&result.Model); err != nil {
return
}

return
}

This file was deleted.

Loading