1
- using Azure . Analytics . Synapse . Artifacts . Models ;
2
- using Microsoft . Azure . Commands . Common . Exceptions ;
1
+ using Microsoft . Azure . Commands . Common . Exceptions ;
3
2
using Microsoft . Azure . Commands . ResourceManager . Common . ArgumentCompleters ;
4
3
using Microsoft . Azure . Commands . Synapse . Common ;
5
4
using Microsoft . Azure . Commands . Synapse . Models ;
10
9
11
10
namespace Microsoft . Azure . Commands . Synapse
12
11
{
13
- [ Cmdlet ( VerbsCommon . Set , ResourceManager . Common . AzureRMConstants . AzureRMPrefix + SynapseConstants . SynapsePrefix + SynapseConstants . SqlScript ,
12
+ [ Cmdlet ( VerbsCommon . Set , ResourceManager . Common . AzureRMConstants . AzureRMPrefix + SynapseConstants . SynapsePrefix + SynapseConstants . SparkJobDefinition ,
14
13
DefaultParameterSetName = SetByName , SupportsShouldProcess = true ) ]
15
- [ Alias ( "New-" + ResourceManager . Common . AzureRMConstants . AzureRMPrefix + SynapseConstants . SynapsePrefix + SynapseConstants . SqlScript ) ]
16
- [ OutputType ( typeof ( PSSqlScriptResource ) ) ]
17
- public class SetAzureSynapseSqlScript : SynapseArtifactsCmdletBase
14
+ [ Alias ( "New-" + ResourceManager . Common . AzureRMConstants . AzureRMPrefix + SynapseConstants . SynapsePrefix + SynapseConstants . SparkJobDefinition ) ]
15
+ [ OutputType ( typeof ( PSSparkJobDefinitionResource ) ) ]
16
+ public class SetAzureSynapseSparkJobDefinition : SynapseArtifactsCmdletBase
18
17
{
19
18
private const string SetByName = "SetByName" ;
20
19
private const string SetByObject = "SetByObject" ;
@@ -36,25 +35,22 @@ public class SetAzureSynapseSqlScript : SynapseArtifactsCmdletBase
36
35
[ ValidateNotNull ]
37
36
public PSSynapseWorkspace WorkspaceObject { get ; set ; }
38
37
39
- [ Parameter ( ValueFromPipelineByPropertyName = false , Mandatory = true , HelpMessage = HelpMessages . SqlScriptName ) ]
38
+ [ Parameter ( ValueFromPipelineByPropertyName = false , Mandatory = true , HelpMessage = HelpMessages . SparkJobDefinitionName ) ]
40
39
[ ValidateNotNullOrEmpty ]
41
- [ Alias ( "SqlScriptName " ) ]
40
+ [ Alias ( "SparkJobDefinitionName " ) ]
42
41
public string Name { get ; set ; }
43
42
44
43
[ Parameter ( ValueFromPipelineByPropertyName = false , ParameterSetName = RenameByName ,
45
- Mandatory = true , HelpMessage = HelpMessages . SqlScriptName ) ]
44
+ Mandatory = true , HelpMessage = HelpMessages . SparkJobDefinitionName ) ]
46
45
[ Parameter ( ValueFromPipelineByPropertyName = false , ParameterSetName = RenameByObject ,
47
- Mandatory = true , HelpMessage = HelpMessages . SqlScriptName ) ]
46
+ Mandatory = true , HelpMessage = HelpMessages . SparkJobDefinitionName ) ]
48
47
[ ValidateNotNullOrEmpty ]
49
48
public string NewName { get ; set ; }
50
49
51
- [ Parameter ( ValueFromPipelineByPropertyName = false , ParameterSetName = SetByName ,
52
- Mandatory = true , HelpMessage = HelpMessages . ScriptFilePath ) ]
53
- [ Parameter ( ValueFromPipelineByPropertyName = false , ParameterSetName = SetByObject ,
54
- Mandatory = true , HelpMessage = HelpMessages . ScriptFilePath ) ]
50
+ [ Parameter ( ValueFromPipelineByPropertyName = false , Mandatory = true , HelpMessage = HelpMessages . JsonFilePath ) ]
55
51
[ ValidateNotNullOrEmpty ]
56
52
[ Alias ( "File" ) ]
57
- public string ScriptFile { get ; set ; }
53
+ public string DefinitionFile { get ; set ; }
58
54
59
55
[ Parameter ( Mandatory = false , HelpMessage = HelpMessages . AsJob ) ]
60
56
public SwitchParameter AsJob { get ; set ; }
@@ -66,33 +62,20 @@ public override void ExecuteCmdlet()
66
62
this . WorkspaceName = this . WorkspaceObject . Name ;
67
63
}
68
64
69
- if ( this . ShouldProcess ( this . WorkspaceName , String . Format ( Resources . SettingSynapseSqlScript , this . Name , this . WorkspaceName ) ) )
65
+ if ( this . ShouldProcess ( this . WorkspaceName , String . Format ( Resources . SettingSynapseSparkJobDefinition , this . Name , this . WorkspaceName ) ) )
70
66
{
71
67
switch ( ParameterSetName )
72
68
{
73
69
case SetByName :
74
70
case SetByObject :
75
- string query = this . ReadFileAsText ( this . TryResolvePath ( ScriptFile ) ) ;
76
- SqlConnection connection = new SqlConnection ( SqlConnectionType . SqlPool , )
77
- SqlScriptContent sqlScriptContent = new SqlScriptContent ( query , connection )
78
- {
79
- Metadata = new SqlScriptMetadata
80
- {
81
- Language = "sql"
82
- }
83
- } ;
84
- SqlScript script = new SqlScript ( content ) ;
85
- SqlScriptResource sqlScript = new SqlScriptResource ( this . Name , new SqlScript )
86
- {
87
-
88
- }
89
- WriteObject( new PSSqlScriptResource ( SynapseAnalyticsClient . CreateOrUpdateSqlScript ( this . Name , rawJsonContent ) ) ) ;
71
+ string rawJsonContent = SynapseAnalyticsClient . ReadJsonFileContent ( this . TryResolvePath ( DefinitionFile ) ) ;
72
+ WriteObject ( new PSSparkJobDefinitionResource ( SynapseAnalyticsClient . CreateOrUpdateSparkJobDefinition ( this . Name , rawJsonContent ) ) ) ;
90
73
break ;
91
74
92
75
case RenameByName :
93
76
case RenameByObject :
94
- SynapseAnalyticsClient . RenameSqlScript ( this . Name , this . NewName ) ;
95
- WriteObject ( new PSSqlScriptResource ( SynapseAnalyticsClient . GetSqlScript ( this . Name ) ) ) ;
77
+ SynapseAnalyticsClient . RenameSparkJobDefinition ( this . Name , this . NewName ) ;
78
+ WriteObject ( new PSSparkJobDefinitionResource ( SynapseAnalyticsClient . GetSparkJobDefinition ( this . Name ) ) ) ;
96
79
break ;
97
80
98
81
default : throw new AzPSInvalidOperationException ( string . Format ( Resources . InvalidParameterSet , this . ParameterSetName ) ) ;
0 commit comments