Skip to content

Commit

Permalink
refreshing the provider for build (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
code-lucidal58 authored Dec 22, 2020
1 parent ad5778d commit 090ec4e
Show file tree
Hide file tree
Showing 14,830 changed files with 997,914 additions and 646,168 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
10 changes: 4 additions & 6 deletions intersight/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"log"
"net/http"
"net/http/httptrace"
"os"
"time"

gosdk "github.com/CiscoDevNet/terraform-provider-intersight/intersight_gosdk"
Expand All @@ -38,7 +37,7 @@ type Client struct {
skipTlsVerification bool
}

func (c *Client) SetInputs(apiKeyId, apiKeyFile, hostName string, ignoreTls bool) context.Context {
func (c *Client) SetInputs(apiKeyId, apiKeyFile, hostName string, ignoreTls bool) (context.Context, error) {
c.hostname = hostName
c.skipTlsVerification = ignoreTls

Expand All @@ -47,13 +46,12 @@ func (c *Client) SetInputs(apiKeyId, apiKeyFile, hostName string, ignoreTls bool
if apiKeyId != "" {
ctx, err = c.getHttpSignatureContext(ctx, apiKeyId, apiKeyFile)
if err != nil {
log.Fatalf("Failed to get signature context: %v", err)
return nil, fmt.Errorf("failed to get signature context: %v", err.Error())
}
} else {
fmt.Printf("Missing API Key and ID. Please specify API Key and for authentication\n")
os.Exit(2)
return nil, fmt.Errorf("missing API key and ID, required for authentication")
}
return ctx
return ctx, nil
}

func newTransport(t http.RoundTripper) *transport {
Expand Down
66 changes: 34 additions & 32 deletions intersight/data_source_intersight_aaa_audit_record.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package intersight

import (
"context"
"encoding/json"
"fmt"
"log"
"reflect"
"time"

models "github.com/CiscoDevNet/terraform-provider-intersight/intersight_gosdk"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAaaAuditRecord() *schema.Resource {
return &schema.Resource{
Read: dataSourceAaaAuditRecordRead,
ReadContext: dataSourceAaaAuditRecordRead,
Schema: map[string]*schema.Schema{
"account": {
Description: "A reference to a iamAccount resource.\nWhen the $expand query parameter is specified, the referenced resource is returned inline.",
Expand Down Expand Up @@ -246,10 +247,11 @@ func dataSourceAaaAuditRecord() *schema.Resource {
}
}

func dataSourceAaaAuditRecordRead(d *schema.ResourceData, meta interface{}) error {
func dataSourceAaaAuditRecordRead(c context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
log.SetFlags(log.LstdFlags | log.Lshortfile)
log.Printf("%v", meta)
conn := meta.(*Config)
var de diag.Diagnostics
var o = &models.AaaAuditRecord{}
if v, ok := d.GetOk("class_id"); ok {
x := (v.(string))
Expand Down Expand Up @@ -306,25 +308,25 @@ func dataSourceAaaAuditRecordRead(d *schema.ResourceData, meta interface{}) erro

data, err := o.MarshalJSON()
if err != nil {
return fmt.Errorf("Json Marshalling of data source failed with error : %+v", err)
return diag.Errorf("json marshal of AaaAuditRecord object failed with error : %s", err.Error())
}
res, _, err := conn.ApiClient.AaaApi.GetAaaAuditRecordList(conn.ctx).Filter(getRequestParams(data)).Execute()
if err != nil {
return fmt.Errorf("error occurred while sending request %+v", err)
resMo, _, responseErr := conn.ApiClient.AaaApi.GetAaaAuditRecordList(conn.ctx).Filter(getRequestParams(data)).Execute()
if responseErr.Error() != "" {
return diag.Errorf("error occurred while fetching AaaAuditRecord: %s Response from endpoint: %s", responseErr.Error(), string(responseErr.Body()))
}

x, err := res.MarshalJSON()
x, err := resMo.MarshalJSON()
if err != nil {
return fmt.Errorf("error occurred while marshalling response: %+v", err)
return diag.Errorf("error occurred while marshalling response for AaaAuditRecord list: %s", err.Error())
}
var s = &models.AaaAuditRecordList{}
err = json.Unmarshal(x, s)
if err != nil {
return fmt.Errorf("error occurred while unmarshalling response to AaaAuditRecord: %+v", err)
return diag.Errorf("error occurred while unmarshalling response to AaaAuditRecord list: %s", err.Error())
}
result := s.GetResults()
if result == nil {
return fmt.Errorf("your query returned no results. Please change your search criteria and try again")
return diag.Errorf("your query for AaaAuditRecord did not return results. Please change your search criteria and try again")
}
switch reflect.TypeOf(result).Kind() {
case reflect.Slice:
Expand All @@ -333,69 +335,69 @@ func dataSourceAaaAuditRecordRead(d *schema.ResourceData, meta interface{}) erro
var s = &models.AaaAuditRecord{}
oo, _ := json.Marshal(r.Index(i).Interface())
if err = json.Unmarshal(oo, s); err != nil {
return fmt.Errorf("error occurred while unmarshalling result at index %+v: %+v", i, err)
return diag.Errorf("error occurred while unmarshalling result at index %+v: %s", i, err.Error())
}

if err := d.Set("account", flattenMapIamAccountRelationship(s.GetAccount(), d)); err != nil {
return fmt.Errorf("error occurred while setting property Account: %+v", err)
return diag.Errorf("error occurred while setting property Account: %s", err.Error())
}
if err := d.Set("additional_properties", flattenAdditionalProperties(s.AdditionalProperties)); err != nil {
return fmt.Errorf("error occurred while setting property AdditionalProperties: %+v", err)
return diag.Errorf("error occurred while setting property AdditionalProperties: %s", err.Error())
}
if err := d.Set("class_id", (s.GetClassId())); err != nil {
return fmt.Errorf("error occurred while setting property ClassId: %+v", err)
return diag.Errorf("error occurred while setting property ClassId: %s", err.Error())
}
if err := d.Set("email", (s.GetEmail())); err != nil {
return fmt.Errorf("error occurred while setting property Email: %+v", err)
return diag.Errorf("error occurred while setting property Email: %s", err.Error())
}
if err := d.Set("event", (s.GetEvent())); err != nil {
return fmt.Errorf("error occurred while setting property Event: %+v", err)
return diag.Errorf("error occurred while setting property Event: %s", err.Error())
}
if err := d.Set("inst_id", (s.GetInstId())); err != nil {
return fmt.Errorf("error occurred while setting property InstId: %+v", err)
return diag.Errorf("error occurred while setting property InstId: %s", err.Error())
}
if err := d.Set("mo_type", (s.GetMoType())); err != nil {
return fmt.Errorf("error occurred while setting property MoType: %+v", err)
return diag.Errorf("error occurred while setting property MoType: %s", err.Error())
}
if err := d.Set("moid", (s.GetMoid())); err != nil {
return fmt.Errorf("error occurred while setting property Moid: %+v", err)
return diag.Errorf("error occurred while setting property Moid: %s", err.Error())
}
if err := d.Set("object_moid", (s.GetObjectMoid())); err != nil {
return fmt.Errorf("error occurred while setting property ObjectMoid: %+v", err)
return diag.Errorf("error occurred while setting property ObjectMoid: %s", err.Error())
}
if err := d.Set("object_type", (s.GetObjectType())); err != nil {
return fmt.Errorf("error occurred while setting property ObjectType: %+v", err)
return diag.Errorf("error occurred while setting property ObjectType: %s", err.Error())
}
if err := d.Set("session_id", (s.GetSessionId())); err != nil {
return fmt.Errorf("error occurred while setting property SessionId: %+v", err)
return diag.Errorf("error occurred while setting property SessionId: %s", err.Error())
}

if err := d.Set("sessions", flattenMapIamSessionRelationship(s.GetSessions(), d)); err != nil {
return fmt.Errorf("error occurred while setting property Sessions: %+v", err)
return diag.Errorf("error occurred while setting property Sessions: %s", err.Error())
}
if err := d.Set("source_ip", (s.GetSourceIp())); err != nil {
return fmt.Errorf("error occurred while setting property SourceIp: %+v", err)
return diag.Errorf("error occurred while setting property SourceIp: %s", err.Error())
}

if err := d.Set("tags", flattenListMoTag(s.GetTags(), d)); err != nil {
return fmt.Errorf("error occurred while setting property Tags: %+v", err)
return diag.Errorf("error occurred while setting property Tags: %s", err.Error())
}

if err := d.Set("timestamp", (s.GetTimestamp()).String()); err != nil {
return fmt.Errorf("error occurred while setting property Timestamp: %+v", err)
return diag.Errorf("error occurred while setting property Timestamp: %s", err.Error())
}
if err := d.Set("trace_id", (s.GetTraceId())); err != nil {
return fmt.Errorf("error occurred while setting property TraceId: %+v", err)
return diag.Errorf("error occurred while setting property TraceId: %s", err.Error())
}

if err := d.Set("user", flattenMapIamUserRelationship(s.GetUser(), d)); err != nil {
return fmt.Errorf("error occurred while setting property User: %+v", err)
return diag.Errorf("error occurred while setting property User: %s", err.Error())
}
if err := d.Set("user_id_or_email", (s.GetUserIdOrEmail())); err != nil {
return fmt.Errorf("error occurred while setting property UserIdOrEmail: %+v", err)
return diag.Errorf("error occurred while setting property UserIdOrEmail: %s", err.Error())
}
d.SetId(s.GetMoid())
}
}
return nil
return de
}
56 changes: 29 additions & 27 deletions intersight/data_source_intersight_access_policy.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package intersight

import (
"context"
"encoding/json"
"fmt"
"log"
"reflect"

models "github.com/CiscoDevNet/terraform-provider-intersight/intersight_gosdk"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAccessPolicy() *schema.Resource {
return &schema.Resource{
Read: dataSourceAccessPolicyRead,
ReadContext: dataSourceAccessPolicyRead,
Schema: map[string]*schema.Schema{
"additional_properties": {
Type: schema.TypeString,
Expand Down Expand Up @@ -270,10 +271,11 @@ func dataSourceAccessPolicy() *schema.Resource {
}
}

func dataSourceAccessPolicyRead(d *schema.ResourceData, meta interface{}) error {
func dataSourceAccessPolicyRead(c context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
log.SetFlags(log.LstdFlags | log.Lshortfile)
log.Printf("%v", meta)
conn := meta.(*Config)
var de diag.Diagnostics
var o = &models.AccessPolicy{}
if v, ok := d.GetOk("class_id"); ok {
x := (v.(string))
Expand Down Expand Up @@ -302,25 +304,25 @@ func dataSourceAccessPolicyRead(d *schema.ResourceData, meta interface{}) error

data, err := o.MarshalJSON()
if err != nil {
return fmt.Errorf("Json Marshalling of data source failed with error : %+v", err)
return diag.Errorf("json marshal of AccessPolicy object failed with error : %s", err.Error())
}
res, _, err := conn.ApiClient.AccessApi.GetAccessPolicyList(conn.ctx).Filter(getRequestParams(data)).Execute()
if err != nil {
return fmt.Errorf("error occurred while sending request %+v", err)
resMo, _, responseErr := conn.ApiClient.AccessApi.GetAccessPolicyList(conn.ctx).Filter(getRequestParams(data)).Execute()
if responseErr.Error() != "" {
return diag.Errorf("error occurred while fetching AccessPolicy: %s Response from endpoint: %s", responseErr.Error(), string(responseErr.Body()))
}

x, err := res.MarshalJSON()
x, err := resMo.MarshalJSON()
if err != nil {
return fmt.Errorf("error occurred while marshalling response: %+v", err)
return diag.Errorf("error occurred while marshalling response for AccessPolicy list: %s", err.Error())
}
var s = &models.AccessPolicyList{}
err = json.Unmarshal(x, s)
if err != nil {
return fmt.Errorf("error occurred while unmarshalling response to AccessPolicy: %+v", err)
return diag.Errorf("error occurred while unmarshalling response to AccessPolicy list: %s", err.Error())
}
result := s.GetResults()
if result == nil {
return fmt.Errorf("your query returned no results. Please change your search criteria and try again")
return diag.Errorf("your query for AccessPolicy did not return results. Please change your search criteria and try again")
}
switch reflect.TypeOf(result).Kind() {
case reflect.Slice:
Expand All @@ -329,55 +331,55 @@ func dataSourceAccessPolicyRead(d *schema.ResourceData, meta interface{}) error
var s = &models.AccessPolicy{}
oo, _ := json.Marshal(r.Index(i).Interface())
if err = json.Unmarshal(oo, s); err != nil {
return fmt.Errorf("error occurred while unmarshalling result at index %+v: %+v", i, err)
return diag.Errorf("error occurred while unmarshalling result at index %+v: %s", i, err.Error())
}
if err := d.Set("additional_properties", flattenAdditionalProperties(s.AdditionalProperties)); err != nil {
return fmt.Errorf("error occurred while setting property AdditionalProperties: %+v", err)
return diag.Errorf("error occurred while setting property AdditionalProperties: %s", err.Error())
}

if err := d.Set("address_type", flattenMapAccessAddressType(s.GetAddressType(), d)); err != nil {
return fmt.Errorf("error occurred while setting property AddressType: %+v", err)
return diag.Errorf("error occurred while setting property AddressType: %s", err.Error())
}
if err := d.Set("class_id", (s.GetClassId())); err != nil {
return fmt.Errorf("error occurred while setting property ClassId: %+v", err)
return diag.Errorf("error occurred while setting property ClassId: %s", err.Error())
}
if err := d.Set("description", (s.GetDescription())); err != nil {
return fmt.Errorf("error occurred while setting property Description: %+v", err)
return diag.Errorf("error occurred while setting property Description: %s", err.Error())
}

if err := d.Set("inband_ip_pool", flattenMapIppoolPoolRelationship(s.GetInbandIpPool(), d)); err != nil {
return fmt.Errorf("error occurred while setting property InbandIpPool: %+v", err)
return diag.Errorf("error occurred while setting property InbandIpPool: %s", err.Error())
}
if err := d.Set("inband_vlan", (s.GetInbandVlan())); err != nil {
return fmt.Errorf("error occurred while setting property InbandVlan: %+v", err)
return diag.Errorf("error occurred while setting property InbandVlan: %s", err.Error())
}

if err := d.Set("inband_vrf", flattenMapVrfVrfRelationship(s.GetInbandVrf(), d)); err != nil {
return fmt.Errorf("error occurred while setting property InbandVrf: %+v", err)
return diag.Errorf("error occurred while setting property InbandVrf: %s", err.Error())
}
if err := d.Set("moid", (s.GetMoid())); err != nil {
return fmt.Errorf("error occurred while setting property Moid: %+v", err)
return diag.Errorf("error occurred while setting property Moid: %s", err.Error())
}
if err := d.Set("name", (s.GetName())); err != nil {
return fmt.Errorf("error occurred while setting property Name: %+v", err)
return diag.Errorf("error occurred while setting property Name: %s", err.Error())
}
if err := d.Set("object_type", (s.GetObjectType())); err != nil {
return fmt.Errorf("error occurred while setting property ObjectType: %+v", err)
return diag.Errorf("error occurred while setting property ObjectType: %s", err.Error())
}

if err := d.Set("organization", flattenMapOrganizationOrganizationRelationship(s.GetOrganization(), d)); err != nil {
return fmt.Errorf("error occurred while setting property Organization: %+v", err)
return diag.Errorf("error occurred while setting property Organization: %s", err.Error())
}

if err := d.Set("profiles", flattenListPolicyAbstractConfigProfileRelationship(s.GetProfiles(), d)); err != nil {
return fmt.Errorf("error occurred while setting property Profiles: %+v", err)
return diag.Errorf("error occurred while setting property Profiles: %s", err.Error())
}

if err := d.Set("tags", flattenListMoTag(s.GetTags(), d)); err != nil {
return fmt.Errorf("error occurred while setting property Tags: %+v", err)
return diag.Errorf("error occurred while setting property Tags: %s", err.Error())
}
d.SetId(s.GetMoid())
}
}
return nil
return de
}
Loading

0 comments on commit 090ec4e

Please sign in to comment.